From 834ea2c5c0dbc92ad8129350ac69e1927c868aae Mon Sep 17 00:00:00 2001 From: Chunyang Dai Date: Thu, 22 Oct 2015 00:24:12 +0800 Subject: [PATCH 001/261] build,src: add Intel Vtune profiling support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This feature supports the Intel Vtune profiling support for JITted JavaScript on IA32 / X64 / X32 platform. The advantage of this profiling is that the user / developer of NodeJS application can get the detailed profiling information for every line of the JavaScript source code. This information will be very useful for the owner to optimize their applications. This feature is a compile-time option. For windows platform, the user needs to pass the following parameter to vcbuild.bat: "enable-vtune" For other OS, the user needs to pass the following parameter to ./configure command: "--enable-vtune-profiling" Ref: https://github.com/nodejs/node/pull/3785 PR-URL: https://github.com/nodejs/node/pull/5527 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Johan Bergström --- configure | 17 +++++++++++++++++ node.gyp | 8 ++++++++ src/node.cc | 7 +++++++ vcbuild.bat | 7 +++++-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 054ebb41cbd8e4..1bb0da21ce67fc 100755 --- a/configure +++ b/configure @@ -92,6 +92,14 @@ parser.add_option("--partly-static", help="Generate an executable with libgcc and libstdc++ libraries. This " "will not work on OSX when using the default compilation environment") +parser.add_option("--enable-vtune-profiling", + action="store_true", + dest="enable_vtune_profiling", + help="Enable profiling support for Intel Vtune profiler to profile" + "JavaScript code executed in nodejs. This feature is only available " + "for ia32, x32 or x64 platform.") + + parser.add_option("--link-module", action="append", dest="linked_module", @@ -686,6 +694,15 @@ def configure_node(o): o['variables']['node_core_target_name'] = 'node_base' o['variables']['node_target_type'] = 'static_library' + if target_arch in ('x86', 'x64', 'ia32', 'x32'): + o['variables']['node_enable_v8_vtunejit'] = b(options.enable_vtune_profiling) + elif options.enable_vtune_profiling: + raise Exception( + 'vtune profiler for JavaScript is only supported on x86, x32 or x64 ' + 'platform.') + else: + o['variables']['node_enable_v8_vtunejit'] = 'false' + if flavor in ('solaris', 'mac', 'linux', 'freebsd'): use_dtrace = not options.without_dtrace # Don't enable by default on linux and freebsd diff --git a/node.gyp b/node.gyp index d549e18c050cef..240922d619337f 100644 --- a/node.gyp +++ b/node.gyp @@ -12,6 +12,7 @@ 'node_use_openssl%': 'true', 'node_shared_openssl%': 'false', 'node_v8_options%': '', + 'node_enable_v8_vtunejit%': 'false', 'node_target_type%': 'executable', 'node_core_target_name%': 'node', 'library_files': [ @@ -235,6 +236,13 @@ 'defines': [ 'NODE_HAVE_SMALL_ICU=1' ], }]], }], + [ 'node_enable_v8_vtunejit=="true" and (target_arch=="x64" or \ + target_arch=="ia32" or target_arch=="x32")', { + 'defines': [ 'NODE_ENABLE_VTUNE_PROFILING' ], + 'dependencies': [ + 'deps/v8/src/third_party/vtune/v8vtune.gyp:v8_vtune' + ], + }], [ 'node_use_openssl=="true"', { 'defines': [ 'HAVE_OPENSSL=1' ], 'sources': [ diff --git a/src/node.cc b/src/node.cc index 85383fa166661c..8264bfe8bba8a3 100644 --- a/src/node.cc +++ b/src/node.cc @@ -44,6 +44,10 @@ #include "v8-profiler.h" #include "zlib.h" +#ifdef NODE_ENABLE_VTUNE_PROFILING +#include "../deps/v8/src/third_party/vtune/v8-vtune.h" +#endif + #include #include // PATH_MAX #include @@ -4070,6 +4074,9 @@ static void StartNodeInstance(void* arg) { Isolate::CreateParams params; ArrayBufferAllocator* array_buffer_allocator = new ArrayBufferAllocator(); params.array_buffer_allocator = array_buffer_allocator; +#ifdef NODE_ENABLE_VTUNE_PROFILING + params.code_event_handler = vTune::GetVtuneCodeEventHandler(); +#endif Isolate* isolate = Isolate::New(params); if (track_heap_objects) { isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); diff --git a/vcbuild.bat b/vcbuild.bat index 852ee85268e2ec..14c65fdcdb3bf5 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -36,6 +36,7 @@ set release_urls_arg= set build_release= set configure_flags= set build_addons= +set enable_vtune_profiling= :next-arg if "%1"=="" goto args-done @@ -73,6 +74,7 @@ if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok if /i "%1"=="ignore-flaky" set test_args=%test_args% --flaky-tests=dontcare&goto arg-ok +if /i "%1"=="enable-vtune" set enable_vtune_profiling="--enable-vtune-profiling"&goto arg-ok echo Warning: ignoring invalid command line option `%1`. @@ -179,7 +181,7 @@ if defined noprojgen goto msbuild @rem Generate the VS project. echo configure %configure_flags% --dest-cpu=%target_arch% --tag=%TAG% -python configure %configure_flags% --dest-cpu=%target_arch% --tag=%TAG% +python configure %configure_flags% %enable_vtune_profiling% --dest-cpu=%target_arch% --tag=%TAG% if errorlevel 1 goto create-msvs-files-failed if not exist node.sln goto create-msvs-files-failed echo Project files generated. @@ -294,7 +296,7 @@ goto exit :help -echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] +echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [vc2013/vc2015] [download-all] [enable-vtune] echo Examples: echo vcbuild.bat : builds release build @@ -302,6 +304,7 @@ echo vcbuild.bat debug : builds debug build echo vcbuild.bat release msi : builds release build and MSI installer package echo vcbuild.bat test : builds debug build and runs tests echo vcbuild.bat build-release : builds the release distribution as used by nodejs.org +echo vcbuild.bat enable-vtune : builds nodejs with Intel Vtune profiling support to profile JavaScript goto exit :exit From da9595fc472701e7c4fc38a03436cd906730fbe9 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 11 Nov 2015 14:32:06 -0500 Subject: [PATCH 002/261] deps: cherry-pick 68e89fb from v8's upstream Original commit message: This commit adds some postmortem data that is otherwise unavailable. I have discovered need in those values when writing: https://github.com/indutny/llnode BUG= Review URL: https://codereview.chromium.org/1436473002 Cr-Commit-Position: refs/heads/master@{#31947} This postmortem information is useful for both object inspection, and function's context variables inspection. PR-URL: https://github.com/nodejs/node/pull/3779 Reviewed-By: Ben Noordhuis --- deps/v8/tools/gen-postmortem-metadata.py | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/deps/v8/tools/gen-postmortem-metadata.py b/deps/v8/tools/gen-postmortem-metadata.py index 0bd7952894e698..9dffd59e5d3ad8 100644 --- a/deps/v8/tools/gen-postmortem-metadata.py +++ b/deps/v8/tools/gen-postmortem-metadata.py @@ -98,6 +98,30 @@ 'value': 'PropertyDetails::FieldIndexField::kMask' }, { 'name': 'prop_index_shift', 'value': 'PropertyDetails::FieldIndexField::kShift' }, + { 'name': 'prop_representation_mask', + 'value': 'PropertyDetails::RepresentationField::kMask' }, + { 'name': 'prop_representation_shift', + 'value': 'PropertyDetails::RepresentationField::kShift' }, + { 'name': 'prop_representation_integer8', + 'value': 'Representation::Kind::kInteger8' }, + { 'name': 'prop_representation_uinteger8', + 'value': 'Representation::Kind::kUInteger8' }, + { 'name': 'prop_representation_integer16', + 'value': 'Representation::Kind::kInteger16' }, + { 'name': 'prop_representation_uinteger16', + 'value': 'Representation::Kind::kUInteger16' }, + { 'name': 'prop_representation_smi', + 'value': 'Representation::Kind::kSmi' }, + { 'name': 'prop_representation_integer32', + 'value': 'Representation::Kind::kInteger32' }, + { 'name': 'prop_representation_double', + 'value': 'Representation::Kind::kDouble' }, + { 'name': 'prop_representation_heapobject', + 'value': 'Representation::Kind::kHeapObject' }, + { 'name': 'prop_representation_tagged', + 'value': 'Representation::Kind::kTagged' }, + { 'name': 'prop_representation_external', + 'value': 'Representation::Kind::kExternal' }, { 'name': 'prop_desc_key', 'value': 'DescriptorArray::kDescriptorKey' }, @@ -121,6 +145,10 @@ 'value': 'Map::ElementsKindBits::kShift' }, { 'name': 'bit_field3_dictionary_map_shift', 'value': 'Map::DictionaryMap::kShift' }, + { 'name': 'bit_field3_number_of_own_descriptors_mask', + 'value': 'Map::NumberOfOwnDescriptorsBits::kMask' }, + { 'name': 'bit_field3_number_of_own_descriptors_shift', + 'value': 'Map::NumberOfOwnDescriptorsBits::kShift' }, { 'name': 'off_fp_context', 'value': 'StandardFrameConstants::kContextOffset' }, @@ -139,14 +167,31 @@ 'value': 'ScopeInfo::kStackLocalCount' }, { 'name': 'scopeinfo_idx_ncontextlocals', 'value': 'ScopeInfo::kContextLocalCount' }, + { 'name': 'scopeinfo_idx_ncontextglobals', + 'value': 'ScopeInfo::kContextGlobalCount' }, { 'name': 'scopeinfo_idx_first_vars', 'value': 'ScopeInfo::kVariablePartIndex' }, + + { 'name': 'sharedfunctioninfo_start_position_mask', + 'value': 'SharedFunctionInfo::kStartPositionMask' }, + { 'name': 'sharedfunctioninfo_start_position_shift', + 'value': 'SharedFunctionInfo::kStartPositionShift' }, + + { 'name': 'jsarray_buffer_was_neutered_mask', + 'value': 'JSArrayBuffer::WasNeutered::kMask' }, + { 'name': 'jsarray_buffer_was_neutered_shift', + 'value': 'JSArrayBuffer::WasNeutered::kShift' }, ]; # # The following useful fields are missing accessors, so we define fake ones. # extras_accessors = [ + 'JSFunction, context, Context, kContextOffset', + 'Context, closure_index, int, CLOSURE_INDEX', + 'Context, global_object_index, int, GLOBAL_OBJECT_INDEX', + 'Context, previous_index, int, PREVIOUS_INDEX', + 'Context, min_context_slots, int, MIN_CONTEXT_SLOTS', 'HeapObject, map, Map, kMapOffset', 'JSObject, elements, Object, kElementsOffset', 'FixedArray, data, uintptr_t, kHeaderSize', @@ -160,6 +205,7 @@ 'Map, prototype, Object, kPrototypeOffset', 'NameDictionaryShape, prefix_size, int, kPrefixSize', 'NameDictionaryShape, entry_size, int, kEntrySize', + 'NameDictionary, prefix_start_index, int, kPrefixStartIndex', 'SeededNumberDictionaryShape, prefix_size, int, kPrefixSize', 'UnseededNumberDictionaryShape, prefix_size, int, kPrefixSize', 'NumberDictionaryShape, entry_size, int, kEntrySize', @@ -171,6 +217,7 @@ 'SeqOneByteString, chars, char, kHeaderSize', 'SeqTwoByteString, chars, char, kHeaderSize', 'SharedFunctionInfo, code, Code, kCodeOffset', + 'SharedFunctionInfo, scope_info, ScopeInfo, kScopeInfoOffset', 'SlicedString, parent, String, kParentOffset', 'Code, instruction_start, uintptr_t, kHeaderSize', 'Code, instruction_size, int, kInstructionSizeOffset', From 2eb097f212a8e843d8193cd5e0bc80e7934537b1 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Thu, 11 Feb 2016 13:09:52 -0700 Subject: [PATCH 003/261] src: fix MakeCallback error handling Implementations of error handling between node::MakeCallback() and AsyncWrap::MakeCallback() do not return at the same point. Make both executions work the same by moving the early return if there's a caught exception just after the AsyncWrap post callback. Since the domain's call stack is cleared on a caught exception there is no reason to call its exit() callback. Remove the SetVerbose() statement in the AsyncWrap pre/post callback calls since it does not affect the callback call. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- src/async-wrap.cc | 13 +++++-------- src/node.cc | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index c9f5caad1e4ea8..29ea139f5f91c0 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -207,25 +207,22 @@ Local AsyncWrap::MakeCallback(const Local cb, } if (ran_init_callback() && !pre_fn.IsEmpty()) { - try_catch.SetVerbose(false); pre_fn->Call(context, 0, nullptr); if (try_catch.HasCaught()) FatalError("node::AsyncWrap::MakeCallback", "pre hook threw"); - try_catch.SetVerbose(true); } Local ret = cb->Call(context, argc, argv); - if (try_catch.HasCaught()) { - return Undefined(env()->isolate()); - } - if (ran_init_callback() && !post_fn.IsEmpty()) { - try_catch.SetVerbose(false); post_fn->Call(context, 0, nullptr); if (try_catch.HasCaught()) FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); - try_catch.SetVerbose(true); + } + + // If the return value is empty then the callback threw. + if (ret.IsEmpty()) { + return Undefined(env()->isolate()); } if (has_domain) { diff --git a/src/node.cc b/src/node.cc index 8264bfe8bba8a3..b048166cd9d8df 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1165,21 +1165,22 @@ Local MakeCallback(Environment* env, } if (ran_init_callback && !pre_fn.IsEmpty()) { - try_catch.SetVerbose(false); pre_fn->Call(object, 0, nullptr); if (try_catch.HasCaught()) FatalError("node::MakeCallback", "pre hook threw"); - try_catch.SetVerbose(true); } Local ret = callback->Call(recv, argc, argv); if (ran_init_callback && !post_fn.IsEmpty()) { - try_catch.SetVerbose(false); post_fn->Call(object, 0, nullptr); if (try_catch.HasCaught()) FatalError("node::MakeCallback", "post hook threw"); - try_catch.SetVerbose(true); + } + + // If the return value is empty then the callback threw. + if (ret.IsEmpty()) { + return Undefined(env->isolate()); } if (has_domain) { @@ -1191,10 +1192,6 @@ Local MakeCallback(Environment* env, } } - if (try_catch.HasCaught()) { - return Undefined(env->isolate()); - } - if (!env->KickNextTick()) return Undefined(env->isolate()); From cb291d5c7f980a591be637c80d3d095d43d47217 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 5 Jan 2016 15:33:21 -0700 Subject: [PATCH 004/261] src: add AsyncCallbackScope Add a scope that will allow MakeCallback to know whether or not it's currently running. This will prevent nextTickQueue and the MicrotaskQueue from being processed recursively. It is also required to wrap the bootloading stage since it doesn't run within a MakeCallback. Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245 Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- src/async-wrap.cc | 8 +++----- src/env-inl.h | 15 +++++++++++++++ src/env.cc | 8 ++------ src/env.h | 16 +++++++++++++++- src/node.cc | 9 +++++++-- src/node_http_parser.cc | 4 +++- src/node_internals.h | 2 -- 7 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 29ea139f5f91c0..01dcaf277c1840 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -184,6 +184,8 @@ Local AsyncWrap::MakeCallback(const Local cb, Local domain; bool has_domain = false; + Environment::AsyncCallbackScope callback_scope(env()); + if (env()->using_domains()) { Local domain_v = context->Get(env()->domain_string()); has_domain = domain_v->IsObject(); @@ -236,7 +238,7 @@ Local AsyncWrap::MakeCallback(const Local cb, Environment::TickInfo* tick_info = env()->tick_info(); - if (tick_info->in_tick()) { + if (callback_scope.in_makecallback()) { return ret; } @@ -249,12 +251,8 @@ Local AsyncWrap::MakeCallback(const Local cb, return ret; } - tick_info->set_in_tick(true); - env()->tick_callback_function()->Call(process, 0, nullptr); - tick_info->set_in_tick(false); - if (try_catch.HasCaught()) { tick_info->set_last_threw(true); return Undefined(env()->isolate()); diff --git a/src/env-inl.h b/src/env-inl.h index f73e9c6ba2000a..eebb68eb463e93 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -88,6 +88,20 @@ inline void Environment::AsyncHooks::set_enable_callbacks(uint32_t flag) { fields_[kEnableCallbacks] = flag; } +inline Environment::AsyncCallbackScope::AsyncCallbackScope(Environment* env) + : env_(env) { + env_->makecallback_cntr_++; +} + +inline Environment::AsyncCallbackScope::~AsyncCallbackScope() { + env_->makecallback_cntr_--; + CHECK_GE(env_->makecallback_cntr_, 0); +} + +inline bool Environment::AsyncCallbackScope::in_makecallback() { + return env_->makecallback_cntr_ > 1; +} + inline Environment::DomainFlag::DomainFlag() { for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; } @@ -210,6 +224,7 @@ inline Environment::Environment(v8::Local context, using_domains_(false), printed_error_(false), trace_sync_io_(false), + makecallback_cntr_(0), async_wrap_uid_(0), debugger_agent_(this), http_parser_buffer_(nullptr), diff --git a/src/env.cc b/src/env.cc index e28866efd06894..8fa6e5c43afe06 100644 --- a/src/env.cc +++ b/src/env.cc @@ -57,10 +57,10 @@ void Environment::PrintSyncTrace() const { } -bool Environment::KickNextTick() { +bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) { TickInfo* info = tick_info(); - if (info->in_tick()) { + if (scope->in_makecallback()) { return true; } @@ -73,15 +73,11 @@ bool Environment::KickNextTick() { return true; } - info->set_in_tick(true); - // process nextTicks after call TryCatch try_catch; try_catch.SetVerbose(true); tick_callback_function()->Call(process_object(), 0, nullptr); - info->set_in_tick(false); - if (try_catch.HasCaught()) { info->set_last_threw(true); return false; diff --git a/src/env.h b/src/env.h index 1531d9911e310b..8ae681ff43c86f 100644 --- a/src/env.h +++ b/src/env.h @@ -294,6 +294,19 @@ class Environment { DISALLOW_COPY_AND_ASSIGN(AsyncHooks); }; + class AsyncCallbackScope { + public: + explicit AsyncCallbackScope(Environment* env); + ~AsyncCallbackScope(); + + inline bool in_makecallback(); + + private: + Environment* env_; + + DISALLOW_COPY_AND_ASSIGN(AsyncCallbackScope); + }; + class DomainFlag { public: inline uint32_t* fields(); @@ -446,7 +459,7 @@ class Environment { inline int64_t get_async_wrap_uid(); - bool KickNextTick(); + bool KickNextTick(AsyncCallbackScope* scope); inline uint32_t* heap_statistics_buffer() const; inline void set_heap_statistics_buffer(uint32_t* pointer); @@ -541,6 +554,7 @@ class Environment { bool using_domains_; bool printed_error_; bool trace_sync_io_; + size_t makecallback_cntr_; int64_t async_wrap_uid_; debugger::Agent debugger_agent_; diff --git a/src/node.cc b/src/node.cc index b048166cd9d8df..ef59a103c30eac 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1132,6 +1132,8 @@ Local MakeCallback(Environment* env, bool ran_init_callback = false; bool has_domain = false; + Environment::AsyncCallbackScope callback_scope(env); + // TODO(trevnorris): Adding "_asyncQueue" to the "this" in the init callback // is a horrible way to detect usage. Rethink how detection should happen. if (recv->IsObject()) { @@ -1192,7 +1194,7 @@ Local MakeCallback(Environment* env, } } - if (!env->KickNextTick()) + if (!env->KickNextTick(&callback_scope)) return Undefined(env->isolate()); return ret; @@ -4100,7 +4102,10 @@ static void StartNodeInstance(void* arg) { if (instance_data->use_debug_agent()) StartDebug(env, debug_wait_connect); - LoadEnvironment(env); + { + Environment::AsyncCallbackScope callback_scope(env); + LoadEnvironment(env); + } env->set_trace_sync_io(trace_sync_io); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 8c976b2e9f0b4c..c6254d57c840ed 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -579,6 +579,8 @@ class Parser : public BaseObject { if (!cb->IsFunction()) return; + Environment::AsyncCallbackScope callback_scope(parser->env()); + // Hooks for GetCurrentBuffer parser->current_buffer_len_ = nread; parser->current_buffer_data_ = buf->base; @@ -588,7 +590,7 @@ class Parser : public BaseObject { parser->current_buffer_len_ = 0; parser->current_buffer_data_ = nullptr; - parser->env()->KickNextTick(); + parser->env()->KickNextTick(&callback_scope); } diff --git a/src/node_internals.h b/src/node_internals.h index 3df7676d2a9d51..6e3f7204777835 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -69,8 +69,6 @@ v8::Local MakeCallback(Environment* env, int argc = 0, v8::Local* argv = nullptr); -bool KickNextTick(); - // Convert a struct sockaddr to a { address: '1.2.3.4', port: 1234 } JS object. // Sets address and port properties on the info object and returns it. // If |info| is omitted, a new object is returned. From d77b28c6b3bf81cda19694004bef7bd8c7cc9108 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Thu, 11 Feb 2016 13:10:47 -0700 Subject: [PATCH 005/261] src: remove unused of TickInfo::last_threw() Environment::TickInfo::last_threw() is no longer in use. Also pass Isolate to few methods and fix whitespace alignment. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- src/async-wrap.cc | 5 ++--- src/env-inl.h | 10 +--------- src/env.cc | 3 +-- src/env.h | 3 --- src/node.cc | 10 +++++----- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 01dcaf277c1840..789e357c732773 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -173,8 +173,8 @@ void LoadAsyncWrapperInfo(Environment* env) { Local AsyncWrap::MakeCallback(const Local cb, - int argc, - Local* argv) { + int argc, + Local* argv) { CHECK(env()->context() == env()->isolate()->GetCurrentContext()); Local pre_fn = env()->async_hooks_pre_function(); @@ -254,7 +254,6 @@ Local AsyncWrap::MakeCallback(const Local cb, env()->tick_callback_function()->Call(process, 0, nullptr); if (try_catch.HasCaught()) { - tick_info->set_last_threw(true); return Undefined(env()->isolate()); } diff --git a/src/env-inl.h b/src/env-inl.h index eebb68eb463e93..f50ec13732e015 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -118,7 +118,7 @@ inline uint32_t Environment::DomainFlag::count() const { return fields_[kCount]; } -inline Environment::TickInfo::TickInfo() : in_tick_(false), last_threw_(false) { +inline Environment::TickInfo::TickInfo() : in_tick_(false) { for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; } @@ -139,10 +139,6 @@ inline uint32_t Environment::TickInfo::index() const { return fields_[kIndex]; } -inline bool Environment::TickInfo::last_threw() const { - return last_threw_; -} - inline uint32_t Environment::TickInfo::length() const { return fields_[kLength]; } @@ -155,10 +151,6 @@ inline void Environment::TickInfo::set_index(uint32_t value) { fields_[kIndex] = value; } -inline void Environment::TickInfo::set_last_threw(bool value) { - last_threw_ = value; -} - inline Environment::ArrayBufferAllocatorInfo::ArrayBufferAllocatorInfo() { for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; diff --git a/src/env.cc b/src/env.cc index 8fa6e5c43afe06..a9b108c47a49be 100644 --- a/src/env.cc +++ b/src/env.cc @@ -74,12 +74,11 @@ bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) { } // process nextTicks after call - TryCatch try_catch; + TryCatch try_catch(isolate()); try_catch.SetVerbose(true); tick_callback_function()->Call(process_object(), 0, nullptr); if (try_catch.HasCaught()) { - info->set_last_threw(true); return false; } diff --git a/src/env.h b/src/env.h index 8ae681ff43c86f..5849d7a92107e2 100644 --- a/src/env.h +++ b/src/env.h @@ -332,12 +332,10 @@ class Environment { inline uint32_t* fields(); inline int fields_count() const; inline bool in_tick() const; - inline bool last_threw() const; inline uint32_t index() const; inline uint32_t length() const; inline void set_in_tick(bool value); inline void set_index(uint32_t value); - inline void set_last_threw(bool value); private: friend class Environment; // So we can call the constructor. @@ -351,7 +349,6 @@ class Environment { uint32_t fields_[kFieldsCount]; bool in_tick_; - bool last_threw_; DISALLOW_COPY_AND_ASSIGN(TickInfo); }; diff --git a/src/node.cc b/src/node.cc index ef59a103c30eac..fc39b8399a1ffa 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1119,10 +1119,10 @@ void SetupPromises(const FunctionCallbackInfo& args) { Local MakeCallback(Environment* env, - Local recv, - const Local callback, - int argc, - Local argv[]) { + Local recv, + const Local callback, + int argc, + Local argv[]) { // If you hit this assertion, you forgot to enter the v8::Context first. CHECK_EQ(env->context(), env->isolate()->GetCurrentContext()); @@ -1154,7 +1154,7 @@ Local MakeCallback(Environment* env, } } - TryCatch try_catch; + TryCatch try_catch(env->isolate()); try_catch.SetVerbose(true); if (has_domain) { From 48b7b71352f0b11453468a876e8a28d2ef2927a2 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 10 Feb 2016 12:48:44 -0700 Subject: [PATCH 006/261] src: remove unused TickInfo::in_tick() Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- src/env-inl.h | 10 +--------- src/env.h | 3 --- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index f50ec13732e015..9084cb5159e58a 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -118,7 +118,7 @@ inline uint32_t Environment::DomainFlag::count() const { return fields_[kCount]; } -inline Environment::TickInfo::TickInfo() : in_tick_(false) { +inline Environment::TickInfo::TickInfo() { for (int i = 0; i < kFieldsCount; ++i) fields_[i] = 0; } @@ -131,10 +131,6 @@ inline int Environment::TickInfo::fields_count() const { return kFieldsCount; } -inline bool Environment::TickInfo::in_tick() const { - return in_tick_; -} - inline uint32_t Environment::TickInfo::index() const { return fields_[kIndex]; } @@ -143,10 +139,6 @@ inline uint32_t Environment::TickInfo::length() const { return fields_[kLength]; } -inline void Environment::TickInfo::set_in_tick(bool value) { - in_tick_ = value; -} - inline void Environment::TickInfo::set_index(uint32_t value) { fields_[kIndex] = value; } diff --git a/src/env.h b/src/env.h index 5849d7a92107e2..44318da1fa3d0f 100644 --- a/src/env.h +++ b/src/env.h @@ -331,10 +331,8 @@ class Environment { public: inline uint32_t* fields(); inline int fields_count() const; - inline bool in_tick() const; inline uint32_t index() const; inline uint32_t length() const; - inline void set_in_tick(bool value); inline void set_index(uint32_t value); private: @@ -348,7 +346,6 @@ class Environment { }; uint32_t fields_[kFieldsCount]; - bool in_tick_; DISALLOW_COPY_AND_ASSIGN(TickInfo); }; From 981bbcd9256379d15d5d2fafd60e78f749579729 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Thu, 11 Feb 2016 13:57:26 -0700 Subject: [PATCH 007/261] src: remove TryCatch in MakeCallback After attempting to use ReThrow() and Reset() there were cases where firing the domain's error handlers was not happening. Or in some cases reentering MakeCallback would still cause the domain enter callback to abort (because the error had not been Reset yet). In order for the script to properly stop execution when a subsequent call to MakeCallback throws it must not be located within a TryCatch. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- src/async-wrap.cc | 28 +++++++++++----------------- src/env.cc | 13 ++++--------- src/node.cc | 27 ++++++++++++--------------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 789e357c732773..a7a9822238329a 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -196,33 +196,28 @@ Local AsyncWrap::MakeCallback(const Local cb, } } - TryCatch try_catch(env()->isolate()); - try_catch.SetVerbose(true); - if (has_domain) { Local enter_v = domain->Get(env()->enter_string()); if (enter_v->IsFunction()) { - enter_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env()->isolate()); + if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain enter callback threw, please report this"); + } } } if (ran_init_callback() && !pre_fn.IsEmpty()) { - pre_fn->Call(context, 0, nullptr); - if (try_catch.HasCaught()) + if (pre_fn->Call(context, 0, nullptr).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "pre hook threw"); } Local ret = cb->Call(context, argc, argv); if (ran_init_callback() && !post_fn.IsEmpty()) { - post_fn->Call(context, 0, nullptr); - if (try_catch.HasCaught()) + if (post_fn->Call(context, 0, nullptr).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); } - // If the return value is empty then the callback threw. if (ret.IsEmpty()) { return Undefined(env()->isolate()); } @@ -230,9 +225,10 @@ Local AsyncWrap::MakeCallback(const Local cb, if (has_domain) { Local exit_v = domain->Get(env()->exit_string()); if (exit_v->IsFunction()) { - exit_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env()->isolate()); + if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::AsyncWrap::MakeCallback", + "domain exit callback threw, please report this"); + } } } @@ -251,9 +247,7 @@ Local AsyncWrap::MakeCallback(const Local cb, return ret; } - env()->tick_callback_function()->Call(process, 0, nullptr); - - if (try_catch.HasCaught()) { + if (env()->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) { return Undefined(env()->isolate()); } diff --git a/src/env.cc b/src/env.cc index a9b108c47a49be..144a37f2e3cb67 100644 --- a/src/env.cc +++ b/src/env.cc @@ -11,6 +11,7 @@ using v8::Message; using v8::StackFrame; using v8::StackTrace; using v8::TryCatch; +using v8::Value; void Environment::PrintSyncTrace() const { if (!trace_sync_io_) @@ -73,16 +74,10 @@ bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) { return true; } - // process nextTicks after call - TryCatch try_catch(isolate()); - try_catch.SetVerbose(true); - tick_callback_function()->Call(process_object(), 0, nullptr); + Local ret = + tick_callback_function()->Call(process_object(), 0, nullptr); - if (try_catch.HasCaught()) { - return false; - } - - return true; + return !ret.IsEmpty(); } } // namespace node diff --git a/src/node.cc b/src/node.cc index fc39b8399a1ffa..5b4b2f8c8affa0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1154,33 +1154,28 @@ Local MakeCallback(Environment* env, } } - TryCatch try_catch(env->isolate()); - try_catch.SetVerbose(true); - if (has_domain) { Local enter_v = domain->Get(env->enter_string()); if (enter_v->IsFunction()) { - enter_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env->isolate()); + if (enter_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::MakeCallback", + "domain enter callback threw, please report this"); + } } } if (ran_init_callback && !pre_fn.IsEmpty()) { - pre_fn->Call(object, 0, nullptr); - if (try_catch.HasCaught()) + if (pre_fn->Call(object, 0, nullptr).IsEmpty()) FatalError("node::MakeCallback", "pre hook threw"); } Local ret = callback->Call(recv, argc, argv); if (ran_init_callback && !post_fn.IsEmpty()) { - post_fn->Call(object, 0, nullptr); - if (try_catch.HasCaught()) + if (post_fn->Call(object, 0, nullptr).IsEmpty()) FatalError("node::MakeCallback", "post hook threw"); } - // If the return value is empty then the callback threw. if (ret.IsEmpty()) { return Undefined(env->isolate()); } @@ -1188,14 +1183,16 @@ Local MakeCallback(Environment* env, if (has_domain) { Local exit_v = domain->Get(env->exit_string()); if (exit_v->IsFunction()) { - exit_v.As()->Call(domain, 0, nullptr); - if (try_catch.HasCaught()) - return Undefined(env->isolate()); + if (exit_v.As()->Call(domain, 0, nullptr).IsEmpty()) { + FatalError("node::MakeCallback", + "domain exit callback threw, please report this"); + } } } - if (!env->KickNextTick(&callback_scope)) + if (!env->KickNextTick(&callback_scope)) { return Undefined(env->isolate()); + } return ret; } From 1186b7a40144836ae0dbfb76fa7d2789593945d6 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 6 Jan 2016 10:39:40 -0700 Subject: [PATCH 008/261] test: add addons test for MakeCallback Make sure that calling MakeCallback multiple times within the same stack does not allow the nextTickQueue or MicrotaskQueue to be processed in any more than the first MakeCallback call. Check that domains enter/exit poperly with multiple MakeCallback calls and that errors are handled as expected Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny --- test/addons/make-callback-recurse/binding.cc | 31 ++++ test/addons/make-callback-recurse/binding.gyp | 8 + test/addons/make-callback-recurse/test.js | 170 ++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 test/addons/make-callback-recurse/binding.cc create mode 100644 test/addons/make-callback-recurse/binding.gyp create mode 100644 test/addons/make-callback-recurse/test.js diff --git a/test/addons/make-callback-recurse/binding.cc b/test/addons/make-callback-recurse/binding.cc new file mode 100644 index 00000000000000..1c575910ef66f5 --- /dev/null +++ b/test/addons/make-callback-recurse/binding.cc @@ -0,0 +1,31 @@ +#include "node.h" +#include "v8.h" + +#include "../../../src/util.h" + +using v8::Function; +using v8::FunctionCallbackInfo; +using v8::Isolate; +using v8::Local; +using v8::Object; +using v8::Value; + +namespace { + +void MakeCallback(const FunctionCallbackInfo& args) { + CHECK(args[0]->IsObject()); + CHECK(args[1]->IsFunction()); + Isolate* isolate = args.GetIsolate(); + Local recv = args[0].As(); + Local method = args[1].As(); + + node::MakeCallback(isolate, recv, method, 0, nullptr); +} + +void Initialize(Local target) { + NODE_SET_METHOD(target, "makeCallback", MakeCallback); +} + +} // namespace anonymous + +NODE_MODULE(binding, Initialize) diff --git a/test/addons/make-callback-recurse/binding.gyp b/test/addons/make-callback-recurse/binding.gyp new file mode 100644 index 00000000000000..3bfb84493f3e87 --- /dev/null +++ b/test/addons/make-callback-recurse/binding.gyp @@ -0,0 +1,8 @@ +{ + 'targets': [ + { + 'target_name': 'binding', + 'sources': [ 'binding.cc' ] + } + ] +} diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js new file mode 100644 index 00000000000000..f924ac61916ba5 --- /dev/null +++ b/test/addons/make-callback-recurse/test.js @@ -0,0 +1,170 @@ +'use strict'; + +const common = require('../../common'); +const assert = require('assert'); +const domain = require('domain'); +const binding = require('./build/Release/binding'); +const makeCallback = binding.makeCallback; + +// Make sure this is run in the future. +const mustCallCheckDomains = common.mustCall(checkDomains); + + +// Make sure that using MakeCallback allows the error to propagate. +assert.throws(function() { + makeCallback({}, function() { + throw new Error('hi from domain error'); + }); +}); + + +// Check the execution order of the nextTickQueue and MicrotaskQueue in +// relation to running multiple MakeCallback's from bootstrap, +// node::MakeCallback() and node::AsyncWrap::MakeCallback(). +// TODO(trevnorris): Is there a way to verify this is being run during +// bootstrap? +(function verifyExecutionOrder(arg) { + const results_arr = []; + + // Processing of the MicrotaskQueue is manually handled by node. They are not + // processed until after the nextTickQueue has been processed. + Promise.resolve(1).then(common.mustCall(function() { + results_arr.push(7); + })); + + // The nextTick should run after all immediately invoked calls. + process.nextTick(common.mustCall(function() { + results_arr.push(3); + + // Run same test again but while processing the nextTickQueue to make sure + // the following MakeCallback call breaks in the middle of processing the + // queue and allows the script to run normally. + process.nextTick(common.mustCall(function() { + results_arr.push(6); + })); + + makeCallback({}, common.mustCall(function() { + results_arr.push(4); + })); + + results_arr.push(5); + })); + + results_arr.push(0); + + // MakeCallback is calling the function immediately, but should then detect + // that a script is already in the middle of execution and return before + // either the nextTickQueue or MicrotaskQueue are processed. + makeCallback({}, common.mustCall(function() { + results_arr.push(1); + })); + + // This should run before either the nextTickQueue or MicrotaskQueue are + // processed. Previously MakeCallback would not detect this circumstance + // and process them immediately. + results_arr.push(2); + + setImmediate(common.mustCall(function() { + for (var i = 0; i < results_arr.length; i++) { + assert.equal(results_arr[i], + i, + `verifyExecutionOrder(${arg}) results: ${results_arr}`); + } + if (arg === 1) { + // The tests are first run on bootstrap during LoadEnvironment() in + // src/node.cc. Now run the tests through node::MakeCallback(). + setImmediate(function() { + makeCallback({}, common.mustCall(function() { + verifyExecutionOrder(2); + })); + }); + } else if (arg === 2) { + // setTimeout runs via the TimerWrap, which runs through + // AsyncWrap::MakeCallback(). Make sure there are no conflicts using + // node::MakeCallback() within it. + setTimeout(common.mustCall(function() { + verifyExecutionOrder(3); + }), 10); + } else if (arg === 3) { + mustCallCheckDomains(); + } else { + throw new Error('UNREACHABLE'); + } + })); +}(1)); + + +function checkDomains() { + // Check that domains are properly entered/exited when called in multiple + // levels from both node::MakeCallback() and AsyncWrap::MakeCallback + setImmediate(common.mustCall(function() { + const d1 = domain.create(); + const d2 = domain.create(); + const d3 = domain.create(); + + makeCallback({ domain: d1 }, common.mustCall(function() { + assert.equal(d1, process.domain); + makeCallback({ domain: d2 }, common.mustCall(function() { + assert.equal(d2, process.domain); + makeCallback({ domain: d3 }, common.mustCall(function() { + assert.equal(d3, process.domain); + })); + assert.equal(d2, process.domain); + })); + assert.equal(d1, process.domain); + })); + })); + + setTimeout(common.mustCall(function() { + const d1 = domain.create(); + const d2 = domain.create(); + const d3 = domain.create(); + + makeCallback({ domain: d1 }, common.mustCall(function() { + assert.equal(d1, process.domain); + makeCallback({ domain: d2 }, common.mustCall(function() { + assert.equal(d2, process.domain); + makeCallback({ domain: d3 }, common.mustCall(function() { + assert.equal(d3, process.domain); + })); + assert.equal(d2, process.domain); + })); + assert.equal(d1, process.domain); + })); + }), 1); + + // Make sure nextTick, setImmediate and setTimeout can all recover properly + // after a thrown makeCallback call. + process.nextTick(common.mustCall(function() { + const d = domain.create(); + d.on('error', common.mustCall(function(e) { + assert.equal(e.message, 'throw from domain 3'); + })); + makeCallback({ domain: d }, function() { + throw new Error('throw from domain 3'); + }); + throw new Error('UNREACHABLE'); + })); + + setImmediate(common.mustCall(function() { + const d = domain.create(); + d.on('error', common.mustCall(function(e) { + assert.equal(e.message, 'throw from domain 2'); + })); + makeCallback({ domain: d }, function() { + throw new Error('throw from domain 2'); + }); + throw new Error('UNREACHABLE'); + })); + + setTimeout(common.mustCall(function() { + const d = domain.create(); + d.on('error', common.mustCall(function(e) { + assert.equal(e.message, 'throw from domain 1'); + })); + makeCallback({ domain: d }, function() { + throw new Error('throw from domain 1'); + }); + throw new Error('UNREACHABLE'); + })); +} From 68f391bf3b96af8f390c7cf9d3984379a8830f4d Mon Sep 17 00:00:00 2001 From: Brian White Date: Mon, 15 Feb 2016 04:45:20 -0500 Subject: [PATCH 009/261] src: remove unnecessary check The value's type is unsigned so it will always be >= 0. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5233 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/env-inl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/env-inl.h b/src/env-inl.h index 9084cb5159e58a..6f19ff50cb536f 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -95,7 +95,6 @@ inline Environment::AsyncCallbackScope::AsyncCallbackScope(Environment* env) inline Environment::AsyncCallbackScope::~AsyncCallbackScope() { env_->makecallback_cntr_--; - CHECK_GE(env_->makecallback_cntr_, 0); } inline bool Environment::AsyncCallbackScope::in_makecallback() { From 13d465bcf63925a534522b922b417479bb3fac9e Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Sat, 9 Jan 2016 10:58:55 +0100 Subject: [PATCH 010/261] async_wrap: add uid to all asyncWrap hooks By doing this users can use a Map object for storing information instead of modifying the handle object. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: #4600 Reviewed-By: Trevor Norris Reviewed-By: Sakthipriyan Vairamani --- src/async-wrap.cc | 5 ++- test/parallel/test-async-wrap-uid.js | 57 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-async-wrap-uid.js diff --git a/src/async-wrap.cc b/src/async-wrap.cc index a7a9822238329a..11a696cc2329a3 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -179,6 +179,7 @@ Local AsyncWrap::MakeCallback(const Local cb, Local pre_fn = env()->async_hooks_pre_function(); Local post_fn = env()->async_hooks_post_function(); + Local uid = Integer::New(env()->isolate(), get_uid()); Local context = object(); Local process = env()->process_object(); Local domain; @@ -207,14 +208,14 @@ Local AsyncWrap::MakeCallback(const Local cb, } if (ran_init_callback() && !pre_fn.IsEmpty()) { - if (pre_fn->Call(context, 0, nullptr).IsEmpty()) + if (pre_fn->Call(context, 1, &uid).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "pre hook threw"); } Local ret = cb->Call(context, argc, argv); if (ran_init_callback() && !post_fn.IsEmpty()) { - if (post_fn->Call(context, 0, nullptr).IsEmpty()) + if (post_fn->Call(context, 1, &uid).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); } diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js new file mode 100644 index 00000000000000..ad2dd5027cfa1d --- /dev/null +++ b/test/parallel/test-async-wrap-uid.js @@ -0,0 +1,57 @@ +'use strict'; + +require('../common'); +const fs = require('fs'); +const assert = require('assert'); +const async_wrap = process.binding('async_wrap'); + +const storage = new Map(); +async_wrap.setupHooks(init, pre, post, destroy); +async_wrap.enable(); + +function init(provider, uid) { + storage.set(uid, { + init: true, + pre: false, + post: false, + destroy: false + }); +} + +function pre(uid) { + storage.get(uid).pre = true; +} + +function post(uid) { + storage.get(uid).post = true; +} + +function destroy(uid) { + storage.get(uid).destroy = true; +} + +fs.access(__filename, function(err) { + assert.ifError(err); +}); + +fs.access(__filename, function(err) { + assert.ifError(err); +}); + +async_wrap.disable(); + +process.once('exit', function() { + assert.strictEqual(storage.size, 2); + + for (const item of storage) { + const uid = item[0]; + const value = item[1]; + assert.strictEqual(typeof uid, 'number'); + assert.deepStrictEqual(value, { + init: true, + pre: true, + post: true, + destroy: true + }); + } +}); From e10eebffa51c4d47edc455f9eb2fa40b91bdff56 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Sat, 9 Jan 2016 12:27:53 +0100 Subject: [PATCH 011/261] async_wrap: make uid the first argument in init All other hooks have uid as the first argument, this makes it concistent for all hooks. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: #4600 Reviewed-By: Trevor Norris Reviewed-By: Sakthipriyan Vairamani --- src/async-wrap-inl.h | 2 +- test/parallel/test-async-wrap-check-providers.js | 4 ++-- test/parallel/test-async-wrap-disabled-propagate-parent.js | 2 +- test/parallel/test-async-wrap-propagate-parent.js | 2 +- test/parallel/test-async-wrap-uid.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index f2d2c3ecf1c7b4..d1197edc05f20c 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -40,8 +40,8 @@ inline AsyncWrap::AsyncWrap(Environment* env, v8::HandleScope scope(env->isolate()); v8::Local argv[] = { - v8::Int32::New(env->isolate(), provider), v8::Integer::New(env->isolate(), get_uid()), + v8::Int32::New(env->isolate(), provider), Null(env->isolate()) }; diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 907b9fa3159926..c08c7a43d445e0 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -29,8 +29,8 @@ if (common.isAix) { } } -function init(id) { - keyList = keyList.filter((e) => e != pkeys[id]); +function init(id, provider) { + keyList = keyList.filter((e) => e != pkeys[provider]); } function noop() { } diff --git a/test/parallel/test-async-wrap-disabled-propagate-parent.js b/test/parallel/test-async-wrap-disabled-propagate-parent.js index 55d2e59efb9ee7..f7badaffdffcb7 100644 --- a/test/parallel/test-async-wrap-disabled-propagate-parent.js +++ b/test/parallel/test-async-wrap-disabled-propagate-parent.js @@ -9,7 +9,7 @@ const providers = Object.keys(async_wrap.Providers); let cntr = 0; let client; -function init(type, id, parent) { +function init(id, type, parent) { if (parent) { cntr++; // Cannot assert in init callback or will abort. diff --git a/test/parallel/test-async-wrap-propagate-parent.js b/test/parallel/test-async-wrap-propagate-parent.js index 6001539c624678..31aa814100069b 100644 --- a/test/parallel/test-async-wrap-propagate-parent.js +++ b/test/parallel/test-async-wrap-propagate-parent.js @@ -8,7 +8,7 @@ const async_wrap = process.binding('async_wrap'); let cntr = 0; let client; -function init(type, id, parent) { +function init(id, type, parent) { if (parent) { cntr++; // Cannot assert in init callback or will abort. diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js index ad2dd5027cfa1d..4e664f1bd46ebb 100644 --- a/test/parallel/test-async-wrap-uid.js +++ b/test/parallel/test-async-wrap-uid.js @@ -9,7 +9,7 @@ const storage = new Map(); async_wrap.setupHooks(init, pre, post, destroy); async_wrap.enable(); -function init(provider, uid) { +function init(uid) { storage.set(uid, { init: true, pre: false, From 75ecf8eb07dbb39e49e7c55bdeb0d953a82514fd Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 20 Jan 2016 18:20:43 +0100 Subject: [PATCH 012/261] async_wrap: add parent uid to init hook When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: #4600 Reviewed-By: Trevor Norris Reviewed-By: Sakthipriyan Vairamani --- src/async-wrap-inl.h | 7 +++++-- .../test-async-wrap-disabled-propagate-parent.js | 13 ++++++++++--- test/parallel/test-async-wrap-propagate-parent.js | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index d1197edc05f20c..eeea5973cac57b 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -42,11 +42,14 @@ inline AsyncWrap::AsyncWrap(Environment* env, v8::Local argv[] = { v8::Integer::New(env->isolate(), get_uid()), v8::Int32::New(env->isolate(), provider), + Null(env->isolate()), Null(env->isolate()) }; - if (parent != nullptr) - argv[2] = parent->object(); + if (parent != nullptr) { + argv[2] = v8::Integer::New(env->isolate(), parent->get_uid()); + argv[3] = parent->object(); + } v8::MaybeLocal ret = init_fn->Call(env->context(), object, arraysize(argv), argv); diff --git a/test/parallel/test-async-wrap-disabled-propagate-parent.js b/test/parallel/test-async-wrap-disabled-propagate-parent.js index f7badaffdffcb7..152af4bcde80fc 100644 --- a/test/parallel/test-async-wrap-disabled-propagate-parent.js +++ b/test/parallel/test-async-wrap-disabled-propagate-parent.js @@ -6,16 +6,23 @@ const net = require('net'); const async_wrap = process.binding('async_wrap'); const providers = Object.keys(async_wrap.Providers); +const uidSymbol = Symbol('uid'); + let cntr = 0; let client; -function init(id, type, parent) { - if (parent) { +function init(uid, type, parentUid, parentHandle) { + this[uidSymbol] = uid; + + if (parentHandle) { cntr++; // Cannot assert in init callback or will abort. process.nextTick(() => { assert.equal(providers[type], 'TCPWRAP'); - assert.equal(parent, server._handle, 'server doesn\'t match parent'); + assert.equal(parentUid, server._handle[uidSymbol], + 'server uid doesn\'t match parent uid'); + assert.equal(parentHandle, server._handle, + 'server handle doesn\'t match parent handle'); assert.equal(this, client._handle, 'client doesn\'t match context'); }); } diff --git a/test/parallel/test-async-wrap-propagate-parent.js b/test/parallel/test-async-wrap-propagate-parent.js index 31aa814100069b..e6cb5fa77bdaf7 100644 --- a/test/parallel/test-async-wrap-propagate-parent.js +++ b/test/parallel/test-async-wrap-propagate-parent.js @@ -4,16 +4,25 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); const async_wrap = process.binding('async_wrap'); +const providers = Object.keys(async_wrap.Providers); + +const uidSymbol = Symbol('uid'); let cntr = 0; let client; -function init(id, type, parent) { - if (parent) { +function init(uid, type, parentUid, parentHandle) { + this[uidSymbol] = uid; + + if (parentHandle) { cntr++; // Cannot assert in init callback or will abort. process.nextTick(() => { - assert.equal(parent, server._handle, 'server doesn\'t match parent'); + assert.equal(providers[type], 'TCPWRAP'); + assert.equal(parentUid, server._handle[uidSymbol], + 'server uid doesn\'t match parent uid'); + assert.equal(parentHandle, server._handle, + 'server handle doesn\'t match parent handle'); assert.equal(this, client._handle, 'client doesn\'t match context'); }); } From 6f312b3a9191709511054a8b8b7e663990d5413e Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Fri, 19 Feb 2016 13:13:04 -0700 Subject: [PATCH 013/261] http_parser: use `MakeCallback` Make `HTTPParser` an instance of `AsyncWrap` and make it use `MakeCallback`. This means that async wrap hooks will be called on consumed TCP sockets as well as on non-consumed ones. Additional uses of `AsyncCallbackScope` are necessary to prevent improper state from progressing that triggers failure in the test-http-pipeline-flood.js test. Optimally this wouldn't be necessary, but for the time being it's the most sure way to allow operations to proceed as they have. Ref: https://github.com/nodejs/node/pull/7048 Fix: https://github.com/nodejs/node/issues/4416 PR-URL: https://github.com/nodejs/node/pull/5419 Reviewed-By: Fedor Indutny --- src/async-wrap.h | 1 + src/node_http_parser.cc | 27 ++++++++++++------- .../test-async-wrap-check-providers.js | 3 +++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/async-wrap.h b/src/async-wrap.h index 5db29600bcd180..cb0c9e211a8923 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -17,6 +17,7 @@ namespace node { V(FSREQWRAP) \ V(GETADDRINFOREQWRAP) \ V(GETNAMEINFOREQWRAP) \ + V(HTTPPARSER) \ V(JSSTREAM) \ V(PIPEWRAP) \ V(PIPECONNECTWRAP) \ diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index c6254d57c840ed..87126bfb33a497 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -3,8 +3,8 @@ #include "node_http_parser.h" #include "node_revert.h" -#include "base-object.h" -#include "base-object-inl.h" +#include "async-wrap.h" +#include "async-wrap-inl.h" #include "env.h" #include "env-inl.h" #include "stream_base.h" @@ -148,10 +148,10 @@ struct StringPtr { }; -class Parser : public BaseObject { +class Parser : public AsyncWrap { public: Parser(Environment* env, Local wrap, enum http_parser_type type) - : BaseObject(env, wrap), + : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER), current_buffer_len_(0), current_buffer_data_(nullptr) { Wrap(object(), this); @@ -165,6 +165,11 @@ class Parser : public BaseObject { } + size_t self_size() const override { + return sizeof(*this); + } + + HTTP_CB(on_message_begin) { num_fields_ = num_values_ = 0; url_.Reset(); @@ -286,8 +291,10 @@ class Parser : public BaseObject { argv[A_UPGRADE] = Boolean::New(env()->isolate(), parser_.upgrade); + Environment::AsyncCallbackScope callback_scope(env()); + Local head_response = - cb.As()->Call(obj, arraysize(argv), argv); + MakeCallback(cb.As(), arraysize(argv), argv); if (head_response.IsEmpty()) { got_exception_ = true; @@ -322,7 +329,7 @@ class Parser : public BaseObject { Integer::NewFromUnsigned(env()->isolate(), length) }; - Local r = cb.As()->Call(obj, arraysize(argv), argv); + Local r = MakeCallback(cb.As(), arraysize(argv), argv); if (r.IsEmpty()) { got_exception_ = true; @@ -345,7 +352,9 @@ class Parser : public BaseObject { if (!cb->IsFunction()) return 0; - Local r = cb.As()->Call(obj, 0, nullptr); + Environment::AsyncCallbackScope callback_scope(env()); + + Local r = MakeCallback(cb.As(), 0, nullptr); if (r.IsEmpty()) { got_exception_ = true; @@ -585,7 +594,7 @@ class Parser : public BaseObject { parser->current_buffer_len_ = nread; parser->current_buffer_data_ = buf->base; - cb.As()->Call(obj, 1, &ret); + parser->MakeCallback(cb.As(), 1, &ret); parser->current_buffer_len_ = 0; parser->current_buffer_data_ = nullptr; @@ -659,7 +668,7 @@ class Parser : public BaseObject { url_.ToString(env()) }; - Local r = cb.As()->Call(obj, arraysize(argv), argv); + Local r = MakeCallback(cb.As(), arraysize(argv), argv); if (r.IsEmpty()) got_exception_ = true; diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index c08c7a43d445e0..3a2c80d9cbe173 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -11,6 +11,7 @@ const tls = require('tls'); const zlib = require('zlib'); const ChildProcess = require('child_process').ChildProcess; const StreamWrap = require('_stream_wrap').StreamWrap; +const HTTPParser = process.binding('http_parser').HTTPParser; const async_wrap = process.binding('async_wrap'); const pkeys = Object.keys(async_wrap.Providers); @@ -106,6 +107,8 @@ zlib.createGzip(); new ChildProcess(); +new HTTPParser(HTTPParser.REQUEST); + process.on('exit', function() { if (keyList.length !== 0) { process._rawDebug('Not all keys have been used:'); From 63356df39cb0e89b27a68ed2ad531239b36d5390 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Fri, 4 Mar 2016 15:14:27 -0700 Subject: [PATCH 014/261] src,http: fix uncaughtException miss in http In AsyncWrap::MakeCallback always return empty handle if there is an error. In the future this should change to return a v8::MaybeLocal, but that major change will have to wait for v6.x, and these changes are meant to be backported to v4.x. The HTTParser call to AsyncWrap::MakeCallback failed because it expected a thrown call to return an empty handle. In node::MakeCallback return an empty handle if the call is in_makecallback(), otherwise return v8::Undefined() as usual to preserve backwards compatibility. Ref: https://github.com/nodejs/node/pull/7048 Fixes: https://github.com/nodejs/node/issues/5555 PR-URL: https://github.com/nodejs/node/pull/5591 Reviewed-By: Julien Gilli --- src/async-wrap.cc | 6 ++--- src/node.cc | 6 ++++- .../test-http-catch-uncaughtexception.js | 23 +++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-http-catch-uncaughtexception.js diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 11a696cc2329a3..e2054031014680 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -193,7 +193,7 @@ Local AsyncWrap::MakeCallback(const Local cb, if (has_domain) { domain = domain_v.As(); if (domain->Get(env()->disposed_string())->IsTrue()) - return Undefined(env()->isolate()); + return Local(); } } @@ -220,7 +220,7 @@ Local AsyncWrap::MakeCallback(const Local cb, } if (ret.IsEmpty()) { - return Undefined(env()->isolate()); + return ret; } if (has_domain) { @@ -249,7 +249,7 @@ Local AsyncWrap::MakeCallback(const Local cb, } if (env()->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) { - return Undefined(env()->isolate()); + return Local(); } return ret; diff --git a/src/node.cc b/src/node.cc index 5b4b2f8c8affa0..056b3711f0c8da 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1177,7 +1177,11 @@ Local MakeCallback(Environment* env, } if (ret.IsEmpty()) { - return Undefined(env->isolate()); + if (callback_scope.in_makecallback()) + return ret; + // NOTE: Undefined() is returned here for backwards compatibility. + else + return Undefined(env->isolate()); } if (has_domain) { diff --git a/test/parallel/test-http-catch-uncaughtexception.js b/test/parallel/test-http-catch-uncaughtexception.js new file mode 100644 index 00000000000000..c4054aafbfb699 --- /dev/null +++ b/test/parallel/test-http-catch-uncaughtexception.js @@ -0,0 +1,23 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +const uncaughtCallback = common.mustCall(function(er) { + assert.equal(er.message, 'get did fail'); +}); + +process.on('uncaughtException', uncaughtCallback); + +const server = http.createServer(function(req, res) { + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('bye'); +}).listen(common.PORT, function() { + http.get({ port: common.PORT }, function(res) { + res.resume(); + throw new Error('get did fail'); + }).on('close', function() { + server.close(); + }); +}); From ee7040568d07ef7d6bc8707b30f44fe69b867c31 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Fri, 11 Mar 2016 12:55:59 -0700 Subject: [PATCH 015/261] src,http_parser: remove KickNextTick call Now that HTTPParser uses MakeCallback it is unnecessary to manually process the nextTickQueue. The KickNextTick function is now no longer needed so code has moved back to node::MakeCallback to simplify implementation. Include minor cleanup moving Environment::tick_info() call below the early return to save an operation. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/async-wrap.cc | 7 ++++--- src/env.cc | 23 ----------------------- src/env.h | 2 -- src/node.cc | 18 +++++++++++++++++- src/node_http_parser.cc | 4 ---- 5 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index e2054031014680..dde07aa0756a3e 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -181,7 +181,6 @@ Local AsyncWrap::MakeCallback(const Local cb, Local post_fn = env()->async_hooks_post_function(); Local uid = Integer::New(env()->isolate(), get_uid()); Local context = object(); - Local process = env()->process_object(); Local domain; bool has_domain = false; @@ -233,16 +232,18 @@ Local AsyncWrap::MakeCallback(const Local cb, } } - Environment::TickInfo* tick_info = env()->tick_info(); - if (callback_scope.in_makecallback()) { return ret; } + Environment::TickInfo* tick_info = env()->tick_info(); + if (tick_info->length() == 0) { env()->isolate()->RunMicrotasks(); } + Local process = env()->process_object(); + if (tick_info->length() == 0) { tick_info->set_index(0); return ret; diff --git a/src/env.cc b/src/env.cc index 144a37f2e3cb67..2509a8fd44b6a2 100644 --- a/src/env.cc +++ b/src/env.cc @@ -57,27 +57,4 @@ void Environment::PrintSyncTrace() const { fflush(stderr); } - -bool Environment::KickNextTick(Environment::AsyncCallbackScope* scope) { - TickInfo* info = tick_info(); - - if (scope->in_makecallback()) { - return true; - } - - if (info->length() == 0) { - isolate()->RunMicrotasks(); - } - - if (info->length() == 0) { - info->set_index(0); - return true; - } - - Local ret = - tick_callback_function()->Call(process_object(), 0, nullptr); - - return !ret.IsEmpty(); -} - } // namespace node diff --git a/src/env.h b/src/env.h index 44318da1fa3d0f..7b6ffc8b87c8ee 100644 --- a/src/env.h +++ b/src/env.h @@ -453,8 +453,6 @@ class Environment { inline int64_t get_async_wrap_uid(); - bool KickNextTick(AsyncCallbackScope* scope); - inline uint32_t* heap_statistics_buffer() const; inline void set_heap_statistics_buffer(uint32_t* pointer); diff --git a/src/node.cc b/src/node.cc index 056b3711f0c8da..6b095a6f5816b6 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1194,7 +1194,23 @@ Local MakeCallback(Environment* env, } } - if (!env->KickNextTick(&callback_scope)) { + if (callback_scope.in_makecallback()) { + return ret; + } + + Environment::TickInfo* tick_info = env->tick_info(); + + if (tick_info->length() == 0) { + env->isolate()->RunMicrotasks(); + } + + Local process = env->process_object(); + + if (tick_info->length() == 0) { + tick_info->set_index(0); + } + + if (env->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) { return Undefined(env->isolate()); } diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 87126bfb33a497..6b15aa8c72d531 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -588,8 +588,6 @@ class Parser : public AsyncWrap { if (!cb->IsFunction()) return; - Environment::AsyncCallbackScope callback_scope(parser->env()); - // Hooks for GetCurrentBuffer parser->current_buffer_len_ = nread; parser->current_buffer_data_ = buf->base; @@ -598,8 +596,6 @@ class Parser : public AsyncWrap { parser->current_buffer_len_ = 0; parser->current_buffer_data_ = nullptr; - - parser->env()->KickNextTick(&callback_scope); } From c3d87eee497b4f4090c0cfcdcc1766bd8e321ee1 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 23 Mar 2016 17:02:04 -0600 Subject: [PATCH 016/261] src: reword command and add ternary Make comment clear that Undefined() is returned for legacy compatibility. This will change in the future as a semver-major change, but to be able to port this to previous releases it needs to stay as is. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/node.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/node.cc b/src/node.cc index 6b095a6f5816b6..074589542f59ba 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1177,11 +1177,10 @@ Local MakeCallback(Environment* env, } if (ret.IsEmpty()) { - if (callback_scope.in_makecallback()) - return ret; - // NOTE: Undefined() is returned here for backwards compatibility. - else - return Undefined(env->isolate()); + // NOTE: For backwards compatibility with public API we return Undefined() + // if the top level call threw. + return callback_scope.in_makecallback() ? + ret : Undefined(env->isolate()).As(); } if (has_domain) { From 0642a146b36265c6cea042c90951207fe4b8b9ee Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 22 Feb 2016 16:34:35 -0700 Subject: [PATCH 017/261] async_wrap: setupHooks now accepts object The number of callbacks accepted to setupHooks was getting unwieldy. Instead change the implementation to accept an object with all callbacks Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/async-wrap.cc | 35 ++++++++++++++----- .../test-async-wrap-check-providers.js | 2 +- ...st-async-wrap-disabled-propagate-parent.js | 2 +- .../test-async-wrap-propagate-parent.js | 2 +- .../parallel/test-async-wrap-throw-no-init.js | 4 +-- test/parallel/test-async-wrap-uid.js | 2 +- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index dde07aa0756a3e..570ed2f165b2ba 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -121,18 +121,35 @@ static void SetupHooks(const FunctionCallbackInfo& args) { if (env->async_hooks()->callbacks_enabled()) return env->ThrowError("hooks should not be set while also enabled"); - - if (!args[0]->IsFunction()) + if (!args[0]->IsObject()) + return env->ThrowTypeError("first argument must be an object"); + + Local fn_obj = args[0].As(); + + Local init_v = fn_obj->Get( + env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "init")).ToLocalChecked(); + Local pre_v = fn_obj->Get( + env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "pre")).ToLocalChecked(); + Local post_v = fn_obj->Get( + env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "post")).ToLocalChecked(); + Local destroy_v = fn_obj->Get( + env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "destroy")).ToLocalChecked(); + + if (!init_v->IsFunction()) return env->ThrowTypeError("init callback must be a function"); - env->set_async_hooks_init_function(args[0].As()); + env->set_async_hooks_init_function(init_v.As()); - if (args[1]->IsFunction()) - env->set_async_hooks_pre_function(args[1].As()); - if (args[2]->IsFunction()) - env->set_async_hooks_post_function(args[2].As()); - if (args[3]->IsFunction()) - env->set_async_hooks_destroy_function(args[3].As()); + if (pre_v->IsFunction()) + env->set_async_hooks_pre_function(pre_v.As()); + if (post_v->IsFunction()) + env->set_async_hooks_post_function(post_v.As()); + if (destroy_v->IsFunction()) + env->set_async_hooks_destroy_function(destroy_v.As()); } diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 3a2c80d9cbe173..5ae8654d337303 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -36,7 +36,7 @@ function init(id, provider) { function noop() { } -async_wrap.setupHooks(init, noop, noop); +async_wrap.setupHooks({ init }); async_wrap.enable(); diff --git a/test/parallel/test-async-wrap-disabled-propagate-parent.js b/test/parallel/test-async-wrap-disabled-propagate-parent.js index 152af4bcde80fc..f0daaeb06d0031 100644 --- a/test/parallel/test-async-wrap-disabled-propagate-parent.js +++ b/test/parallel/test-async-wrap-disabled-propagate-parent.js @@ -30,7 +30,7 @@ function init(uid, type, parentUid, parentHandle) { function noop() { } -async_wrap.setupHooks(init, noop, noop); +async_wrap.setupHooks({ init }); async_wrap.enable(); const server = net.createServer(function(c) { diff --git a/test/parallel/test-async-wrap-propagate-parent.js b/test/parallel/test-async-wrap-propagate-parent.js index e6cb5fa77bdaf7..34a00c22eeeafd 100644 --- a/test/parallel/test-async-wrap-propagate-parent.js +++ b/test/parallel/test-async-wrap-propagate-parent.js @@ -30,7 +30,7 @@ function init(uid, type, parentUid, parentHandle) { function noop() { } -async_wrap.setupHooks(init, noop, noop); +async_wrap.setupHooks({ init }); async_wrap.enable(); const server = net.createServer(function(c) { diff --git a/test/parallel/test-async-wrap-throw-no-init.js b/test/parallel/test-async-wrap-throw-no-init.js index 768e38e8eff389..ccf77f66dc7232 100644 --- a/test/parallel/test-async-wrap-throw-no-init.js +++ b/test/parallel/test-async-wrap-throw-no-init.js @@ -7,14 +7,14 @@ const async_wrap = process.binding('async_wrap'); assert.throws(function() { async_wrap.setupHooks(null); -}, /init callback must be a function/); +}, /first argument must be an object/); assert.throws(function() { async_wrap.enable(); }, /init callback is not assigned to a function/); // Should not throw -async_wrap.setupHooks(() => {}); +async_wrap.setupHooks({ init: () => {} }); async_wrap.enable(); assert.throws(function() { diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js index 4e664f1bd46ebb..5bf3a8856e0e3f 100644 --- a/test/parallel/test-async-wrap-uid.js +++ b/test/parallel/test-async-wrap-uid.js @@ -6,7 +6,7 @@ const assert = require('assert'); const async_wrap = process.binding('async_wrap'); const storage = new Map(); -async_wrap.setupHooks(init, pre, post, destroy); +async_wrap.setupHooks({ init, pre, post, destroy }); async_wrap.enable(); function init(uid) { From c06e2b07b6ed170ac771850afc5379618dded30d Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 22 Feb 2016 22:50:56 -0700 Subject: [PATCH 018/261] async_wrap: notify post if intercepted exception The second argument of the post callback is a boolean indicating whether the callback threw and was intercepted by uncaughtException or a domain. Currently node::MakeCallback has no way of retrieving a uid for the object. This is coming in a future patch. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/async-wrap.cc | 5 ++- src/node.cc | 7 +++- .../test-async-wrap-post-did-throw.js | 34 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-async-wrap-post-did-throw.js diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 570ed2f165b2ba..7338f051cd4aee 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -9,6 +9,7 @@ #include "v8-profiler.h" using v8::Array; +using v8::Boolean; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; @@ -231,7 +232,9 @@ Local AsyncWrap::MakeCallback(const Local cb, Local ret = cb->Call(context, argc, argv); if (ran_init_callback() && !post_fn.IsEmpty()) { - if (post_fn->Call(context, 1, &uid).IsEmpty()) + Local did_throw = Boolean::New(env()->isolate(), ret.IsEmpty()); + Local vals[] = { uid, did_throw }; + if (post_fn->Call(context, arraysize(vals), vals).IsEmpty()) FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); } diff --git a/src/node.cc b/src/node.cc index 074589542f59ba..0281f31d2bf47b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1172,7 +1172,12 @@ Local MakeCallback(Environment* env, Local ret = callback->Call(recv, argc, argv); if (ran_init_callback && !post_fn.IsEmpty()) { - if (post_fn->Call(object, 0, nullptr).IsEmpty()) + Local did_throw = Boolean::New(env->isolate(), ret.IsEmpty()); + // Currently there's no way to retrieve an uid from node::MakeCallback(). + // This needs to be fixed. + Local vals[] = + { Undefined(env->isolate()).As(), did_throw }; + if (post_fn->Call(object, arraysize(vals), vals).IsEmpty()) FatalError("node::MakeCallback", "post hook threw"); } diff --git a/test/parallel/test-async-wrap-post-did-throw.js b/test/parallel/test-async-wrap-post-did-throw.js new file mode 100644 index 00000000000000..9781983f58987e --- /dev/null +++ b/test/parallel/test-async-wrap-post-did-throw.js @@ -0,0 +1,34 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const async_wrap = process.binding('async_wrap'); +var asyncThrows = 0; +var uncaughtExceptionCount = 0; + +process.on('uncaughtException', (e) => { + assert.equal(e.message, 'oh noes!', 'error messages do not match'); +}); + +process.on('exit', () => { + process.removeAllListeners('uncaughtException'); + assert.equal(uncaughtExceptionCount, 1); + assert.equal(uncaughtExceptionCount, asyncThrows); +}); + +function init() { } +function post(id, threw) { + if (threw) + uncaughtExceptionCount++; +} + +async_wrap.setupHooks({ init, post }); +async_wrap.enable(); + +// Timers still aren't supported, so use crypto API. +// It's also important that the callback not happen in a nextTick, like many +// error events in core. +require('crypto').randomBytes(0, () => { + asyncThrows++; + throw new Error('oh noes!'); +}); From 747f1071886e28cdbe832faf71e457b71d08750e Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 14 Mar 2016 12:35:22 -0600 Subject: [PATCH 019/261] async_wrap: don't abort on callback exception Rather than abort if the init/pre/post/final/destroy callbacks throw, force the exception to propagate and not be made catchable. This way the application is still not allowed to proceed but also allowed the location of the failure to print before exiting. Though the stack itself may not be of much use since all callbacks except init are called from the bottom of the call stack. /tmp/async-test.js:14 throw new Error('pre'); ^ Error: pre at InternalFieldObject.pre (/tmp/async-test.js:14:9) Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis Reviewed-By: Andreas Madsen --- src/async-wrap-inl.h | 15 ++-- src/async-wrap.cc | 20 ++++-- src/node.cc | 39 +++++++++-- src/node_internals.h | 5 ++ .../test-async-wrap-throw-from-callback.js | 68 +++++++++++++++++++ 5 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 test/parallel/test-async-wrap-throw-from-callback.js diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index eeea5973cac57b..cf7024e7e31461 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -51,11 +51,15 @@ inline AsyncWrap::AsyncWrap(Environment* env, argv[3] = parent->object(); } + v8::TryCatch try_catch(env->isolate()); + v8::MaybeLocal ret = init_fn->Call(env->context(), object, arraysize(argv), argv); - if (ret.IsEmpty()) - FatalError("node::AsyncWrap::AsyncWrap", "init hook threw"); + if (ret.IsEmpty()) { + ClearFatalExceptionHandlers(env); + FatalException(env->isolate(), try_catch); + } bits_ |= 1; // ran_init_callback() is true now. } @@ -69,10 +73,13 @@ inline AsyncWrap::~AsyncWrap() { if (!fn.IsEmpty()) { v8::HandleScope scope(env()->isolate()); v8::Local uid = v8::Integer::New(env()->isolate(), get_uid()); + v8::TryCatch try_catch(env()->isolate()); v8::MaybeLocal ret = fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid); - if (ret.IsEmpty()) - FatalError("node::AsyncWrap::~AsyncWrap", "destroy hook threw"); + if (ret.IsEmpty()) { + ClearFatalExceptionHandlers(env()); + FatalException(env()->isolate(), try_catch); + } } } diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 7338f051cd4aee..8129500a922d97 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -18,6 +18,7 @@ using v8::HeapProfiler; using v8::Integer; using v8::Isolate; using v8::Local; +using v8::MaybeLocal; using v8::Object; using v8::RetainedObjectInfo; using v8::TryCatch; @@ -225,8 +226,13 @@ Local AsyncWrap::MakeCallback(const Local cb, } if (ran_init_callback() && !pre_fn.IsEmpty()) { - if (pre_fn->Call(context, 1, &uid).IsEmpty()) - FatalError("node::AsyncWrap::MakeCallback", "pre hook threw"); + TryCatch try_catch(env()->isolate()); + MaybeLocal ar = pre_fn->Call(env()->context(), context, 1, &uid); + if (ar.IsEmpty()) { + ClearFatalExceptionHandlers(env()); + FatalException(env()->isolate(), try_catch); + return Local(); + } } Local ret = cb->Call(context, argc, argv); @@ -234,8 +240,14 @@ Local AsyncWrap::MakeCallback(const Local cb, if (ran_init_callback() && !post_fn.IsEmpty()) { Local did_throw = Boolean::New(env()->isolate(), ret.IsEmpty()); Local vals[] = { uid, did_throw }; - if (post_fn->Call(context, arraysize(vals), vals).IsEmpty()) - FatalError("node::AsyncWrap::MakeCallback", "post hook threw"); + TryCatch try_catch(env()->isolate()); + MaybeLocal ar = + post_fn->Call(env()->context(), context, arraysize(vals), vals); + if (ar.IsEmpty()) { + ClearFatalExceptionHandlers(env()); + FatalException(env()->isolate(), try_catch); + return Local(); + } } if (ret.IsEmpty()) { diff --git a/src/node.cc b/src/node.cc index 0281f31d2bf47b..2f08a1da378eaf 100644 --- a/src/node.cc +++ b/src/node.cc @@ -115,6 +115,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::Locker; +using v8::MaybeLocal; using v8::Message; using v8::Number; using v8::Object; @@ -1165,8 +1166,13 @@ Local MakeCallback(Environment* env, } if (ran_init_callback && !pre_fn.IsEmpty()) { - if (pre_fn->Call(object, 0, nullptr).IsEmpty()) - FatalError("node::MakeCallback", "pre hook threw"); + TryCatch try_catch(env->isolate()); + MaybeLocal ar = pre_fn->Call(env->context(), object, 0, nullptr); + if (ar.IsEmpty()) { + ClearFatalExceptionHandlers(env); + FatalException(env->isolate(), try_catch); + return Local(); + } } Local ret = callback->Call(recv, argc, argv); @@ -1177,8 +1183,14 @@ Local MakeCallback(Environment* env, // This needs to be fixed. Local vals[] = { Undefined(env->isolate()).As(), did_throw }; - if (post_fn->Call(object, arraysize(vals), vals).IsEmpty()) - FatalError("node::MakeCallback", "post hook threw"); + TryCatch try_catch(env->isolate()); + MaybeLocal ar = + post_fn->Call(env->context(), object, arraysize(vals), vals); + if (ar.IsEmpty()) { + ClearFatalExceptionHandlers(env); + FatalException(env->isolate(), try_catch); + return Local(); + } } if (ret.IsEmpty()) { @@ -2352,6 +2364,25 @@ void OnMessage(Local message, Local error) { } +void ClearFatalExceptionHandlers(Environment* env) { + Local process = env->process_object(); + Local events = + process->Get(env->context(), env->events_string()).ToLocalChecked(); + + if (events->IsObject()) { + events.As()->Set( + env->context(), + OneByteString(env->isolate(), "uncaughtException"), + Undefined(env->isolate())).FromJust(); + } + + process->Set( + env->context(), + env->domain_string(), + Undefined(env->isolate())).FromJust(); +} + + static void Binding(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); diff --git a/src/node_internals.h b/src/node_internals.h index 6e3f7204777835..33ae25d6062938 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -237,6 +237,11 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { Environment* env_; }; +// Clear any domain and/or uncaughtException handlers to force the error's +// propagation and shutdown the process. Use this to force the process to exit +// by clearing all callbacks that could handle the error. +void ClearFatalExceptionHandlers(Environment* env); + enum NodeInstanceType { MAIN, WORKER }; class NodeInstanceData { diff --git a/test/parallel/test-async-wrap-throw-from-callback.js b/test/parallel/test-async-wrap-throw-from-callback.js new file mode 100644 index 00000000000000..bfbe32c38b021a --- /dev/null +++ b/test/parallel/test-async-wrap-throw-from-callback.js @@ -0,0 +1,68 @@ +'use strict'; + +require('../common'); +const async_wrap = process.binding('async_wrap'); +const assert = require('assert'); +const crypto = require('crypto'); +const domain = require('domain'); +const spawn = require('child_process').spawn; +const callbacks = [ 'init', 'pre', 'post', 'destroy' ]; +const toCall = process.argv[2]; +var msgCalled = 0; +var msgReceived = 0; + +function init() { + if (toCall === 'init') + throw new Error('init'); +} +function pre() { + if (toCall === 'pre') + throw new Error('pre'); +} +function post() { + if (toCall === 'post') + throw new Error('post'); +} +function destroy() { + if (toCall === 'destroy') + throw new Error('destroy'); +} + +if (typeof process.argv[2] === 'string') { + async_wrap.setupHooks({ init, pre, post, destroy }); + async_wrap.enable(); + + process.on('uncaughtException', () => assert.ok(0, 'UNREACHABLE')); + + const d = domain.create(); + d.on('error', () => assert.ok(0, 'UNREACHABLE')); + d.run(() => { + // Using randomBytes because timers are not yet supported. + crypto.randomBytes(0, () => { }); + }); + +} else { + + process.on('exit', (code) => { + assert.equal(msgCalled, callbacks.length); + assert.equal(msgCalled, msgReceived); + }); + + callbacks.forEach((item) => { + msgCalled++; + + const child = spawn(process.execPath, [__filename, item]); + var errstring = ''; + + child.stderr.on('data', (data) => { + errstring += data.toString(); + }); + + child.on('close', (code) => { + if (errstring.includes('Error: ' + item)) + msgReceived++; + + assert.equal(code, 1, `${item} closed with code ${code}`); + }); + }); +} From 271927f29e5119f243decca9d7912fa4e4cd6c76 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 1 Jun 2016 12:33:33 -0600 Subject: [PATCH 020/261] async_wrap: pass uid to JS as double Passing the uid via v8::Integer::New() converts it to a uint32_t. Which will trim the value early. Instead use v8::Number::New() to convert the int64_t to a double so that JS can see the full 2^53 range of uid's. Ref: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/7096 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Andreas Madsen --- src/async-wrap-inl.h | 6 +++--- src/async-wrap.cc | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index cf7024e7e31461..9f520de4429622 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -40,14 +40,14 @@ inline AsyncWrap::AsyncWrap(Environment* env, v8::HandleScope scope(env->isolate()); v8::Local argv[] = { - v8::Integer::New(env->isolate(), get_uid()), + v8::Number::New(env->isolate(), get_uid()), v8::Int32::New(env->isolate(), provider), Null(env->isolate()), Null(env->isolate()) }; if (parent != nullptr) { - argv[2] = v8::Integer::New(env->isolate(), parent->get_uid()); + argv[2] = v8::Number::New(env->isolate(), parent->get_uid()); argv[3] = parent->object(); } @@ -72,7 +72,7 @@ inline AsyncWrap::~AsyncWrap() { v8::Local fn = env()->async_hooks_destroy_function(); if (!fn.IsEmpty()) { v8::HandleScope scope(env()->isolate()); - v8::Local uid = v8::Integer::New(env()->isolate(), get_uid()); + v8::Local uid = v8::Number::New(env()->isolate(), get_uid()); v8::TryCatch try_catch(env()->isolate()); v8::MaybeLocal ret = fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid); diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 8129500a922d97..2b6839c05ee461 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -19,6 +19,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::Number; using v8::Object; using v8::RetainedObjectInfo; using v8::TryCatch; @@ -198,7 +199,7 @@ Local AsyncWrap::MakeCallback(const Local cb, Local pre_fn = env()->async_hooks_pre_function(); Local post_fn = env()->async_hooks_post_function(); - Local uid = Integer::New(env()->isolate(), get_uid()); + Local uid = Number::New(env()->isolate(), get_uid()); Local context = object(); Local domain; bool has_domain = false; From c807287e80fef9edbadb89e8e4c9153dedf9f718 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 9 May 2016 16:35:20 +0200 Subject: [PATCH 021/261] tls,https: respect address family when connecting Respect the `{ family: 6 }` address family property when connecting to a remote peer over TLS. Fixes: https://github.com/nodejs/node/issues/4139 Fixes: https://github.com/nodejs/node/issues/6440 PR-URL: https://github.com/nodejs/node/pull/6654 Reviewed-By: Colin Ihrig --- lib/_http_agent.js | 5 ++++ lib/_tls_wrap.js | 1 + test/parallel/parallel.status | 7 +++++ test/parallel/test-http-agent-getname.js | 6 ++++ .../test-https-connect-address-family.js | 28 +++++++++++++++++++ .../test-tls-connect-address-family.js | 27 ++++++++++++++++++ 6 files changed, 74 insertions(+) create mode 100644 test/parallel/test-https-connect-address-family.js create mode 100644 test/parallel/test-tls-connect-address-family.js diff --git a/lib/_http_agent.js b/lib/_http_agent.js index aac4b955637e9a..cb52c1105466e5 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -102,6 +102,11 @@ Agent.prototype.getName = function(options) { if (options.localAddress) name += options.localAddress; + // Pacify parallel/test-http-agent-getname by only appending + // the ':' when options.family is set. + if (options.family === 4 || options.family === 6) + name += ':' + options.family; + return name; }; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index e340e4a041b6ee..c115555ce7a7ff 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -994,6 +994,7 @@ exports.connect = function(/* [port, host], options, cb */) { connect_opt = { port: options.port, host: options.host, + family: options.family, localAddress: options.localAddress }; } diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index dc71ddb361f70e..2cdc5b7b07cb64 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -12,6 +12,13 @@ test-tick-processor : PASS,FLAKY [$system==linux] test-tick-processor : PASS,FLAKY +# Flaky until https://github.com/nodejs/build/issues/415 is resolved. +# On some of the buildbots, AAAA queries for localhost don't resolve +# to an address and neither do any of the alternatives from the +# localIPv6Hosts list from test/common.js. +test-https-connect-address-family : PASS,FLAKY +test-tls-connect-address-family : PASS,FLAKY + [$system==macos] [$system==solaris] # Also applies to SmartOS diff --git a/test/parallel/test-http-agent-getname.js b/test/parallel/test-http-agent-getname.js index 1b80b5c36e1e64..5f5c479dcf354d 100644 --- a/test/parallel/test-http-agent-getname.js +++ b/test/parallel/test-http-agent-getname.js @@ -30,3 +30,9 @@ assert.equal( }), '0.0.0.0:80:192.168.1.1' ); + +for (const family of [0, null, undefined, 'bogus']) + assert.strictEqual(agent.getName({ family }), 'localhost::'); + +for (const family of [4, 6]) + assert.strictEqual(agent.getName({ family }), 'localhost:::' + family); diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js new file mode 100644 index 00000000000000..b2f3c233cfd720 --- /dev/null +++ b/test/parallel/test-https-connect-address-family.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const https = require('https'); + +if (!common.hasIPv6) { + common.skip('no IPv6 support'); + return; +} + +const ciphers = 'AECDH-NULL-SHA'; +https.createServer({ ciphers }, function(req, res) { + this.close(); + res.end(); +}).listen(common.PORT, '::1', function() { + const options = { + host: 'localhost', + port: common.PORT, + family: 6, + ciphers: ciphers, + rejectUnauthorized: false, + }; + // Will fail with ECONNREFUSED if the address family is not honored. + https.get(options, common.mustCall(function() { + assert.strictEqual('::1', this.socket.remoteAddress); + this.destroy(); + })); +}); diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js new file mode 100644 index 00000000000000..665a71dfe666d9 --- /dev/null +++ b/test/parallel/test-tls-connect-address-family.js @@ -0,0 +1,27 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const tls = require('tls'); + +if (!common.hasIPv6) { + common.skip('no IPv6 support'); + return; +} + +const ciphers = 'AECDH-NULL-SHA'; +tls.createServer({ ciphers }, function() { + this.close(); +}).listen(common.PORT, '::1', function() { + const options = { + host: 'localhost', + port: common.PORT, + family: 6, + ciphers: ciphers, + rejectUnauthorized: false, + }; + // Will fail with ECONNREFUSED if the address family is not honored. + tls.connect(options).once('secureConnect', common.mustCall(function() { + assert.strictEqual('::1', this.remoteAddress); + this.destroy(); + })); +}); From e3f9bc893ff9ad4aca0bb5fea0d3a0465dfd2d08 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 28 May 2016 18:57:25 +0200 Subject: [PATCH 022/261] test: use strictEqual consistently in agent test Update parallel/test-http-agent-getname to use assert.strictEqual() consistently and const-ify variables while we're here. PR-URL: https://github.com/nodejs/node/pull/6654 Reviewed-By: Colin Ihrig --- test/parallel/test-http-agent-getname.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-http-agent-getname.js b/test/parallel/test-http-agent-getname.js index 5f5c479dcf354d..45e1817cf5ee1e 100644 --- a/test/parallel/test-http-agent-getname.js +++ b/test/parallel/test-http-agent-getname.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var agent = new http.Agent(); +const agent = new http.Agent(); // default to localhost -assert.equal( +assert.strictEqual( agent.getName({ port: 80, localAddress: '192.168.1.1' @@ -16,13 +16,13 @@ assert.equal( ); // empty -assert.equal( +assert.strictEqual( agent.getName({}), 'localhost::' ); // pass all arguments -assert.equal( +assert.strictEqual( agent.getName({ host: '0.0.0.0', port: 80, From 74a5e911c0e751b583660459b8bdff56b80c02dc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 21 Oct 2015 13:52:04 +0200 Subject: [PATCH 023/261] debugger: propagate --debug-port= to debuggee Before this commit `node --debug-port=1234 debug t.js` ignored the --debug-port= argument, binding to the default port 5858 instead, making it impossible to debug more than one process on the same machine that way. This commit also reduces the number of places where the default port is hard-coded by one. Fixes: https://github.com/nodejs/node/issues/3345 PR-URL: https://github.com/nodejs/node/pull/3470 Reviewed-By: Colin Ihrig Reviewed-By: Fedor Indutny Reviewed-By: James M Snell --- lib/_debugger.js | 4 +-- test/parallel/test-debug-port-numbers.js | 41 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-debug-port-numbers.js diff --git a/lib/_debugger.js b/lib/_debugger.js index 411db79d087798..a5d3f6e87262c5 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -25,7 +25,7 @@ exports.start = function(argv, stdin, stdout) { stdin = stdin || process.stdin; stdout = stdout || process.stdout; - const args = ['--debug-brk'].concat(argv); + const args = [`--debug-brk=${exports.port}`].concat(argv); const interface_ = new Interface(stdin, stdout, args); stdin.resume(); @@ -40,7 +40,7 @@ exports.start = function(argv, stdin, stdout) { }); }; -exports.port = 5858; +exports.port = process.debugPort; // diff --git a/test/parallel/test-debug-port-numbers.js b/test/parallel/test-debug-port-numbers.js new file mode 100644 index 00000000000000..e21cb72f0a0622 --- /dev/null +++ b/test/parallel/test-debug-port-numbers.js @@ -0,0 +1,41 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const spawn = require('child_process').spawn; + +const children = []; +for (let i = 0; i < 4; i += 1) { + const port = common.PORT + i; + const args = [`--debug-port=${port}`, '--interactive', 'debug', __filename]; + const child = spawn(process.execPath, args, { stdio: 'pipe' }); + child.test = { port: port, stdout: '' }; + child.stdout.setEncoding('utf8'); + child.stdout.on('data', function(s) { child.test.stdout += s; update(); }); + child.stdout.pipe(process.stdout); + child.stderr.pipe(process.stderr); + children.push(child); +} + +function update() { + // Debugger prints relative paths except on Windows. + const filename = path.basename(__filename); + + let ready = 0; + for (const child of children) + ready += RegExp(`break in .*?${filename}:1`).test(child.test.stdout); + + if (ready === children.length) + for (const child of children) + child.kill(); +} + +process.on('exit', function() { + for (const child of children) { + const one = RegExp(`Debugger listening on port ${child.test.port}`); + const two = RegExp(`connecting to 127.0.0.1:${child.test.port}`); + assert(one.test(child.test.stdout)); + assert(two.test(child.test.stdout)); + } +}); From efdeb69c9a4ca8052c77b7be33269027ce5c88fb Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 28 May 2016 11:28:01 +0200 Subject: [PATCH 024/261] test: work around debugger not killing inferior On UNIX platforms, the debugger doesn't reliably kill the inferior when killed by a signal. Work around that by spawning the debugger in its own process group and killing the process group instead of just the debugger process. This is a hack to get the continuous integration back to green, it doesn't address the underlying issue, which is that the debugger shouldn't leave stray processes behind. Fixes: https://github.com/nodejs/node/issues/7034 PR-URL: https://github.com/nodejs/node/pull/7037 Refs: https://github.com/nodejs/node/pull/3470 Reviewed-By: Colin Ihrig --- test/parallel/test-debug-port-numbers.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-debug-port-numbers.js b/test/parallel/test-debug-port-numbers.js index e21cb72f0a0622..c7bf1da5f64849 100644 --- a/test/parallel/test-debug-port-numbers.js +++ b/test/parallel/test-debug-port-numbers.js @@ -5,11 +5,17 @@ const assert = require('assert'); const path = require('path'); const spawn = require('child_process').spawn; +// FIXME(bnoordhuis) On UNIX platforms, the debugger doesn't reliably kill +// the inferior when killed by a signal. Work around that by spawning +// the debugger in its own process group and killing the process group +// instead of just the debugger process. +const detached = !common.isWindows; + const children = []; for (let i = 0; i < 4; i += 1) { const port = common.PORT + i; const args = [`--debug-port=${port}`, '--interactive', 'debug', __filename]; - const child = spawn(process.execPath, args, { stdio: 'pipe' }); + const child = spawn(process.execPath, args, { detached, stdio: 'pipe' }); child.test = { port: port, stdout: '' }; child.stdout.setEncoding('utf8'); child.stdout.on('data', function(s) { child.test.stdout += s; update(); }); @@ -28,7 +34,18 @@ function update() { if (ready === children.length) for (const child of children) - child.kill(); + kill(child); +} + +function kill(child) { + if (!detached) + return child.kill(); + + try { + process.kill(-child.pid); // Kill process group. + } catch (e) { + assert.strictEqual(e.code, 'ESRCH'); // Already gone. + } } process.on('exit', function() { From 13d0e463b0efc66855942fd72be930ffd7861265 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Mon, 28 Mar 2016 17:03:06 -0400 Subject: [PATCH 025/261] build: enable compilation for linuxOne MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes to Node core in order to allow compilation for linuxOne. The ../archs/linux32-s390x/opensslconf.h and ../archs/linux64-s390x/opensslconf.h were automatically generated by running make linux-ppc linux-ppc64 in the deps/openssl/config directory as per our standard practice After these changes we still need a version of v8 which supports linuxOne but that will be coming soon in the 5.1 version of v8. Until then with these changes we'll be able to create a hybrid build which pulls in v8 from the http://github/andrewlow repo. PR-URL: https://github.com/nodejs/node/pull/5941 Reviewed-By: Johan Bergström Reviewed-By: Ben Noordhuis --- Makefile | 8 + common.gypi | 8 + configure | 7 +- deps/openssl/config/Makefile | 3 +- .../config/archs/linux32-s390x/opensslconf.h | 270 ++++++++++++++++++ .../config/archs/linux64-s390x/opensslconf.h | 270 ++++++++++++++++++ deps/openssl/config/opensslconf.h | 8 + tools/test.py | 3 +- tools/utils.py | 2 + 9 files changed, 575 insertions(+), 4 deletions(-) create mode 100644 deps/openssl/config/archs/linux32-s390x/opensslconf.h create mode 100644 deps/openssl/config/archs/linux64-s390x/opensslconf.h diff --git a/Makefile b/Makefile index 4d180501c6d2c3..383542680bc512 100644 --- a/Makefile +++ b/Makefile @@ -313,12 +313,20 @@ else ifeq ($(DESTCPU),ppc) ARCH=ppc else +ifeq ($(DESTCPU),s390) +ARCH=s390 +else +ifeq ($(DESTCPU),s390x) +ARCH=s390x +else ARCH=x86 endif endif endif endif endif +endif +endif # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel ifeq ($(ARCH),ia32) diff --git a/common.gypi b/common.gypi index 4a8e8716b9c8d4..811a7b3da3d502 100644 --- a/common.gypi +++ b/common.gypi @@ -264,6 +264,14 @@ 'cflags': [ '-m64', '-mminimal-toc' ], 'ldflags': [ '-m64' ], }], + [ 'target_arch=="s390"', { + 'cflags': [ '-m31' ], + 'ldflags': [ '-m31' ], + }], + [ 'target_arch=="s390x"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], [ 'OS=="solaris"', { 'cflags': [ '-pthreads' ], 'ldflags': [ '-pthreads' ], diff --git a/configure b/configure index 1bb0da21ce67fc..4434d53e47bb10 100755 --- a/configure +++ b/configure @@ -28,7 +28,7 @@ parser = optparse.OptionParser() valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux', 'android', 'aix') valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 'x32', - 'x64', 'x86') + 'x64', 'x86', 's390', 's390x') valid_arm_float_abi = ('soft', 'softfp', 'hard') valid_arm_fpu = ('vfp', 'vfpv3', 'vfpv3-d16', 'neon') valid_mips_arch = ('loongson', 'r1', 'r2', 'r6', 'rx') @@ -601,6 +601,8 @@ def host_arch_cc(): '__PPC64__' : 'ppc64', '__PPC__' : 'ppc', '__x86_64__' : 'x64', + '__s390__' : 's390', + '__s390x__' : 's390x', } rtn = 'ia32' # default @@ -608,7 +610,8 @@ def host_arch_cc(): for i in matchup: if i in k and k[i] != '0': rtn = matchup[i] - break + if rtn != 's390': + break return rtn diff --git a/deps/openssl/config/Makefile b/deps/openssl/config/Makefile index b56e9004c3b732..c8155b16d8dcfb 100644 --- a/deps/openssl/config/Makefile +++ b/deps/openssl/config/Makefile @@ -5,7 +5,8 @@ COPT = no-shared no-symlinks ARCHS = aix-gcc aix64-gcc BSD-x86 BSD-x86_64 VC-WIN32 \ VC-WIN64A darwin64-x86_64-cc darwin-i386-cc linux-aarch64 \ linux-armv4 linux-elf linux-x32 linux-x86_64 linux-ppc \ -linux-ppc64 solaris-x86-gcc solaris64-x86_64-gcc +linux-ppc64 linux32-s390x linux64-s390x solaris-x86-gcc \ +solaris64-x86_64-gcc CFG = opensslconf.h SRC_CFG = ../openssl/crypto/$(CFG) diff --git a/deps/openssl/config/archs/linux32-s390x/opensslconf.h b/deps/openssl/config/archs/linux32-s390x/opensslconf.h new file mode 100644 index 00000000000000..e0d0f8fa613456 --- /dev/null +++ b/deps/openssl/config/archs/linux32-s390x/opensslconf.h @@ -0,0 +1,270 @@ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +#ifdef __cplusplus +extern "C" { +#endif +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_DOING_MAKEDEPEND + + +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# define OPENSSL_NO_EC_NISTP_64_GCC_128 +#endif +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_JPAKE +# define OPENSSL_NO_JPAKE +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_LIBUNBOUND +# define OPENSSL_NO_LIBUNBOUND +#endif +#ifndef OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif +#ifndef OPENSSL_NO_RFC3779 +# define OPENSSL_NO_RFC3779 +#endif +#ifndef OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP +#endif +#ifndef OPENSSL_NO_SSL_TRACE +# define OPENSSL_NO_SSL_TRACE +#endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif +#ifndef OPENSSL_NO_STORE +# define OPENSSL_NO_STORE +#endif +#ifndef OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST +#endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ + +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif +#ifndef OPENSSL_NO_DYNAMIC_ENGINE +# define OPENSSL_NO_DYNAMIC_ENGINE +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128) +# define NO_EC_NISTP_64_GCC_128 +# endif +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE) +# define NO_JPAKE +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND) +# define NO_LIBUNBOUND +# endif +# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2) +# define NO_MD2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) +# define NO_RFC3779 +# endif +# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP) +# define NO_SCTP +# endif +# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) +# define NO_SSL_TRACE +# endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif +# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) +# define NO_STORE +# endif +# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) +# define NO_UNIT_TEST +# endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif +#endif + + + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "/usr/local/ssl/lib/engines" +#define OPENSSLDIR "/usr/local/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned char +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( __sun ) || defined ( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ +#ifdef __cplusplus +} +#endif diff --git a/deps/openssl/config/archs/linux64-s390x/opensslconf.h b/deps/openssl/config/archs/linux64-s390x/opensslconf.h new file mode 100644 index 00000000000000..dbb03486798275 --- /dev/null +++ b/deps/openssl/config/archs/linux64-s390x/opensslconf.h @@ -0,0 +1,270 @@ +/* opensslconf.h */ +/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ + +#ifdef __cplusplus +extern "C" { +#endif +/* OpenSSL was configured with the following options: */ +#ifndef OPENSSL_DOING_MAKEDEPEND + + +#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# define OPENSSL_NO_EC_NISTP_64_GCC_128 +#endif +#ifndef OPENSSL_NO_GMP +# define OPENSSL_NO_GMP +#endif +#ifndef OPENSSL_NO_JPAKE +# define OPENSSL_NO_JPAKE +#endif +#ifndef OPENSSL_NO_KRB5 +# define OPENSSL_NO_KRB5 +#endif +#ifndef OPENSSL_NO_LIBUNBOUND +# define OPENSSL_NO_LIBUNBOUND +#endif +#ifndef OPENSSL_NO_MD2 +# define OPENSSL_NO_MD2 +#endif +#ifndef OPENSSL_NO_RC5 +# define OPENSSL_NO_RC5 +#endif +#ifndef OPENSSL_NO_RFC3779 +# define OPENSSL_NO_RFC3779 +#endif +#ifndef OPENSSL_NO_SCTP +# define OPENSSL_NO_SCTP +#endif +#ifndef OPENSSL_NO_SSL_TRACE +# define OPENSSL_NO_SSL_TRACE +#endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif +#ifndef OPENSSL_NO_STORE +# define OPENSSL_NO_STORE +#endif +#ifndef OPENSSL_NO_UNIT_TEST +# define OPENSSL_NO_UNIT_TEST +#endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif + +#endif /* OPENSSL_DOING_MAKEDEPEND */ + +#ifndef OPENSSL_THREADS +# define OPENSSL_THREADS +#endif +#ifndef OPENSSL_NO_DYNAMIC_ENGINE +# define OPENSSL_NO_DYNAMIC_ENGINE +#endif + +/* The OPENSSL_NO_* macros are also defined as NO_* if the application + asks for it. This is a transient feature that is provided for those + who haven't had the time to do the appropriate changes in their + applications. */ +#ifdef OPENSSL_ALGORITHM_DEFINES +# if defined(OPENSSL_NO_EC_NISTP_64_GCC_128) && !defined(NO_EC_NISTP_64_GCC_128) +# define NO_EC_NISTP_64_GCC_128 +# endif +# if defined(OPENSSL_NO_GMP) && !defined(NO_GMP) +# define NO_GMP +# endif +# if defined(OPENSSL_NO_JPAKE) && !defined(NO_JPAKE) +# define NO_JPAKE +# endif +# if defined(OPENSSL_NO_KRB5) && !defined(NO_KRB5) +# define NO_KRB5 +# endif +# if defined(OPENSSL_NO_LIBUNBOUND) && !defined(NO_LIBUNBOUND) +# define NO_LIBUNBOUND +# endif +# if defined(OPENSSL_NO_MD2) && !defined(NO_MD2) +# define NO_MD2 +# endif +# if defined(OPENSSL_NO_RC5) && !defined(NO_RC5) +# define NO_RC5 +# endif +# if defined(OPENSSL_NO_RFC3779) && !defined(NO_RFC3779) +# define NO_RFC3779 +# endif +# if defined(OPENSSL_NO_SCTP) && !defined(NO_SCTP) +# define NO_SCTP +# endif +# if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) +# define NO_SSL_TRACE +# endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif +# if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) +# define NO_STORE +# endif +# if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) +# define NO_UNIT_TEST +# endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif +#endif + + + +/* crypto/opensslconf.h.in */ + +/* Generate 80386 code? */ +#undef I386_ONLY + +#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */ +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define ENGINESDIR "/usr/local/ssl/lib/engines" +#define OPENSSLDIR "/usr/local/ssl" +#endif +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned char +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependancies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +#error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very mucy CPU dependant */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( __sun ) || defined ( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ +#ifdef __cplusplus +} +#endif diff --git a/deps/openssl/config/opensslconf.h b/deps/openssl/config/opensslconf.h index 9a7cda94543e68..9b20fb6485aa84 100644 --- a/deps/openssl/config/opensslconf.h +++ b/deps/openssl/config/opensslconf.h @@ -27,6 +27,8 @@ | linux | arm64 | linux-aarch64 | o | | linux | ppc | linux-ppc | o | | linux | ppc64 | linux-ppc64 | o | + | linux | s390 | linux32-s390x | o | + | linux | s390x | linux64-s390x | o | | mac | ia32 | darwin-i386-cc | o | | mac | x64 | darwin64-x86-cc | o | | win | ia32 | VC-WIN32 | - | @@ -68,6 +70,8 @@ | | _ARCH_PPC | | ppc64 | __PPC64__ | | | _ARCH_PPC64 | + | s390 | __s390__ | + | s390x | __s390x__ | These are the list which is not implemented yet. @@ -124,6 +128,10 @@ # include "./archs/aix64-gcc/opensslconf.h" #elif defined(_AIX) && !defined(_ARCH_PPC64) && defined(_ARCH_PPC) # include "./archs/aix-gcc/opensslconf.h" +#elif defined(OPENSSL_LINUX) && defined(__s390x__) +# include "./archs/linux64-s390x/opensslconf.h" +#elif defined(OPENSSL_LINUX) && defined(__s390__) +# include "./archs/linux32-s390x/opensslconf.h" #else # include "./archs/linux-elf/opensslconf.h" #endif diff --git a/tools/test.py b/tools/test.py index e1189bfbc28608..8b66b3136769b7 100755 --- a/tools/test.py +++ b/tools/test.py @@ -777,7 +777,8 @@ def GetTestStatus(self, context, sections, defs): 'armv6' : { 'debug' : 12, 'release' : 3 }, # The ARM buildbots are slow. 'arm' : { 'debug' : 8, 'release' : 2 }, 'ia32' : { 'debug' : 4, 'release' : 1 }, - 'ppc' : { 'debug' : 4, 'release' : 1 } } + 'ppc' : { 'debug' : 4, 'release' : 1 }, + 's390' : { 'debug' : 4, 'release' : 1 } } class Context(object): diff --git a/tools/utils.py b/tools/utils.py index c77ab8edafcbe3..dd5ce3fcb629a4 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -89,6 +89,8 @@ def GuessArchitecture(): return 'ia32' elif id.startswith('ppc'): return 'ppc' + elif id == 's390x': + return 's390' else: id = platform.processor() if id == 'powerpc': From 9606f768ea52cbc1e44eeb5ee110821efdf8b165 Mon Sep 17 00:00:00 2001 From: Bryon Leung Date: Fri, 27 Mar 2015 21:39:06 -0700 Subject: [PATCH 026/261] test: run v8 tests from node tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ported by exinfinitum from a PR by jasnell: see https://github.com/nodejs/node-v0.x-archive/pull/14185 Allows the running of v8 tests on node's packaged v8 source code. Note that the limited win32 support added by jasnell has NOT been ported, and so these tests are currently UNIX ONLY. Note that gclient depot tools (see https://commondatastorage.googleapis.com/ chrome-infra-docs/flat/depot_tools/docs/html/ depot_tools_tutorial.html#_setting_up) and subversion are required to run tests. To perform tests, run the following commands: make v8 DESTCPU=(ARCH) make test-v8 DESTCPU=(ARCH) where (ARCH) is your CPU architecture, e.g. x64, ia32. DESTCPU MUST be specified for this to work properly. Can also do tests on debug build by using "make test-v8 DESTCPU=(ARCH) BUILDTYPE=Debug", or perform intl or benchmark tests via make test-v8-intl or test-v8-benchmarks respectively. Note that by default, quickcheck and TAP output are disabled, and i18n is enabled. To activate these options, use options"QUICKCHECK=True" and "ENABLE_V8_TAP=True" respectively. Use "DISABLE_V8_I18N" to disable i18n. Use V8_BUILD_OPTIONS to allow custom user-defined flags to be appended onto "make v8". Any tests performed after changes to the packaged v8 file will require recompiling of v8, which can be done using "make v8 DESTCPU=(ARCH)". Finally, two additional files necessary for one of the v8 tests have been added to the v8 folder. PR-URL: https://github.com/nodejs/node/pull/4704 Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Ben Noordhuis Reviewed-By: targos - Michaël Zasso --- Makefile | 58 +- deps/v8/test/mjsunit/tools/profviz-test.log | 2613 +++++++++++++++++ .../tools/tickprocessor-test-func-info.log | 11 + .../test/mjsunit/tools/tickprocessor-test.log | 25 + tools/make-v8.sh | 38 + 5 files changed, 2744 insertions(+), 1 deletion(-) create mode 100644 deps/v8/test/mjsunit/tools/profviz-test.log create mode 100644 deps/v8/test/mjsunit/tools/tickprocessor-test-func-info.log create mode 100644 deps/v8/test/mjsunit/tools/tickprocessor-test.log create mode 100755 tools/make-v8.sh diff --git a/Makefile b/Makefile index 383542680bc512..1823d9b771853e 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,23 @@ STAGINGSERVER ?= node-www OSTYPE := $(shell uname -s | tr '[A-Z]' '[a-z]') +ifdef QUICKCHECK + QUICKCHECK_ARG := --quickcheck +endif + +ifdef ENABLE_V8_TAP + TAP_V8 := --junitout v8-tap.xml + TAP_V8_INTL := --junitout v8-intl-tap.xml + TAP_V8_BENCHMARKS := --junitout v8-benchmarks-tap.xml +endif + +ifdef DISABLE_V8_I18N + V8_TEST_NO_I18N := --noi18n + V8_BUILD_OPTIONS += i18nsupport=off +endif + +BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]') + # Determine EXEEXT EXEEXT := $(shell $(PYTHON) -c \ "import sys; print('.exe' if sys.platform == 'win32' else '')") @@ -81,12 +98,18 @@ distclean: -rm -rf deps/icu -rm -rf deps/icu4c*.tgz deps/icu4c*.zip deps/icu-tmp -rm -f $(BINARYTAR).* $(TARBALL).* + -rm -rf deps/v8/testing/gmock + -rm -rf deps/v8/testing/gtest check: test cctest: all @out/$(BUILDTYPE)/$@ +v8: + tools/make-v8.sh v8 + $(MAKE) -C deps/v8 $(V8_ARCH) $(V8_BUILD_OPTIONS) + test: | cctest # Depends on 'all'. $(PYTHON) tools/test.py --mode=release doctool message parallel sequential -J $(MAKE) jslint @@ -187,6 +210,30 @@ test-timers: test-timers-clean: $(MAKE) --directory=tools clean +test-v8: + # note: performs full test unless QUICKCHECK is specified + deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \ + --mode=$(BUILDTYPE_LOWER) $(V8_TEST_NO_I18N) $(QUICKCHECK_ARG) \ + --no-presubmit \ + --shell-dir=$(PWD)/deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) \ + $(TAP_V8) + +test-v8-intl: + # note: performs full test unless QUICKCHECK is specified + deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \ + --mode=$(BUILDTYPE_LOWER) --no-presubmit $(QUICKCHECK_ARG) \ + --shell-dir=deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) intl \ + $(TAP_V8_INTL) + +test-v8-benchmarks: + deps/v8/tools/run-tests.py --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \ + --download-data $(QUICKCHECK_ARG) --no-presubmit \ + --shell-dir=deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) benchmarks \ + $(TAP_V8_BENCHMARKS) + +test-v8-all: test-v8 test-v8-intl test-v8-benchmarks + # runs all v8 tests + apidoc_sources = $(wildcard doc/api/*.markdown) apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \ $(addprefix out/,$(apidoc_sources:.markdown=.json)) @@ -328,6 +375,15 @@ endif endif endif +# node and v8 use different arch names (e.g. node 'x86' vs v8 'ia32'). +# pass the proper v8 arch name to $V8_ARCH based on user-specified $DESTCPU. +ifeq ($(DESTCPU),x86) +V8_ARCH=ia32 +else +V8_ARCH ?= $(DESTCPU) + +endif + # enforce "x86" over "ia32" as the generally accepted way of referring to 32-bit intel ifeq ($(ARCH),ia32) override ARCH=x86 @@ -594,4 +650,4 @@ lint-ci: lint blog blogclean tar binary release-only bench-http-simple bench-idle \ bench-all bench bench-misc bench-array bench-buffer bench-net \ bench-http bench-fs bench-tls cctest run-ci lint-ci bench-ci \ - $(TARBALL)-headers + test-v8 test-v8-intl test-v8-benchmarks test-v8-all v8 $(TARBALL)-headers diff --git a/deps/v8/test/mjsunit/tools/profviz-test.log b/deps/v8/test/mjsunit/tools/profviz-test.log new file mode 100644 index 00000000000000..fe4b7ffcbc09d2 --- /dev/null +++ b/deps/v8/test/mjsunit/tools/profviz-test.log @@ -0,0 +1,2613 @@ +shared-library,"/usr/local/google/home/yangguo/v8/out/ia32.release/d8",0x08048000,0x08557000 +shared-library,"2506f000-25070000",0x2506f000,0x25070000 +shared-library,"31e60000-31e61000",0x31e60000,0x31e61000 +shared-library,"35dff000-35e00000",0x35dff000,0x35e00000 +shared-library,"48218000-48219000",0x48218000,0x48219000 +shared-library,"4af7d000-4af7e000",0x4af7d000,0x4af7e000 +shared-library,"55bf2000-55bf3000",0x55bf2000,0x55bf3000 +shared-library,"/lib/i386-linux-gnu/libc-2.15.so",0xf7450000,0xf75f3000 +shared-library,"/lib/i386-linux-gnu/libpthread-2.15.so",0xf75f9000,0xf7610000 +shared-library,"/lib/i386-linux-gnu/libgcc_s.so.1",0xf7614000,0xf7630000 +shared-library,"/lib/i386-linux-gnu/libm-2.15.so",0xf7633000,0xf765d000 +shared-library,"/usr/lib/i386-linux-gnu/libstdc++.so.6.0.16",0xf765f000,0xf7737000 +shared-library,"[vdso]",0xf776d000,0xf776e000 +shared-library,"/lib/i386-linux-gnu/ld-2.15.so",0xf776e000,0xf778e000 +profiler,"begin",1 +timer-event-start,"V8.GCCompactor",2425 +timer-event-start,"V8.External",2458 +timer-event-end,"V8.External",2468 +timer-event-start,"V8.External",3810 +timer-event-end,"V8.External",3830 +timer-event-end,"V8.GCCompactor",3840 +code-creation,Stub,2,0x2b80a000,484,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80a200,622,"CEntryStub" +code-creation,Stub,2,0x2b80a480,540,"ArrayNArgumentsConstructorStub" +code-creation,Stub,13,0x2b80a6a0,116,"CompareICStub" +code-creation,Stub,2,0x2b80a720,1428,"RecordWriteStub" +code-creation,Stub,2,0x2b80acc0,97,"StoreBufferOverflowStub" +code-creation,Stub,2,0x2b80ad40,611,"RecordWriteStub" +code-creation,Stub,2,0x2b80afc0,76,"InterruptStub" +code-creation,Stub,13,0x2b80b020,104,"CompareICStub" +code-creation,Stub,2,0x2b80b0a0,130,"ArgumentsAccessStub" +code-creation,Stub,2,0x2b80b140,160,"FastNewContextStub" +code-creation,Stub,2,0x2b80b1e0,79,"StubFailureTrampolineStub" +code-creation,Stub,2,0x2b80b240,704,"ArraySingleArgumentConstructorStub" +code-creation,Stub,14,0x2b80b500,93,"CompareNilICStub" +code-creation,Stub,2,0x2b80b560,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80b6a0,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80b940,740,"NameDictionaryLookupStub" +code-creation,Stub,13,0x2b80bc40,156,"CompareICStub" +code-creation,Stub,2,0x2b80bce0,611,"RecordWriteStub" +code-creation,Stub,13,0x2b80bf60,122,"CompareICStub" +code-creation,Stub,2,0x2b80bfe0,217,"CreateAllocationSiteStub" +code-creation,Stub,2,0x2b80c0c0,1456,"RecordWriteStub" +code-creation,Stub,2,0x2b80c680,245,"StoreArrayLiteralElementStub" +code-creation,Stub,2,0x2b80c780,1448,"RecordWriteStub" +code-creation,Stub,2,0x2b80cd40,1471,"StringAddStub" +code-creation,Stub,2,0x2b80d300,1448,"RecordWriteStub" +code-creation,Stub,2,0x2b80d8c0,1453,"RecordWriteStub" +code-creation,Stub,12,0x2b80de80,146,"BinaryOpStub" +code-creation,Stub,2,0x2b80df20,640,"InternalArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80e1a0,517,"ArrayConstructorStub" +code-creation,Stub,2,0x2b80e3c0,305,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e500,305,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e640,349,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e7a0,349,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e900,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80ea40,680,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80ed00,692,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80efc0,704,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80f280,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80f520,488,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80f720,540,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80f940,432,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80fb00,432,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80fcc0,1453,"RecordWriteStub" +code-creation,Stub,2,0x2b810280,400,"InternalArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b810420,611,"RecordWriteStub" +code-creation,Stub,2,0x2b8106a0,213,"JSEntryStub" +code-creation,Stub,13,0x2b810780,104,"CompareICStub" +code-creation,Stub,12,0x2b810800,124,"BinaryOpStub" +code-creation,Stub,2,0x2b810880,1447,"StringAddStub" +code-creation,Stub,2,0x2b810e40,640,"InternalArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b8110c0,400,"InternalArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b811260,261,"FastCloneShallowArrayStub" +code-creation,Stub,12,0x2b811380,88,"BinaryOpStub" +code-creation,Stub,2,0x2b8113e0,76,"StackCheckStub" +code-creation,Stub,2,0x2b811440,1437,"RecordWriteStub" +code-creation,Stub,2,0x2b8119e0,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b811b20,331,"CallFunctionStub" +code-creation,Builtin,3,0x2b811c80,174,"A builtin from the snapshot" +code-creation,Stub,14,0x2b811d40,124,"CompareNilICStub" +code-creation,Stub,2,0x2b811dc0,1420,"RecordWriteStub" +code-creation,Stub,13,0x2b812360,104,"CompareICStub" +code-creation,Stub,2,0x2b8123e0,76,"LoadFieldStub" +code-creation,Stub,13,0x2b812440,104,"CompareICStub" +code-creation,Stub,2,0x2b8124c0,195,"NumberToStringStub" +code-creation,Stub,15,0x2b8125a0,148,"ToBooleanStub" +code-creation,Stub,2,0x2b812640,351,"ArgumentsAccessStub" +code-creation,Stub,2,0x2b8127a0,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b812a40,1420,"RecordWriteStub" +code-creation,Stub,12,0x2b812fe0,133,"BinaryOpStub" +code-creation,Stub,2,0x2b813080,1664,"StringAddStub" +code-creation,Stub,2,0x2b813700,1661,"StringAddStub" +code-creation,Stub,2,0x2b813d80,472,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b813f60,80,"StubFailureTrampolineStub" +code-creation,Stub,13,0x2b813fc0,104,"CompareICStub" +code-creation,Stub,2,0x2b814040,331,"CallFunctionStub" +code-creation,Stub,2,0x2b8141a0,660,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b814440,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b8149e0,146,"BinaryOpStub" +code-creation,Stub,2,0x2b814a80,271,"CallConstructStub" +code-creation,Stub,15,0x2b814ba0,136,"ToBooleanStub" +code-creation,Stub,2,0x2b814c40,468,"ArrayNArgumentsConstructorStub" +code-creation,Stub,15,0x2b814e20,128,"ToBooleanStub" +code-creation,Stub,2,0x2b814ea0,163,"FastNewContextStub" +code-creation,Stub,2,0x2b814f60,1425,"RecordWriteStub" +code-creation,LoadIC,5,0x2b815500,145,"A load IC from the snapshot" +code-creation,Builtin,3,0x2b8155a0,83,"A builtin from the snapshot" +code-creation,Stub,12,0x2b815600,88,"BinaryOpStub" +code-creation,Stub,2,0x2b815660,1433,"RecordWriteStub" +code-creation,Stub,2,0x2b815c00,331,"CallFunctionStub" +code-creation,Stub,13,0x2b815d60,104,"CompareICStub" +code-creation,Stub,2,0x2b815de0,304,"FastNewClosureStub" +code-creation,Stub,2,0x2b815f20,285,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b816040,1433,"RecordWriteStub" +code-creation,Stub,2,0x2b8165e0,233,"InternalArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b8166e0,740,"NameDictionaryLookupStub" +code-creation,Stub,2,0x2b8169e0,740,"NameDictionaryLookupStub" +code-creation,Stub,12,0x2b816ce0,88,"BinaryOpStub" +code-creation,Stub,2,0x2b816d40,216,"StringCompareStub" +code-creation,Stub,15,0x2b816e20,93,"ToBooleanStub" +code-creation,Stub,12,0x2b816e80,88,"BinaryOpStub" +code-creation,Stub,2,0x2b816ee0,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b817480,155,"BinaryOpStub" +code-creation,Stub,2,0x2b817520,169,"InternalArrayConstructorStub" +code-creation,Stub,2,0x2b8175e0,233,"InternalArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b8176e0,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b817c80,88,"BinaryOpStub" +code-creation,Stub,2,0x2b817ce0,328,"KeyedLoadElementStub" +code-creation,Stub,2,0x2b817e40,1461,"RecordWriteStub" +code-creation,Stub,2,0x2b818400,98,"ToNumberStub" +code-creation,Stub,13,0x2b818480,122,"CompareICStub" +code-creation,Stub,12,0x2b818500,124,"BinaryOpStub" +code-creation,Stub,2,0x2b818580,148,"CallConstructStub" +code-creation,Stub,13,0x2b818620,491,"CompareICStub" +code-creation,Stub,2,0x2b818820,213,"JSEntryStub" +code-creation,CallIC,7,0x2b818900,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8189c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818a80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818b40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818c00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818cc0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818d80,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818e40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818f00,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818fc0,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819080,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819140,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819200,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8192c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819380,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819440,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819500,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8195c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819680,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819740,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819800,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8198c0,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819980,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819a40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819b00,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819bc0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819c80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819d40,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819e00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819ec0,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819f80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a040,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a100,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a1c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a280,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a340,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a400,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a4c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a580,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a640,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a700,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a7c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a880,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a940,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81aa00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81aac0,180,"A call IC from the snapshot" +code-creation,Builtin,3,0x2b81ab80,107,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ac00,105,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ac80,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ace0,432,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81afc0,101,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b81b1a0,83,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b81bf00,83,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b81c680,84,"A store IC from the snapshot" +code-creation,Builtin,3,0x2b8262e0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826340,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8263a0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826400,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826460,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8264c0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826520,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826580,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8265e0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826640,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8266a0,80,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826700,80,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826760,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8267c0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826820,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826880,75,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8268e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826960,491,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826b60,406,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826d00,157,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826da0,131,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826e40,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826ec0,107,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826f40,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826fe0,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827080,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827120,94,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827180,91,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8271e0,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827240,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8272a0,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827300,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827360,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8273c0,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827420,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827480,84,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b8274e0,83,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827540,313,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827680,266,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b8277a0,80,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827800,83,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827860,83,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b8278c0,896,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827c40,499,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827e40,144,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827ee0,216,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b827fc0,365,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828140,293,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828280,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8282e0,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828340,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8283a0,84,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828400,365,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828580,293,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8286c0,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828720,82,"A store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b828780,84,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b8287e0,2082,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b829020,84,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b829080,2082,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b8298c0,286,"A keyed store IC from the snapshot" +code-creation,Builtin,3,0x2b8299e0,355,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829b60,416,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829d00,376,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829e80,388,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a020,78,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a080,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a0e0,357,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a260,359,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a3e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a460,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a4e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a560,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a5e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a660,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a6e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a760,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a7e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a860,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a8e0,104,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a960,106,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a9e0,110,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82aa60,112,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b82aae0,106,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b82ab60,106,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b82abe0,108,"A store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b82ac60,108,"A keyed store IC from the snapshot" +code-creation,Stub,14,0x2b82ace0,104,"CallFunctionStub" +code-creation,Builtin,3,0x2b82ad60,65,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82adc0,93,"A builtin from the snapshot" +timer-event-start,"V8.GCCompactor",6301 +timer-event-start,"V8.External",6312 +timer-event-end,"V8.External",6321 +timer-event-start,"V8.External",7418 +timer-event-end,"V8.External",7436 +timer-event-end,"V8.GCCompactor",7446 +code-creation,LazyCompile,3,0x2b81ac80,77,"Empty :1",0x4420e5cc, +code-creation,LazyCompile,0,0x2b81aea0,264," native uri.js:1",0x4420e668, +code-creation,LazyCompile,0,0x2b81b040,336,"SetUpUri native uri.js:442",0x4420f5b4, +code-creation,LazyCompile,0,0x2b81b200,1880," native messages.js:1",0x4420f670, +code-creation,LazyCompile,0,0x2b81b960,1429,"FormatString native messages.js:187",0x4420f918, +code-creation,LazyCompile,0,0x2b81bf60,280,"MakeGenericError native messages.js:282",0x44211088, +code-creation,LazyCompile,0,0x2b81c080,264,"FormatMessage native messages.js:301",0x4421113c, +code-creation,LazyCompile,0,0x2b81c1a0,200,"MakeRangeError native messages.js:335",0x442112f0, +code-creation,LazyCompile,0,0x2b81c280,1012,"captureStackTrace native messages.js:1123",0x44212280, +code-creation,LazyCompile,0,0x2b81c6e0,460,"SetUpError native messages.js:1173",0x44212410, +code-creation,LazyCompile,0,0x2b81c8c0,692,"SetUpError.a native messages.js:1176",0x442124c0, +code-creation,LazyCompile,0,0x2b81cb80,164,"d native messages.js:1192",0x44212548, +code-creation,LazyCompile,0,0x2b81cc40,360," native messages.js:1202",0x442125d0, +code-creation,LazyCompile,0,0x2b81cc40,360,"Error",0x44212698, +code-creation,LazyCompile,0,0x2b81cc40,360,"TypeError",0x442126f8, +code-creation,LazyCompile,0,0x2b81cc40,360,"RangeError",0x44212758, +code-creation,LazyCompile,0,0x2b81cc40,360,"SyntaxError",0x442127b8, +code-creation,LazyCompile,0,0x2b81cc40,360,"ReferenceError",0x44212818, +code-creation,LazyCompile,0,0x2b81cc40,360,"EvalError",0x44212878, +code-creation,LazyCompile,0,0x2b81cc40,360,"URIError",0x442128d8, +code-creation,LazyCompile,0,0x2b81cdc0,424,"SetUpStackOverflowBoilerplate native messages.js:1301",0x44212a74, +code-creation,LazyCompile,0,0x2b81cf80,216," native messages.js:294",0x44214b3c, +code-creation,LazyCompile,0,0x2b81d060,408," native string.js:1",0x44214c2c, +code-creation,LazyCompile,0,0x2b81d200,380,"StringConstructor native string.js:35",0x44214e2c, +code-creation,LazyCompile,0,0x2b81d380,1132,"SetUpString native string.js:962",0x44216ea8, +code-creation,LazyCompile,0,0x2b81d800,616," native date.js:1",0x44216fa0, +code-creation,LazyCompile,0,0x2b81da80,1392,"DateConstructor native date.js:141",0x442182bc, +code-creation,LazyCompile,0,0x2b81e000,1396,"SetUpDate native date.js:761",0x44219944, +code-creation,LazyCompile,0,0x2b81e580,268," native array.js:1",0x44219b20, +code-creation,LazyCompile,0,0x2b81e6a0,2272,"SetUpArray native array.js:1591",0x4421c6ac, +code-creation,LazyCompile,0,0x2b81ef80,292,"SetUpArray.b native array.js:1605",0x4421c814, +code-creation,LazyCompile,0,0x2b81f0c0,1084," native v8natives.js:1",0x4421c904, +code-creation,LazyCompile,0,0x2b81f500,561,"InstallFunctions native v8natives.js:46",0x4421cc1c, +code-creation,LazyCompile,0,0x2b81f740,304,"InstallGetterSetter native v8natives.js:72",0x4421ea1c, +code-creation,LazyCompile,0,0x2b81f880,814,"SetUpLockedPrototype native v8natives.js:87",0x4421eab4, +code-creation,LazyCompile,0,0x2b81fbc0,452,"SetUpGlobal native v8natives.js:197",0x4421ed3c, +code-creation,LazyCompile,0,0x2b81fda0,404,"hasOwnProperty native v8natives.js:251",0x4421eee4, +code-creation,LazyCompile,0,0x2b81ff40,308,"ObjectConstructor native v8natives.js:1371",0x442200b4, +code-creation,LazyCompile,0,0x2b820080,1044,"SetUpObject native v8natives.js:1385",0x44220140, +code-creation,LazyCompile,0,0x2b8204a0,292,"BooleanConstructor native v8natives.js:1437",0x442201c8, +code-creation,LazyCompile,0,0x2b8205e0,448,"SetUpBoolean native v8natives.js:1472",0x44220314, +code-creation,LazyCompile,0,0x2b8207a0,336,"NumberConstructor native v8natives.js:1491",0x442203ac, +code-creation,LazyCompile,0,0x2b820900,924,"SetUpNumber native v8natives.js:1635",0x4422073c, +code-creation,LazyCompile,0,0x2b820ca0,440,"FunctionConstructor native v8natives.js:1813",0x44220954, +code-creation,LazyCompile,0,0x2b820e60,380,"SetUpFunction native v8natives.js:1826",0x442209f8, +code-creation,LazyCompile,0,0x2b820fe0,264," native json.js:1",0x44221238, +code-creation,LazyCompile,0,0x2b821100,260,"SetUpJSON native json.js:219",0x44221940, +code-creation,LazyCompile,0,0x2b821220,340," native math.js:1",0x44221a5c, +code-creation,LazyCompile,0,0x2b821380,164,"MathConstructor native math.js:40",0x44221ba4, +code-creation,LazyCompile,0,0x2b821440,1112,"SetUpMath native math.js:226",0x4422283c, +code-creation,LazyCompile,0,0x2b8218a0,404," native regexp.js:1",0x442228f8, +code-creation,LazyCompile,0,0x2b821a40,324,"RegExpConstructor native regexp.js:90",0x44223264, +code-creation,LazyCompile,0,0x2b821ba0,224,"RegExpMakeCaptureGetter native regexp.js:360",0x44223784, +code-creation,LazyCompile,0,0x2b821c80,1561,"SetUpRegExp native regexp.js:400",0x44223878, +code-creation,LazyCompile,0,0x2b8222a0,280," native apinatives.js:1",0x44223b98, +code-creation,LazyCompile,0,0x2b8223c0,612," native runtime.js:1",0x44223e30, +code-creation,LazyCompile,0,0x2b822640,1728,"EQUALS native runtime.js:54",0x44224078, +code-creation,LazyCompile,0,0x2b822d00,376,"STRICT_EQUALS native runtime.js:108",0x44224c18, +code-creation,LazyCompile,0,0x2b822e80,924,"COMPARE native runtime.js:128",0x44224ca4, +code-creation,LazyCompile,0,0x2b823220,596,"ADD native runtime.js:171",0x44224d44, +code-creation,LazyCompile,0,0x2b823480,572,"STRING_ADD_LEFT native runtime.js:191",0x44224dd8, +code-creation,LazyCompile,0,0x2b8236c0,580,"STRING_ADD_RIGHT native runtime.js:206",0x44224e64, +code-creation,LazyCompile,0,0x2b823920,296,"SUB native runtime.js:222",0x44224ef4, +code-creation,LazyCompile,0,0x2b823a60,296,"MUL native runtime.js:230",0x44224f84, +code-creation,LazyCompile,0,0x2b823ba0,296,"DIV native runtime.js:238",0x44225014, +code-creation,LazyCompile,0,0x2b823ce0,296,"MOD native runtime.js:246",0x442250a4, +code-creation,LazyCompile,0,0x2b823e20,296,"BIT_OR native runtime.js:260",0x44225134, +code-creation,LazyCompile,0,0x2b823f60,384,"BIT_AND native runtime.js:268",0x442251c4, +code-creation,LazyCompile,0,0x2b8240e0,296,"BIT_XOR native runtime.js:290",0x44225254, +code-creation,LazyCompile,0,0x2b824220,244,"UNARY_MINUS native runtime.js:298",0x442252e4, +code-creation,LazyCompile,0,0x2b824320,244,"BIT_NOT native runtime.js:305",0x44225370, +code-creation,LazyCompile,0,0x2b824420,296,"SHL native runtime.js:312",0x442253fc, +code-creation,LazyCompile,0,0x2b824560,384,"SAR native runtime.js:320",0x4422548c, +code-creation,LazyCompile,0,0x2b8246e0,296,"SHR native runtime.js:342",0x4422551c, +code-creation,LazyCompile,0,0x2b824820,228,"DELETE native runtime.js:356",0x442255ac, +code-creation,LazyCompile,0,0x2b824920,368,"IN native runtime.js:362",0x4422563c, +code-creation,LazyCompile,0,0x2b824aa0,644,"INSTANCE_OF native runtime.js:375",0x442256e8, +code-creation,LazyCompile,0,0x2b824d40,236,"FILTER_KEY native runtime.js:406",0x442257b8, +code-creation,LazyCompile,0,0x2b824e40,380,"CALL_NON_FUNCTION native runtime.js:413",0x44225848, +code-creation,LazyCompile,0,0x2b824fc0,380,"CALL_NON_FUNCTION_AS_CONSTRUCTOR native runtime.js:422",0x442258f4, +code-creation,LazyCompile,0,0x2b825140,288,"CALL_FUNCTION_PROXY native runtime.js:431",0x442259a0, +code-creation,LazyCompile,0,0x2b825260,260,"CALL_FUNCTION_PROXY_AS_CONSTRUCTOR native runtime.js:439",0x44225a38, +code-creation,LazyCompile,0,0x2b825380,912,"APPLY_PREPARE native runtime.js:446",0x44225acc, +code-creation,LazyCompile,0,0x2b825720,232,"APPLY_OVERFLOW native runtime.js:484",0x44225b9c, +code-creation,LazyCompile,0,0x2b825820,188,"TO_OBJECT native runtime.js:490",0x44225c38, +code-creation,LazyCompile,0,0x2b8258e0,188,"TO_NUMBER native runtime.js:496",0x44225cc0, +code-creation,LazyCompile,0,0x2b8259a0,188,"TO_STRING native runtime.js:502",0x44225d48, +code-creation,LazyCompile,0,0x2b825a60,600,"ToPrimitive native runtime.js:514",0x44225dd0, +code-creation,LazyCompile,0,0x2b825cc0,404,"ToBoolean native runtime.js:526",0x44225e60, +code-creation,LazyCompile,0,0x2b825e60,504,"ToNumber native runtime.js:536",0x44225eec, +code-creation,LazyCompile,0,0x2b826060,416,"ToString native runtime.js:561",0x44225fd8, +code-creation,LazyCompile,0,0x2b826200,220,"ToName native runtime.js:578",0x442260c4, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227108, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227168, +code-creation,LazyCompile,3,0x2b8262e0,77,"OpaqueReference",0x442271c8, +code-creation,LazyCompile,3,0x2b8262e0,77,"JSON",0x44227228, +code-creation,LazyCompile,0,0x2b8204a0,292,"Boolean",0x44227288, +code-creation,LazyCompile,3,0x2b82a080,83,"Array",0x442272e8, +code-creation,LazyCompile,3,0x2b826460,77,"pop",0x44227348, +code-creation,LazyCompile,3,0x2b826400,77,"push",0x442273a8, +code-creation,LazyCompile,3,0x2b826640,77,"concat",0x44227408, +code-creation,LazyCompile,3,0x2b8264c0,77,"shift",0x44227468, +code-creation,LazyCompile,3,0x2b826520,77,"unshift",0x442274c8, +code-creation,LazyCompile,3,0x2b826580,77,"slice",0x44227528, +code-creation,LazyCompile,3,0x2b8265e0,77,"splice",0x44227588, +code-creation,LazyCompile,0,0x2b8207a0,336,"Number",0x442275e8, +code-creation,LazyCompile,3,0x2b82a020,78,"InternalArray",0x44227648, +code-creation,LazyCompile,3,0x2b82a020,78,"InternalPackedArray",0x442276b4, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227714, +code-creation,LazyCompile,0,0x2b821a40,324,"RegExp",0x44227774, +code-creation,LazyCompile,0,0x2b81da80,1392,"Date",0x442277d4, +code-creation,LazyCompile,0,0x2b820ca0,440,"Function",0x44227834, +code-creation,LazyCompile,0,0x2b81d200,380,"String",0x44227894, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x442278f4, +code-creation,LazyCompile,0,0x2b81cf80,216,"Script",0x44227960, +code-creation,LazyCompile,0,0x2b81ff40,308,"Object",0x44227a00, +code-creation,LazyCompile,3,0x2b829d00,376,"call",0x44227a60, +code-creation,LazyCompile,3,0x2b829e80,388,"apply",0x44227ac0, +code-creation,LazyCompile,3,0x2b8262e0,77,"Arguments",0x44227b20, +code-creation,LazyCompile,3,0x2b826820,77,"ThrowTypeError",0x44227b80, +code-creation,LazyCompile,3,0x2b826760,77,"",0x44227be0, +code-creation,LazyCompile,3,0x2b8267c0,77,"",0x44227c40, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227ca0, +timer-event-start,"V8.GCCompactor",9350 +timer-event-start,"V8.External",9362 +timer-event-end,"V8.External",9370 +timer-event-start,"V8.External",10477 +timer-event-end,"V8.External",10500 +timer-event-end,"V8.GCCompactor",10511 +code-creation,Stub,2,0x2b80a000,484,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80a200,622,"CEntryStub" +code-creation,Stub,2,0x2b80a480,540,"ArrayNArgumentsConstructorStub" +code-creation,Stub,13,0x2b80a6a0,116,"CompareICStub" +code-creation,Stub,2,0x2b80a720,1428,"RecordWriteStub" +code-creation,Stub,2,0x2b80acc0,97,"StoreBufferOverflowStub" +code-creation,Stub,2,0x2b80ad40,611,"RecordWriteStub" +code-creation,Stub,2,0x2b80afc0,76,"InterruptStub" +code-creation,Stub,13,0x2b80b020,104,"CompareICStub" +code-creation,Stub,2,0x2b80b0a0,130,"ArgumentsAccessStub" +code-creation,Stub,2,0x2b80b140,160,"FastNewContextStub" +code-creation,Stub,2,0x2b80b1e0,79,"StubFailureTrampolineStub" +code-creation,Stub,2,0x2b80b240,704,"ArraySingleArgumentConstructorStub" +code-creation,Stub,14,0x2b80b500,93,"CompareNilICStub" +code-creation,Stub,2,0x2b80b560,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80b6a0,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80b940,740,"NameDictionaryLookupStub" +code-creation,Stub,13,0x2b80bc40,156,"CompareICStub" +code-creation,Stub,2,0x2b80bce0,611,"RecordWriteStub" +code-creation,Stub,13,0x2b80bf60,122,"CompareICStub" +code-creation,Stub,2,0x2b80bfe0,217,"CreateAllocationSiteStub" +code-creation,Stub,2,0x2b80c0c0,1456,"RecordWriteStub" +code-creation,Stub,2,0x2b80c680,245,"StoreArrayLiteralElementStub" +code-creation,Stub,2,0x2b80c780,1448,"RecordWriteStub" +code-creation,Stub,2,0x2b80cd40,1471,"StringAddStub" +code-creation,Stub,2,0x2b80d300,1448,"RecordWriteStub" +code-creation,Stub,2,0x2b80d8c0,1453,"RecordWriteStub" +code-creation,Stub,12,0x2b80de80,146,"BinaryOpStub" +code-creation,Stub,2,0x2b80df20,640,"InternalArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80e1a0,517,"ArrayConstructorStub" +code-creation,Stub,2,0x2b80e3c0,305,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e500,305,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e640,349,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e7a0,349,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80e900,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b80ea40,680,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80ed00,692,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80efc0,704,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80f280,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b80f520,488,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80f720,540,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80f940,432,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80fb00,432,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b80fcc0,1453,"RecordWriteStub" +code-creation,Stub,2,0x2b810280,400,"InternalArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b810420,611,"RecordWriteStub" +code-creation,Stub,2,0x2b8106a0,213,"JSEntryStub" +code-creation,Stub,13,0x2b810780,104,"CompareICStub" +code-creation,Stub,12,0x2b810800,124,"BinaryOpStub" +code-creation,Stub,2,0x2b810880,1447,"StringAddStub" +code-creation,Stub,2,0x2b810e40,640,"InternalArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b8110c0,400,"InternalArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b811260,261,"FastCloneShallowArrayStub" +code-creation,Stub,12,0x2b811380,88,"BinaryOpStub" +code-creation,Stub,2,0x2b8113e0,76,"StackCheckStub" +code-creation,Stub,2,0x2b811440,1437,"RecordWriteStub" +code-creation,Stub,2,0x2b8119e0,289,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b811b20,331,"CallFunctionStub" +code-creation,Builtin,3,0x2b811c80,174,"A builtin from the snapshot" +code-creation,Stub,14,0x2b811d40,124,"CompareNilICStub" +code-creation,Stub,2,0x2b811dc0,1420,"RecordWriteStub" +code-creation,Stub,13,0x2b812360,104,"CompareICStub" +code-creation,Stub,2,0x2b8123e0,76,"LoadFieldStub" +code-creation,Stub,13,0x2b812440,104,"CompareICStub" +code-creation,Stub,2,0x2b8124c0,195,"NumberToStringStub" +code-creation,Stub,15,0x2b8125a0,148,"ToBooleanStub" +code-creation,Stub,2,0x2b812640,351,"ArgumentsAccessStub" +code-creation,Stub,2,0x2b8127a0,664,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b812a40,1420,"RecordWriteStub" +code-creation,Stub,12,0x2b812fe0,133,"BinaryOpStub" +code-creation,Stub,2,0x2b813080,1664,"StringAddStub" +code-creation,Stub,2,0x2b813700,1661,"StringAddStub" +code-creation,Stub,2,0x2b813d80,472,"ArrayNArgumentsConstructorStub" +code-creation,Stub,2,0x2b813f60,80,"StubFailureTrampolineStub" +code-creation,Stub,13,0x2b813fc0,104,"CompareICStub" +code-creation,Stub,2,0x2b814040,331,"CallFunctionStub" +code-creation,Stub,2,0x2b8141a0,660,"ArraySingleArgumentConstructorStub" +code-creation,Stub,2,0x2b814440,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b8149e0,146,"BinaryOpStub" +code-creation,Stub,2,0x2b814a80,271,"CallConstructStub" +code-creation,Stub,15,0x2b814ba0,136,"ToBooleanStub" +code-creation,Stub,2,0x2b814c40,468,"ArrayNArgumentsConstructorStub" +code-creation,Stub,15,0x2b814e20,128,"ToBooleanStub" +code-creation,Stub,2,0x2b814ea0,163,"FastNewContextStub" +code-creation,Stub,2,0x2b814f60,1425,"RecordWriteStub" +code-creation,LoadIC,5,0x2b815500,145,"A load IC from the snapshot" +code-creation,Builtin,3,0x2b8155a0,83,"A builtin from the snapshot" +code-creation,Stub,12,0x2b815600,88,"BinaryOpStub" +code-creation,Stub,2,0x2b815660,1433,"RecordWriteStub" +code-creation,Stub,2,0x2b815c00,331,"CallFunctionStub" +code-creation,Stub,13,0x2b815d60,104,"CompareICStub" +code-creation,Stub,2,0x2b815de0,304,"FastNewClosureStub" +code-creation,Stub,2,0x2b815f20,285,"ArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b816040,1433,"RecordWriteStub" +code-creation,Stub,2,0x2b8165e0,233,"InternalArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b8166e0,740,"NameDictionaryLookupStub" +code-creation,Stub,2,0x2b8169e0,740,"NameDictionaryLookupStub" +code-creation,Stub,12,0x2b816ce0,88,"BinaryOpStub" +code-creation,Stub,2,0x2b816d40,216,"StringCompareStub" +code-creation,Stub,15,0x2b816e20,93,"ToBooleanStub" +code-creation,Stub,12,0x2b816e80,88,"BinaryOpStub" +code-creation,Stub,2,0x2b816ee0,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b817480,155,"BinaryOpStub" +code-creation,Stub,2,0x2b817520,169,"InternalArrayConstructorStub" +code-creation,Stub,2,0x2b8175e0,233,"InternalArrayNoArgumentConstructorStub" +code-creation,Stub,2,0x2b8176e0,1433,"RecordWriteStub" +code-creation,Stub,12,0x2b817c80,88,"BinaryOpStub" +code-creation,Stub,2,0x2b817ce0,328,"KeyedLoadElementStub" +code-creation,Stub,2,0x2b817e40,1461,"RecordWriteStub" +code-creation,Stub,2,0x2b818400,98,"ToNumberStub" +code-creation,Stub,13,0x2b818480,122,"CompareICStub" +code-creation,Stub,12,0x2b818500,124,"BinaryOpStub" +code-creation,Stub,2,0x2b818580,148,"CallConstructStub" +code-creation,Stub,13,0x2b818620,491,"CompareICStub" +code-creation,Stub,2,0x2b818820,213,"JSEntryStub" +code-creation,CallIC,7,0x2b818900,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8189c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818a80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818b40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818c00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818cc0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818d80,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818e40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818f00,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b818fc0,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819080,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819140,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819200,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8192c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819380,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819440,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819500,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8195c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819680,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819740,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819800,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b8198c0,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819980,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819a40,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819b00,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819bc0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819c80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819d40,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819e00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819ec0,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b819f80,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a040,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a100,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a1c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a280,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a340,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a400,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a4c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a580,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a640,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a700,189,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a7c0,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a880,178,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81a940,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81aa00,180,"A call IC from the snapshot" +code-creation,CallIC,7,0x2b81aac0,180,"A call IC from the snapshot" +code-creation,Builtin,3,0x2b81ab80,107,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ac00,105,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ac80,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81ace0,432,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b81afc0,101,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b81b1a0,83,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b81bf00,83,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b81c680,84,"A store IC from the snapshot" +code-creation,Builtin,3,0x2b8262e0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826340,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8263a0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826400,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826460,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8264c0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826520,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826580,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8265e0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826640,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8266a0,80,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826700,80,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826760,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8267c0,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826820,77,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826880,75,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8268e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826960,491,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826b60,406,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826d00,157,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826da0,131,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826e40,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826ec0,107,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826f40,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b826fe0,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827080,143,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827120,94,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827180,91,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8271e0,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827240,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8272a0,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827300,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827360,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b8273c0,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827420,84,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b827480,84,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b8274e0,83,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827540,313,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827680,266,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b8277a0,80,"A load IC from the snapshot" +code-creation,LoadIC,5,0x2b827800,83,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827860,83,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b8278c0,896,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827c40,499,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827e40,144,"A keyed load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b827ee0,216,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b827fc0,365,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828140,293,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828280,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8282e0,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828340,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8283a0,84,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828400,365,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828580,293,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b8286c0,88,"A store IC from the snapshot" +code-creation,StoreIC,9,0x2b828720,82,"A store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b828780,84,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b8287e0,2082,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b829020,84,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b829080,2082,"A keyed store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b8298c0,286,"A keyed store IC from the snapshot" +code-creation,Builtin,3,0x2b8299e0,355,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829b60,416,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829d00,376,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b829e80,388,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a020,78,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a080,83,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a0e0,357,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a260,359,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a3e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a460,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a4e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a560,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a5e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a660,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a6e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a760,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a7e0,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a860,101,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a8e0,104,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a960,106,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82a9e0,110,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82aa60,112,"A builtin from the snapshot" +code-creation,LoadIC,5,0x2b82aae0,106,"A load IC from the snapshot" +code-creation,KeyedLoadIC,6,0x2b82ab60,106,"A keyed load IC from the snapshot" +code-creation,StoreIC,9,0x2b82abe0,108,"A store IC from the snapshot" +code-creation,KeyedStoreIC,10,0x2b82ac60,108,"A keyed store IC from the snapshot" +code-creation,Stub,14,0x2b82ace0,104,"CallFunctionStub" +code-creation,Builtin,3,0x2b82ad60,65,"A builtin from the snapshot" +code-creation,Builtin,3,0x2b82adc0,93,"A builtin from the snapshot" +timer-event-start,"V8.GCCompactor",12962 +timer-event-start,"V8.External",12972 +timer-event-end,"V8.External",12981 +timer-event-start,"V8.External",13996 +timer-event-end,"V8.External",14014 +timer-event-end,"V8.GCCompactor",14024 +code-creation,LazyCompile,3,0x2b81ac80,77,"Empty :1",0x4420e5cc, +code-creation,LazyCompile,0,0x2b81b040,336,"SetUpUri native uri.js:442",0x4420f5b4, +code-creation,LazyCompile,0,0x2b81b960,1429,"FormatString native messages.js:187",0x4420f918, +code-creation,LazyCompile,0,0x2b81bf60,280,"MakeGenericError native messages.js:282",0x44211088, +code-creation,LazyCompile,0,0x2b81c080,264,"FormatMessage native messages.js:301",0x4421113c, +code-creation,LazyCompile,0,0x2b81c1a0,200,"MakeRangeError native messages.js:335",0x442112f0, +code-creation,LazyCompile,0,0x2b81c280,1012,"captureStackTrace native messages.js:1123",0x44212280, +code-creation,LazyCompile,0,0x2b81c6e0,460,"SetUpError native messages.js:1173",0x44212410, +code-creation,LazyCompile,0,0x2b81c8c0,692,"SetUpError.a native messages.js:1176",0x442124c0, +code-creation,LazyCompile,0,0x2b81cb80,164,"d native messages.js:1192",0x44212548, +code-creation,LazyCompile,0,0x2b81cc40,360," native messages.js:1202",0x442125d0, +code-creation,LazyCompile,0,0x2b81cc40,360,"Error",0x44212698, +code-creation,LazyCompile,0,0x2b81cc40,360,"TypeError",0x442126f8, +code-creation,LazyCompile,0,0x2b81cc40,360,"RangeError",0x44212758, +code-creation,LazyCompile,0,0x2b81cc40,360,"SyntaxError",0x442127b8, +code-creation,LazyCompile,0,0x2b81cc40,360,"ReferenceError",0x44212818, +code-creation,LazyCompile,0,0x2b81cc40,360,"EvalError",0x44212878, +code-creation,LazyCompile,0,0x2b81cc40,360,"URIError",0x442128d8, +code-creation,LazyCompile,0,0x2b81cdc0,424,"SetUpStackOverflowBoilerplate native messages.js:1301",0x44212a74, +code-creation,LazyCompile,0,0x2b81d200,380,"StringConstructor native string.js:35",0x44214e2c, +code-creation,LazyCompile,0,0x2b81d380,1132,"SetUpString native string.js:962",0x44216ea8, +code-creation,LazyCompile,0,0x2b81da80,1392,"DateConstructor native date.js:141",0x442182bc, +code-creation,LazyCompile,0,0x2b81e000,1396,"SetUpDate native date.js:761",0x44219944, +code-creation,LazyCompile,0,0x2b81e6a0,2272,"SetUpArray native array.js:1591",0x4421c6ac, +code-creation,LazyCompile,0,0x2b81f500,561,"InstallFunctions native v8natives.js:46",0x4421cc1c, +code-creation,LazyCompile,0,0x2b81f740,304,"InstallGetterSetter native v8natives.js:72",0x4421ea1c, +code-creation,LazyCompile,0,0x2b81f880,814,"SetUpLockedPrototype native v8natives.js:87",0x4421eab4, +code-creation,LazyCompile,0,0x2b81fbc0,452,"SetUpGlobal native v8natives.js:197",0x4421ed3c, +code-creation,LazyCompile,0,0x2b81fda0,404,"hasOwnProperty native v8natives.js:251",0x4421eee4, +code-creation,LazyCompile,0,0x2b81ff40,308,"ObjectConstructor native v8natives.js:1371",0x442200b4, +code-creation,LazyCompile,0,0x2b820080,1044,"SetUpObject native v8natives.js:1385",0x44220140, +code-creation,LazyCompile,0,0x2b8204a0,292,"BooleanConstructor native v8natives.js:1437",0x442201c8, +code-creation,LazyCompile,0,0x2b8205e0,448,"SetUpBoolean native v8natives.js:1472",0x44220314, +code-creation,LazyCompile,0,0x2b8207a0,336,"NumberConstructor native v8natives.js:1491",0x442203ac, +code-creation,LazyCompile,0,0x2b820900,924,"SetUpNumber native v8natives.js:1635",0x4422073c, +code-creation,LazyCompile,0,0x2b820ca0,440,"FunctionConstructor native v8natives.js:1813",0x44220954, +code-creation,LazyCompile,0,0x2b820e60,380,"SetUpFunction native v8natives.js:1826",0x442209f8, +code-creation,LazyCompile,0,0x2b821100,260,"SetUpJSON native json.js:219",0x44221940, +code-creation,LazyCompile,0,0x2b821380,164,"MathConstructor native math.js:40",0x44221ba4, +code-creation,LazyCompile,0,0x2b821440,1112,"SetUpMath native math.js:226",0x4422283c, +code-creation,LazyCompile,0,0x2b821a40,324,"RegExpConstructor native regexp.js:90",0x44223264, +code-creation,LazyCompile,0,0x2b821ba0,224,"RegExpMakeCaptureGetter native regexp.js:360",0x44223784, +code-creation,LazyCompile,0,0x2b821c80,1561,"SetUpRegExp native regexp.js:400",0x44223878, +code-creation,LazyCompile,0,0x2b822640,1728,"EQUALS native runtime.js:54",0x44224078, +code-creation,LazyCompile,0,0x2b822d00,376,"STRICT_EQUALS native runtime.js:108",0x44224c18, +code-creation,LazyCompile,0,0x2b822e80,924,"COMPARE native runtime.js:128",0x44224ca4, +code-creation,LazyCompile,0,0x2b823220,596,"ADD native runtime.js:171",0x44224d44, +code-creation,LazyCompile,0,0x2b823480,572,"STRING_ADD_LEFT native runtime.js:191",0x44224dd8, +code-creation,LazyCompile,0,0x2b8236c0,580,"STRING_ADD_RIGHT native runtime.js:206",0x44224e64, +code-creation,LazyCompile,0,0x2b823920,296,"SUB native runtime.js:222",0x44224ef4, +code-creation,LazyCompile,0,0x2b823a60,296,"MUL native runtime.js:230",0x44224f84, +code-creation,LazyCompile,0,0x2b823ba0,296,"DIV native runtime.js:238",0x44225014, +code-creation,LazyCompile,0,0x2b823ce0,296,"MOD native runtime.js:246",0x442250a4, +code-creation,LazyCompile,0,0x2b823e20,296,"BIT_OR native runtime.js:260",0x44225134, +code-creation,LazyCompile,0,0x2b823f60,384,"BIT_AND native runtime.js:268",0x442251c4, +code-creation,LazyCompile,0,0x2b8240e0,296,"BIT_XOR native runtime.js:290",0x44225254, +code-creation,LazyCompile,0,0x2b824220,244,"UNARY_MINUS native runtime.js:298",0x442252e4, +code-creation,LazyCompile,0,0x2b824320,244,"BIT_NOT native runtime.js:305",0x44225370, +code-creation,LazyCompile,0,0x2b824420,296,"SHL native runtime.js:312",0x442253fc, +code-creation,LazyCompile,0,0x2b824560,384,"SAR native runtime.js:320",0x4422548c, +code-creation,LazyCompile,0,0x2b8246e0,296,"SHR native runtime.js:342",0x4422551c, +code-creation,LazyCompile,0,0x2b824820,228,"DELETE native runtime.js:356",0x442255ac, +code-creation,LazyCompile,0,0x2b824920,368,"IN native runtime.js:362",0x4422563c, +code-creation,LazyCompile,0,0x2b824aa0,644,"INSTANCE_OF native runtime.js:375",0x442256e8, +code-creation,LazyCompile,0,0x2b824d40,236,"FILTER_KEY native runtime.js:406",0x442257b8, +code-creation,LazyCompile,0,0x2b824e40,380,"CALL_NON_FUNCTION native runtime.js:413",0x44225848, +code-creation,LazyCompile,0,0x2b824fc0,380,"CALL_NON_FUNCTION_AS_CONSTRUCTOR native runtime.js:422",0x442258f4, +code-creation,LazyCompile,0,0x2b825140,288,"CALL_FUNCTION_PROXY native runtime.js:431",0x442259a0, +code-creation,LazyCompile,0,0x2b825260,260,"CALL_FUNCTION_PROXY_AS_CONSTRUCTOR native runtime.js:439",0x44225a38, +code-creation,LazyCompile,0,0x2b825380,912,"APPLY_PREPARE native runtime.js:446",0x44225acc, +code-creation,LazyCompile,0,0x2b825720,232,"APPLY_OVERFLOW native runtime.js:484",0x44225b9c, +code-creation,LazyCompile,0,0x2b825820,188,"TO_OBJECT native runtime.js:490",0x44225c38, +code-creation,LazyCompile,0,0x2b8258e0,188,"TO_NUMBER native runtime.js:496",0x44225cc0, +code-creation,LazyCompile,0,0x2b8259a0,188,"TO_STRING native runtime.js:502",0x44225d48, +code-creation,LazyCompile,0,0x2b825a60,600,"ToPrimitive native runtime.js:514",0x44225dd0, +code-creation,LazyCompile,0,0x2b825cc0,404,"ToBoolean native runtime.js:526",0x44225e60, +code-creation,LazyCompile,0,0x2b825e60,504,"ToNumber native runtime.js:536",0x44225eec, +code-creation,LazyCompile,0,0x2b826060,416,"ToString native runtime.js:561",0x44225fd8, +code-creation,LazyCompile,0,0x2b826200,220,"ToName native runtime.js:578",0x442260c4, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227108, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227168, +code-creation,LazyCompile,3,0x2b8262e0,77,"OpaqueReference",0x442271c8, +code-creation,LazyCompile,3,0x2b8262e0,77,"JSON",0x44227228, +code-creation,LazyCompile,0,0x2b8204a0,292,"Boolean",0x44227288, +code-creation,LazyCompile,3,0x2b82a080,83,"Array",0x442272e8, +code-creation,LazyCompile,3,0x2b826460,77,"pop",0x44227348, +code-creation,LazyCompile,3,0x2b826400,77,"push",0x442273a8, +code-creation,LazyCompile,3,0x2b826640,77,"concat",0x44227408, +code-creation,LazyCompile,3,0x2b8264c0,77,"shift",0x44227468, +code-creation,LazyCompile,3,0x2b826520,77,"unshift",0x442274c8, +code-creation,LazyCompile,3,0x2b826580,77,"slice",0x44227528, +code-creation,LazyCompile,3,0x2b8265e0,77,"splice",0x44227588, +code-creation,LazyCompile,0,0x2b8207a0,336,"Number",0x442275e8, +code-creation,LazyCompile,3,0x2b82a020,78,"InternalArray",0x44227648, +code-creation,LazyCompile,3,0x2b82a020,78,"InternalPackedArray",0x442276b4, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227714, +code-creation,LazyCompile,0,0x2b821a40,324,"RegExp",0x44227774, +code-creation,LazyCompile,0,0x2b81da80,1392,"Date",0x442277d4, +code-creation,LazyCompile,0,0x2b820ca0,440,"Function",0x44227834, +code-creation,LazyCompile,0,0x2b81d200,380,"String",0x44227894, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x442278f4, +code-creation,LazyCompile,0,0x2b81cf80,216,"Script",0x44227960, +code-creation,LazyCompile,0,0x2b81ff40,308,"Object",0x44227a00, +code-creation,LazyCompile,3,0x2b829d00,376,"call",0x44227a60, +code-creation,LazyCompile,3,0x2b829e80,388,"apply",0x44227ac0, +code-creation,LazyCompile,3,0x2b8262e0,77,"Arguments",0x44227b20, +code-creation,LazyCompile,3,0x2b826820,77,"ThrowTypeError",0x44227b80, +code-creation,LazyCompile,3,0x2b826760,77,"",0x44227be0, +code-creation,LazyCompile,3,0x2b8267c0,77,"",0x44227c40, +code-creation,LazyCompile,3,0x2b8262e0,77,"",0x44227ca0, +code-creation,Stub,2,0x2b81ef80,782,"CEntryStub" +code-creation,Stub,2,0x2b81f2a0,197,"StoreBufferOverflowStub" +code-creation,Stub,2,0x2b81f380,79,"StubFailureTrampolineStub" +code-creation,Stub,2,0x2b81f3e0,80,"StubFailureTrampolineStub" +tick,0xf776d430,16272,0,0x0,3 +timer-event-start,"V8.ParseLazy",16854 +timer-event-end,"V8.ParseLazy",17081 +timer-event-start,"V8.CompileLazy",17098 +timer-event-start,"V8.CompileFullCode",17125 +tick,0xf74c79de,17348,0,0xff820034,2 +code-creation,Stub,2,0x2b81b200,246,"FastCloneShallowObjectStub" +code-creation,Stub,12,0x2b81b300,88,"BinaryOpStub_ADD_Alloc_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b81b360,88,"BinaryOpStub_ADD_OverwriteLeft_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",17910 +code-creation,LazyCompile,0,0x2b81b3c0,572,"Instantiate native apinatives.js:44",0x44223cdc,~ +timer-event-end,"V8.CompileLazy",17948 +code-creation,Stub,13,0x2b81b600,116,"CompareICStub" +timer-event-start,"V8.ParseLazy",18020 +timer-event-end,"V8.ParseLazy",18170 +timer-event-start,"V8.CompileLazy",18187 +timer-event-start,"V8.CompileFullCode",18208 +code-creation,Stub,12,0x2b81b680,88,"BinaryOpStub_BIT_AND_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",18340 +code-creation,LazyCompile,0,0x2b82ae20,1008,"InstantiateFunction native apinatives.js:65",0x44223d3c, +timer-event-end,"V8.CompileLazy",18396 +tick,0xf776d430,18420,0,0x90d68fc,2,0x2b81b4f0 +code-creation,Stub,2,0x2b82b220,1800,"RecordWriteStub" +code-creation,Stub,2,0x2b82b940,236,"KeyedStoreElementStub" +code-creation,KeyedStoreIC,10,0x2b82ba40,91,"" +code-creation,CallIC,7,0x2b82baa0,129,"InstantiateFunction" +code-creation,LoadIC,5,0x2b82bb40,103,"kApiFunctionCache" +code-creation,Stub,12,0x2b82bbc0,146,"BinaryOpStub_BIT_AND_Alloc_Smi+Smi" +code-creation,Stub,15,0x2b82bc60,132,"ToBooleanStub(Smi)" +timer-event-start,"V8.ParseLazy",19172 +timer-event-end,"V8.ParseLazy",19253 +timer-event-start,"V8.CompileLazy",19268 +timer-event-start,"V8.CompileFullCode",19285 +timer-event-end,"V8.CompileFullCode",19350 +code-creation,LazyCompile,0,0x2b82bd00,753,"ConfigureTemplateInstance native apinatives.js:105",0x44223d9c, +timer-event-end,"V8.CompileLazy",19384 +tick,0x83c1620,19510,0,0xff81f92c,0,0x2b82b1de,0x2b81b4f0,0x2b81b576,0x2b82b0b8,0x2b81b4f0 +code-creation,Stub,2,0x2b82c000,208,"KeyedLoadElementStub" +code-creation,KeyedLoadIC,6,0x2b82c0e0,91,"" +code-creation,Stub,15,0x2b82c140,156,"ToBooleanStub(Undefined,SpecObject)" +code-creation,KeyedLoadIC,6,0x2b82c1e0,91,"" +code-creation,Stub,12,0x2b82c240,146,"BinaryOpStub_ADD_Alloc_Smi+Smi" +code-creation,Stub,15,0x2b82c2e0,168,"ToBooleanStub(Undefined,String)" +code-creation,CallIC,7,0x2b82c3a0,129,"ConfigureTemplateInstance" +code-creation,CallIC,7,0x2b82c440,129,"Instantiate" +code-creation,CallIC,7,0x2b82c4e0,144,"Instantiate" +code-creation,Stub,13,0x2b82c580,469,"CompareICStub" +code-creation,Stub,14,0x2b82c760,144,"CompareNilICStub(NullValue)(MonomorphicMap)" +code-creation,Stub,14,0x2b82c800,144,"CompareNilICStub(NullValue)(MonomorphicMap)" +tick,0x8132a60,20593,0,0x8141e5e,0,0x2b822c4e,0x2b82af24,0x2b81b4f0,0x2b82beff,0x2b81b59f,0x2b82beff,0x2b81b589,0x2b82b0b8,0x2b81b4f0 +code-creation,Stub,14,0x2b82c8a0,124,"CompareNilICStub(NullValue)(Undefined,Null,Undetectable,Generic)" +code-creation,Stub,13,0x2b82c920,156,"CompareICStub" +timer-event-start,"V8.ParseLazy",20736 +timer-event-end,"V8.ParseLazy",20818 +timer-event-start,"V8.CompileLazy",20838 +timer-event-start,"V8.CompileFullCode",20854 +code-creation,Stub,2,0x2b82c9c0,587,"FastCloneShallowArrayStub" +timer-event-end,"V8.CompileFullCode",21298 +code-creation,LazyCompile,0,0x2b82cc20,812,"DefaultNumber native runtime.js:645",0x44226390,~ +timer-event-end,"V8.CompileLazy",21330 +timer-event-start,"V8.ParseLazy",21352 +timer-event-end,"V8.ParseLazy",21381 +timer-event-start,"V8.CompileLazy",21393 +timer-event-start,"V8.CompileFullCode",21405 +timer-event-end,"V8.CompileFullCode",21436 +code-creation,LazyCompile,0,0x2b82cf60,184,"valueOf native v8natives.js:245",0x4421ee84,~ +timer-event-end,"V8.CompileLazy",21465 +timer-event-start,"V8.ParseLazy",21482 +timer-event-end,"V8.ParseLazy",21544 +timer-event-start,"V8.CompileLazy",21557 +timer-event-start,"V8.CompileFullCode",21571 +timer-event-end,"V8.CompileFullCode",21651 +code-creation,LazyCompile,0,0x2b82d020,652,"ToObject native runtime.js:584",0x44226150,~ +timer-event-end,"V8.CompileLazy",21690 +tick,0x80eabe2,21708,0,0xff81f7a8,2,0x2b82cfe4,0x2b82cd79,0x2b825c84,0x2b822ca7,0x2b82af24,0x2b81b4f0,0x2b82beff,0x2b81b59f,0x2b82beff,0x2b81b589,0x2b82b0b8,0x2b81b4f0 +timer-event-start,"V8.ParseLazy",21761 +timer-event-end,"V8.ParseLazy",21796 +timer-event-start,"V8.CompileLazy",21808 +timer-event-start,"V8.CompileFullCode",21820 +timer-event-end,"V8.CompileFullCode",21845 +code-creation,LazyCompile,0,0x2b82d2c0,220,"IsPrimitive native runtime.js:636",0x44226330,~ +timer-event-end,"V8.CompileLazy",21873 +timer-event-start,"V8.ParseLazy",21895 +timer-event-end,"V8.ParseLazy",21921 +timer-event-start,"V8.CompileLazy",21932 +timer-event-start,"V8.CompileFullCode",21946 +timer-event-end,"V8.CompileFullCode",21966 +code-creation,LazyCompile,0,0x2b82d3a0,184,"toString native v8natives.js:1721",0x44220834,~ +timer-event-end,"V8.CompileLazy",21994 +timer-event-start,"V8.ParseLazy",22009 +timer-event-end,"V8.ParseLazy",22087 +timer-event-start,"V8.CompileLazy",22101 +timer-event-start,"V8.CompileFullCode",22116 +timer-event-end,"V8.CompileFullCode",22221 +code-creation,LazyCompile,0,0x2b82d460,681,"FunctionSourceString native v8natives.js:1693",0x442207d4,~ +timer-event-end,"V8.CompileLazy",22237 +code-creation,Stub,15,0x2b82d720,156,"ToBooleanStub(String)" +code-creation,Stub,12,0x2b82d7c0,124,"BinaryOpStub_ADD_Alloc_String+String" +code-creation,Stub,12,0x2b82d840,124,"BinaryOpStub_ADD_OverwriteLeft_String+String" +code-creation,CallMiss,7,0x2b82d8c0,178,"args_count: 2" +code-creation,CallIC,7,0x2b82d980,128,"ToPrimitive" +code-creation,CallIC,7,0x2b82da00,128,"DefaultNumber" +code-creation,Stub,2,0x2b82da80,116,"valueOf" +code-creation,LoadIC,5,0x2b82db00,93,"valueOf" +code-creation,CallIC,7,0x2b82db60,129,"ToObject" +code-creation,CallIC,7,0x2b82dc00,128,"IsPrimitive" +code-creation,Stub,2,0x2b82dc80,98,"toString" +code-creation,LoadIC,5,0x2b82dd00,93,"toString" +code-creation,CallIC,7,0x2b82dd60,129,"FunctionSourceString" +code-creation,CallIC,7,0x2b82de00,128,"ToNumber" +timer-event-start,"V8.Parse",22650 +tick,0xf776d430,22726,0,0x0,2 +timer-event-end,"V8.Parse",22773 +timer-event-start,"V8.Compile",22785 +timer-event-start,"V8.CompileFullCode",22801 +timer-event-end,"V8.CompileFullCode",22822 +code-creation,Script,0,0x2b82de80,264,"native arraybuffer.js",0x4423ab7c,~ +timer-event-end,"V8.Compile",22836 +timer-event-start,"V8.ParseLazy",22859 +timer-event-end,"V8.ParseLazy",22881 +timer-event-start,"V8.CompileLazy",22887 +timer-event-start,"V8.CompileFullCode",22899 +timer-event-end,"V8.CompileFullCode",22918 +code-creation,LazyCompile,0,0x2b82dfa0,480,"SetUpArrayBuffer native arraybuffer.js:84",0x4423aac0,~ +timer-event-end,"V8.CompileLazy",22934 +timer-event-start,"V8.ParseLazy",22943 +timer-event-end,"V8.ParseLazy",22962 +timer-event-start,"V8.CompileLazy",22967 +timer-event-start,"V8.CompileFullCode",22972 +timer-event-end,"V8.CompileFullCode",22987 +code-creation,LazyCompile,0,0x2b82e180,324,"ArrayBufferConstructor native arraybuffer.js:34",0x4423a9a0,~ +timer-event-end,"V8.CompileLazy",23000 +code-creation,LazyCompile,0,0x2b82e180,324,"ArrayBufferConstructor native arraybuffer.js:34",0x4423a9a0, +timer-event-start,"V8.ParseLazy",23021 +timer-event-end,"V8.ParseLazy",23037 +timer-event-start,"V8.CompileLazy",23042 +timer-event-start,"V8.CompileFullCode",23047 +timer-event-end,"V8.CompileFullCode",23057 +code-creation,LazyCompile,0,0x2b82e2e0,252,"InstallGetter native v8natives.js:63",0x4421e9bc,~ +timer-event-end,"V8.CompileLazy",23069 +code-creation,KeyedLoadIC,6,0x2b82e3e0,91,"" +code-creation,LoadIC,5,0x2b82e440,93,"length" +timer-event-start,"V8.Parse",23160 +timer-event-end,"V8.Parse",23613 +timer-event-start,"V8.Compile",23621 +timer-event-start,"V8.CompileFullCode",23666 +timer-event-end,"V8.CompileFullCode",23702 +code-creation,Script,0,0x2b82e4a0,720,"native typedarray.js",0x4423bc04,~ +timer-event-end,"V8.Compile",23724 +timer-event-start,"V8.ParseLazy",23755 +tick,0xf776d430,23782,0,0x0,2 +timer-event-end,"V8.ParseLazy",23867 +timer-event-start,"V8.CompileLazy",23905 +timer-event-start,"V8.CompileFullCode",23916 +timer-event-end,"V8.CompileFullCode",23939 +code-creation,LazyCompile,0,0x2b82e780,664,"SetupTypedArray native typedarray.js:170",0x4423b238,~ +timer-event-end,"V8.CompileLazy",23971 +timer-event-start,"V8.ParseLazy",23979 +timer-event-end,"V8.ParseLazy",24064 +timer-event-start,"V8.CompileLazy",24071 +timer-event-start,"V8.CompileFullCode",24085 +code-creation,Stub,2,0x2b82ea20,175,"FastNewContextStub" +code-creation,Stub,2,0x2b82eae0,304,"FastNewClosureStub" +code-creation,Stub,2,0x2b82ec20,1448,"RecordWriteStub" +timer-event-end,"V8.CompileFullCode",24149 +code-creation,LazyCompile,0,0x2b82f1e0,460,"CreateTypedArrayConstructor native typedarray.js:38",0x4423af98,~ +timer-event-end,"V8.CompileLazy",24163 +timer-event-start,"V8.ParseLazy",24170 +timer-event-end,"V8.ParseLazy",24198 +timer-event-start,"V8.CompileLazy",24203 +timer-event-start,"V8.CompileFullCode",24211 +code-creation,Stub,2,0x2b82f3c0,331,"CallFunctionStub_Args4_Recording" +code-creation,Stub,2,0x2b82f520,631,"FastCloneShallowArrayStub" +code-creation,Stub,2,0x2b82f7a0,245,"StoreArrayLiteralElementStub" +timer-event-end,"V8.CompileFullCode",24435 +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580,~ +timer-event-end,"V8.CompileLazy",24448 +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +timer-event-start,"V8.ParseLazy",24478 +timer-event-end,"V8.ParseLazy",24519 +timer-event-start,"V8.CompileLazy",24525 +timer-event-start,"V8.CompileFullCode",24533 +timer-event-end,"V8.CompileFullCode",24546 +code-creation,LazyCompile,0,0x2b82fbe0,268,"CreateSubArray native typedarray.js:121",0x4423b178,~ +timer-event-end,"V8.CompileLazy",24559 +code-creation,CallMiss,7,0x2b82fd00,180,"args_count: 4" +code-creation,CallIC,7,0x2b82fdc0,129,"CreateTypedArrayConstructor" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b82fe60,103,"$Object" +code-creation,LoadIC,5,0x2b82fee0,103,"TypedArrayGetBuffer" +code-creation,CallMiss,7,0x2b82ff60,180,"args_count: 3" +code-creation,CallIC,7,0x2b830020,129,"InstallGetter" +code-creation,LoadIC,5,0x2b8300c0,103,"TypedArrayGetByteOffset" +code-creation,LoadIC,5,0x2b830140,103,"TypedArrayGetByteLength" +code-creation,LoadIC,5,0x2b8301c0,103,"TypedArrayGetLength" +code-creation,CallIC,7,0x2b830240,129,"CreateSubArray" +code-creation,LoadIC,5,0x2b8302e0,103,"TypedArraySet" +code-creation,CallIC,7,0x2b830360,133,"$Array" +code-creation,CallIC,7,0x2b830400,129,"InstallFunctions" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +tick,0xf7492ece,24846,0,0xff81ff10,0,0x2b82e839,0x2b82e5f9 +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +timer-event-start,"V8.ParseLazy",25032 +timer-event-end,"V8.ParseLazy",25074 +timer-event-start,"V8.CompileLazy",25081 +timer-event-start,"V8.CompileFullCode",25093 +timer-event-end,"V8.CompileFullCode",25115 +code-creation,LazyCompile,0,0x2b8304a0,888,"SetupDataView native typedarray.js:434",0x4423ba78,~ +timer-event-end,"V8.CompileLazy",25128 +timer-event-start,"V8.ParseLazy",25136 +timer-event-end,"V8.ParseLazy",25175 +timer-event-start,"V8.CompileLazy",25181 +timer-event-start,"V8.CompileFullCode",25188 +code-creation,Stub,12,0x2b830820,88,"BinaryOpStub_SUB_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",25228 +code-creation,LazyCompile,0,0x2b830880,908,"DataViewConstructor native typedarray.js:209",0x4423b298,~ +timer-event-end,"V8.CompileLazy",25241 +code-creation,LazyCompile,0,0x2b830880,908,"DataViewConstructor native typedarray.js:209",0x4423b298, +code-creation,KeyedStorePolymorphicIC,10,0x2b830c20,101,"" +code-creation,KeyedStorePolymorphicIC,10,0x2b830c20,101,"args_count: 0" +code-creation,CallIC,7,0x2b830ca0,144,"Instantiate" +code-creation,CallIC,7,0x2b830d40,129,"InstantiateFunction" +code-creation,LoadIC,5,0x2b830de0,103,"kApiFunctionCache" +code-creation,KeyedLoadPolymorphicIC,6,0x2b830e60,105,"" +code-creation,CallIC,7,0x2b830ee0,129,"ConfigureTemplateInstance" +code-creation,CallIC,7,0x2b830f80,129,"Instantiate" +code-creation,Stub,2,0x2b831020,116,"valueOf" +code-creation,LoadPolymorphicIC,5,0x2b8310a0,105,"valueOf" +code-creation,Stub,2,0x2b831120,98,"toString" +code-creation,LoadPolymorphicIC,5,0x2b8311a0,105,"toString" +code-creation,CallIC,7,0x2b831220,128,"ToPrimitive" +code-creation,CallIC,7,0x2b8312a0,128,"DefaultNumber" +code-creation,CallIC,7,0x2b831320,129,"ToObject" +code-creation,CallIC,7,0x2b8313c0,128,"IsPrimitive" +code-creation,CallIC,7,0x2b831440,129,"FunctionSourceString" +code-creation,CallIC,7,0x2b8314e0,128,"ToNumber" +tick,0xf776d430,25914,0,0x90ec418,0,0x2b82cda7,0x2b825c84,0x2b822ca7,0x2b82af24,0x2b81b4f0,0x2b82beff,0x2b81b59f,0x2b82beff,0x2b81b589,0x2b82b0b8,0x2b81b4f0 +timer-event-start,"V8.ParseLazy",25965 +timer-event-end,"V8.ParseLazy",25985 +timer-event-start,"V8.CompileLazy",25991 +timer-event-start,"V8.RecompileSynchronous",25996 +code-creation,LazyCompile,0,0x2b831560,184,"valueOf native v8natives.js:245",0x4421ee84,~ +timer-event-end,"V8.RecompileSynchronous",26121 +code-creation,LazyCompile,1,0x2b831620,180,"valueOf native v8natives.js:245",0x4421ee84,* +timer-event-end,"V8.CompileLazy",26138 +timer-event-start,"V8.ParseLazy",26144 +timer-event-end,"V8.ParseLazy",26156 +timer-event-start,"V8.CompileLazy",26161 +timer-event-start,"V8.RecompileSynchronous",26166 +code-creation,LazyCompile,0,0x2b8316e0,220,"IsPrimitive native runtime.js:636",0x44226330,~ +timer-event-end,"V8.RecompileSynchronous",26250 +code-creation,LazyCompile,1,0x2b8317c0,170,"IsPrimitive native runtime.js:636",0x44226330,* +timer-event-end,"V8.CompileLazy",26266 +timer-event-start,"V8.ParseLazy",26271 +timer-event-end,"V8.ParseLazy",26282 +timer-event-start,"V8.CompileLazy",26286 +timer-event-start,"V8.RecompileSynchronous",26291 +code-creation,LazyCompile,0,0x2b831880,184,"toString native v8natives.js:1721",0x44220834,~ +timer-event-end,"V8.RecompileSynchronous",26361 +code-creation,LazyCompile,1,0x2b831940,180,"toString native v8natives.js:1721",0x44220834,* +timer-event-end,"V8.CompileLazy",26376 +code-creation,LoadIC,5,0x2b831a00,103,"global" +code-creation,LoadIC,5,0x2b831a80,114,"ArrayBuffer" +code-creation,CallMiss,7,0x2b831b00,180,"args_count: 0" +code-creation,CallIC,7,0x2b831bc0,129,"SetUpArrayBuffer" +code-creation,LoadIC,5,0x2b831c60,103,"$ArrayBuffer" +code-creation,LoadIC,5,0x2b831ce0,103,"ArrayBufferConstructor" +code-creation,LazyCompile,0,0x2b82e180,324,"ArrayBufferConstructor native arraybuffer.js:34",0x4423a9a0, +code-creation,LoadIC,5,0x2b831d60,103,"$Object" +code-creation,LoadIC,5,0x2b831de0,103,"ArrayBufferGetByteLength" +code-creation,CallIC,7,0x2b831e60,129,"InstallGetter" +code-creation,LoadIC,5,0x2b831f00,103,"ArrayBufferSlice" +code-creation,CallIC,7,0x2b831f80,133,"$Array" +code-creation,CallIC,7,0x2b832020,129,"InstallFunctions" +code-creation,LoadPolymorphicIC,5,0x2b8320c0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b832140,105,"length" +code-creation,KeyedLoadPolymorphicIC,6,0x2b8321c0,105,"" +code-creation,LoadIC,5,0x2b832240,114,"Uint8Array" +code-creation,CallIC,7,0x2b8322c0,129,"SetupTypedArray" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832360,103,"$Object" +code-creation,LoadIC,5,0x2b8323e0,114,"Int8Array" +code-creation,CallIC,7,0x2b832460,129,"CreateTypedArrayConstructor" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832500,103,"TypedArrayGetBuffer" +code-creation,LoadIC,5,0x2b832580,103,"TypedArrayGetByteOffset" +code-creation,LoadIC,5,0x2b832600,103,"TypedArrayGetByteLength" +code-creation,LoadIC,5,0x2b832680,103,"TypedArrayGetLength" +code-creation,CallIC,7,0x2b832700,129,"CreateSubArray" +code-creation,LoadIC,5,0x2b8327a0,103,"TypedArraySet" +code-creation,CallIC,7,0x2b832820,133,"$Array" +code-creation,LoadIC,5,0x2b8328c0,114,"Uint16Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +tick,0xf776d430,26979,0,0x90ec418,0,0x2b82e9b7,0x2b82e593 +code-creation,LoadIC,5,0x2b832940,114,"Int16Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b8329c0,114,"Uint32Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832a40,114,"Int32Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832ac0,114,"Float32Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832b40,114,"Float64Array" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832bc0,114,"Uint8ClampedArray" +code-creation,LazyCompile,0,0x2b82f8a0,824," native typedarray.js:88",0x4423c580, +code-creation,LoadIC,5,0x2b832c40,114,"DataView" +code-creation,CallIC,7,0x2b832cc0,129,"SetupDataView" +code-creation,LoadIC,5,0x2b832d60,103,"$DataView" +code-creation,LoadIC,5,0x2b832de0,103,"DataViewConstructor" +code-creation,LazyCompile,0,0x2b830880,908,"DataViewConstructor native typedarray.js:209",0x4423b298, +code-creation,LoadIC,5,0x2b832e60,103,"DataViewGetBuffer" +code-creation,LoadIC,5,0x2b832ee0,103,"DataViewGetByteOffset" +code-creation,LoadIC,5,0x2b832f60,103,"DataViewGetByteLength" +code-creation,LoadIC,5,0x2b832fe0,103,"DataViewGetInt8" +code-creation,LoadIC,5,0x2b833060,103,"DataViewSetInt8" +code-creation,LoadIC,5,0x2b8330e0,103,"DataViewGetUint8" +code-creation,LoadIC,5,0x2b833160,103,"DataViewSetUint8" +code-creation,LoadIC,5,0x2b8331e0,103,"DataViewGetInt16" +code-creation,LoadIC,5,0x2b833260,103,"DataViewSetInt16" +code-creation,LoadIC,5,0x2b8332e0,103,"DataViewGetUint16" +code-creation,LoadIC,5,0x2b833360,103,"DataViewSetUint16" +code-creation,LoadIC,5,0x2b8333e0,103,"DataViewGetInt32" +code-creation,LoadIC,5,0x2b833460,103,"DataViewSetInt32" +code-creation,LoadIC,5,0x2b8334e0,103,"DataViewGetUint32" +code-creation,LoadIC,5,0x2b833560,103,"DataViewSetUint32" +code-creation,LoadIC,5,0x2b8335e0,103,"DataViewGetFloat32" +code-creation,LoadIC,5,0x2b833660,103,"DataViewSetFloat32" +code-creation,LoadIC,5,0x2b8336e0,103,"DataViewGetFloat64" +code-creation,LoadIC,5,0x2b833760,103,"DataViewSetFloat64" +code-creation,CallMiss,7,0x2b8337e0,189,"args_count: 32" +code-creation,CallIC,7,0x2b8338a0,136,"$Array" +code-creation,LoadIC,5,0x2b833940,93,"length" +timer-event-start,"V8.Parse",28734 +timer-event-start,"V8.PreParse",28760 +timer-event-end,"V8.PreParse",28785 +timer-event-start,"V8.PreParse",28796 +timer-event-end,"V8.PreParse",28803 +timer-event-start,"V8.PreParse",28810 +timer-event-end,"V8.PreParse",28817 +timer-event-start,"V8.PreParse",28828 +timer-event-end,"V8.PreParse",28862 +timer-event-start,"V8.PreParse",28872 +timer-event-end,"V8.PreParse",28878 +timer-event-start,"V8.PreParse",28884 +timer-event-end,"V8.PreParse",28890 +timer-event-start,"V8.PreParse",28905 +timer-event-end,"V8.PreParse",28931 +timer-event-start,"V8.PreParse",28938 +timer-event-end,"V8.PreParse",28970 +timer-event-start,"V8.PreParse",28980 +timer-event-end,"V8.PreParse",28989 +timer-event-start,"V8.PreParse",28995 +timer-event-end,"V8.PreParse",29005 +timer-event-start,"V8.PreParse",29012 +timer-event-end,"V8.PreParse",29019 +timer-event-start,"V8.PreParse",29026 +timer-event-end,"V8.PreParse",29045 +timer-event-start,"V8.PreParse",29052 +timer-event-end,"V8.PreParse",29059 +timer-event-start,"V8.PreParse",29066 +timer-event-end,"V8.PreParse",29072 +timer-event-start,"V8.PreParse",29078 +timer-event-end,"V8.PreParse",29087 +tick,0xf776d430,29099,0,0x0,2 +timer-event-start,"V8.PreParse",29187 +timer-event-end,"V8.PreParse",29241 +timer-event-start,"V8.PreParse",29253 +timer-event-end,"V8.PreParse",29261 +timer-event-start,"V8.PreParse",29274 +timer-event-end,"V8.PreParse",29286 +timer-event-start,"V8.PreParse",29293 +timer-event-end,"V8.PreParse",29305 +timer-event-start,"V8.PreParse",29314 +timer-event-end,"V8.PreParse",29324 +timer-event-start,"V8.PreParse",29331 +timer-event-end,"V8.PreParse",29344 +timer-event-start,"V8.PreParse",29355 +timer-event-end,"V8.PreParse",29369 +timer-event-start,"V8.PreParse",29375 +timer-event-end,"V8.PreParse",29391 +timer-event-start,"V8.PreParse",29400 +timer-event-end,"V8.PreParse",29408 +timer-event-start,"V8.PreParse",29416 +timer-event-end,"V8.PreParse",29422 +timer-event-start,"V8.PreParse",29435 +timer-event-end,"V8.PreParse",29442 +timer-event-start,"V8.PreParse",29448 +timer-event-end,"V8.PreParse",29461 +timer-event-start,"V8.PreParse",29467 +timer-event-end,"V8.PreParse",29480 +timer-event-start,"V8.PreParse",29489 +timer-event-end,"V8.PreParse",29508 +timer-event-start,"V8.PreParse",29516 +timer-event-end,"V8.PreParse",29547 +timer-event-start,"V8.PreParse",29561 +timer-event-end,"V8.PreParse",29579 +timer-event-start,"V8.PreParse",29587 +timer-event-end,"V8.PreParse",29605 +timer-event-start,"V8.PreParse",29613 +timer-event-end,"V8.PreParse",29639 +timer-event-start,"V8.PreParse",29646 +timer-event-end,"V8.PreParse",29667 +timer-event-start,"V8.PreParse",29677 +timer-event-end,"V8.PreParse",29702 +timer-event-start,"V8.PreParse",29709 +timer-event-end,"V8.PreParse",29735 +timer-event-start,"V8.PreParse",29741 +timer-event-end,"V8.PreParse",29758 +timer-event-start,"V8.PreParse",29764 +timer-event-end,"V8.PreParse",29773 +timer-event-start,"V8.PreParse",29781 +timer-event-end,"V8.PreParse",29796 +timer-event-start,"V8.PreParse",29805 +timer-event-end,"V8.PreParse",29813 +timer-event-start,"V8.PreParse",29821 +timer-event-end,"V8.PreParse",29839 +timer-event-start,"V8.PreParse",29847 +timer-event-end,"V8.PreParse",29861 +timer-event-start,"V8.PreParse",29868 +timer-event-end,"V8.PreParse",29873 +timer-event-start,"V8.PreParse",29880 +timer-event-end,"V8.PreParse",29908 +timer-event-start,"V8.PreParse",29914 +timer-event-end,"V8.PreParse",29923 +timer-event-start,"V8.PreParse",29930 +timer-event-end,"V8.PreParse",29937 +timer-event-start,"V8.PreParse",29944 +timer-event-end,"V8.PreParse",29955 +timer-event-start,"V8.PreParse",29960 +timer-event-end,"V8.PreParse",29970 +timer-event-start,"V8.PreParse",29977 +timer-event-end,"V8.PreParse",29982 +timer-event-start,"V8.PreParse",29989 +timer-event-end,"V8.PreParse",29999 +timer-event-start,"V8.PreParse",30031 +timer-event-end,"V8.PreParse",30041 +timer-event-start,"V8.PreParse",30047 +timer-event-end,"V8.PreParse",30054 +timer-event-start,"V8.PreParse",30060 +timer-event-end,"V8.PreParse",30069 +timer-event-start,"V8.PreParse",30080 +timer-event-end,"V8.PreParse",30106 +timer-event-start,"V8.PreParse",30113 +timer-event-end,"V8.PreParse",30121 +timer-event-start,"V8.PreParse",30127 +timer-event-end,"V8.PreParse",30133 +timer-event-start,"V8.PreParse",30139 +timer-event-end,"V8.PreParse",30148 +tick,0x825e06c,30162,0,0x0,2 +timer-event-start,"V8.PreParse",30217 +timer-event-end,"V8.PreParse",30285 +timer-event-start,"V8.PreParse",30293 +timer-event-end,"V8.PreParse",30319 +timer-event-start,"V8.PreParse",30326 +timer-event-end,"V8.PreParse",30344 +timer-event-start,"V8.PreParse",30350 +timer-event-end,"V8.PreParse",30367 +timer-event-start,"V8.PreParse",30374 +timer-event-end,"V8.PreParse",30385 +timer-event-start,"V8.PreParse",30392 +timer-event-end,"V8.PreParse",30400 +timer-event-start,"V8.PreParse",30407 +timer-event-end,"V8.PreParse",30415 +timer-event-start,"V8.PreParse",30429 +timer-event-end,"V8.PreParse",30446 +timer-event-start,"V8.PreParse",30456 +timer-event-end,"V8.PreParse",30461 +timer-event-start,"V8.PreParse",30469 +timer-event-end,"V8.PreParse",30480 +timer-event-start,"V8.PreParse",30488 +timer-event-end,"V8.PreParse",30497 +timer-event-start,"V8.PreParse",30503 +timer-event-end,"V8.PreParse",30511 +timer-event-start,"V8.PreParse",30517 +timer-event-end,"V8.PreParse",30528 +timer-event-start,"V8.PreParse",30535 +timer-event-end,"V8.PreParse",30539 +timer-event-start,"V8.PreParse",30546 +timer-event-end,"V8.PreParse",30550 +timer-event-start,"V8.PreParse",30568 +timer-event-end,"V8.PreParse",30577 +timer-event-start,"V8.PreParse",30586 +timer-event-end,"V8.PreParse",30591 +timer-event-start,"V8.PreParse",30600 +timer-event-end,"V8.PreParse",30610 +timer-event-start,"V8.PreParse",30616 +timer-event-end,"V8.PreParse",30621 +timer-event-start,"V8.PreParse",30630 +timer-event-end,"V8.PreParse",30638 +timer-event-start,"V8.PreParse",30649 +timer-event-end,"V8.PreParse",30665 +timer-event-start,"V8.PreParse",30672 +timer-event-end,"V8.PreParse",30682 +timer-event-start,"V8.PreParse",30692 +timer-event-end,"V8.PreParse",30706 +timer-event-start,"V8.PreParse",30719 +timer-event-end,"V8.PreParse",30730 +timer-event-start,"V8.PreParse",30737 +timer-event-end,"V8.PreParse",30749 +tick,0x82b07f6,31208,0,0x0,2 +tick,0x824d3ad,32274,0,0x0,2 +tick,0x82b07c6,33327,0,0x0,2 +tick,0x82b0804,34401,0,0x0,2 +tick,0x81fc62c,35474,0,0x0,2 +tick,0x81fc62c,36534,0,0x0,2 +tick,0x824e954,37593,0,0x0,2 +tick,0x82b07f3,38662,0,0x0,2 +tick,0x81fc625,39722,0,0x0,2 +tick,0x81fc61e,40783,0,0x0,2 +tick,0x821c1a1,41846,0,0x0,2 +tick,0x81fc62c,42913,0,0x0,2 +timer-event-start,"V8.PreParse",43415 +timer-event-end,"V8.PreParse",43428 +timer-event-start,"V8.PreParse",43446 +timer-event-end,"V8.PreParse",43481 +timer-event-end,"V8.Parse",43493 +timer-event-start,"V8.Compile",43498 +timer-event-start,"V8.CompileFullCode",43528 +timer-event-end,"V8.CompileFullCode",43671 +code-creation,Script,0,0x2b8339a0,6060,"bsuite/kraken-once/stanford-crypto-ccm.js",0x2f33b684,~ +timer-event-end,"V8.Compile",43688 +timer-event-start,"V8.Execute",43739 +timer-event-start,"V8.ParseLazy",43914 +timer-event-end,"V8.ParseLazy",43936 +timer-event-start,"V8.CompileLazy",43942 +timer-event-start,"V8.CompileFullCode",43947 +timer-event-end,"V8.CompileFullCode",43966 +tick,0x820b498,43978,0,0x0,0,0x2b83464f +code-creation,LazyCompile,0,0x2b835160,372,"sjcl.hash.sha256 bsuite/kraken-once/stanford-crypto-ccm.js:15",0x2f339fb0,~ +timer-event-end,"V8.CompileLazy",44194 +code-creation,Stub,2,0x2b8352e0,188,"KeyedLoadElementStub" +code-creation,KeyedLoadIC,6,0x2b8353a0,91,"" +code-creation,CallPreMonomorphic,7,0x2b835400,178,"args_count: 0" +timer-event-start,"V8.ParseLazy",44292 +timer-event-end,"V8.ParseLazy",44326 +timer-event-start,"V8.CompileLazy",44333 +timer-event-start,"V8.CompileFullCode",44340 +code-creation,Stub,12,0x2b8354c0,88,"BinaryOpStub_MOD_Alloc_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b835520,88,"BinaryOpStub_MUL_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",44389 +code-creation,LazyCompile,0,0x2b835580,906,"sjcl.hash.sha256.w bsuite/kraken-once/stanford-crypto-ccm.js:17",0x2f33a190,~ +timer-event-end,"V8.CompileLazy",44407 +code-creation,Stub,12,0x2b835920,167,"BinaryOpStub_MUL_Alloc_Smi+Smi" +code-creation,Stub,13,0x2b8359e0,122,"CompareICStub" +timer-event-start,"V8.ParseLazy",44439 +timer-event-end,"V8.ParseLazy",44460 +timer-event-start,"V8.CompileLazy",44465 +timer-event-start,"V8.CompileFullCode",44471 +code-creation,Stub,2,0x2b835a60,501,"MathPowStub" +timer-event-end,"V8.CompileFullCode",44505 +code-creation,LazyCompile,0,0x2b835c60,304,"pow native math.js:181",0x4422259c,~ +timer-event-end,"V8.CompileLazy",44517 +timer-event-start,"V8.ParseLazy",44522 +timer-event-end,"V8.ParseLazy",44534 +timer-event-start,"V8.CompileLazy",44539 +timer-event-start,"V8.CompileFullCode",44545 +code-creation,Stub,12,0x2b835da0,88,"BinaryOpStub_MUL_OverwriteLeft_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b835e00,88,"BinaryOpStub_BIT_OR_OverwriteLeft_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",44570 +code-creation,LazyCompile,0,0x2b835e60,228,"a bsuite/kraken-once/stanford-crypto-ccm.js:17",0x2f33d150,~ +timer-event-end,"V8.CompileLazy",44582 +timer-event-start,"V8.ParseLazy",44590 +timer-event-end,"V8.ParseLazy",44609 +timer-event-start,"V8.CompileLazy",44614 +timer-event-start,"V8.CompileFullCode",44619 +code-creation,Stub,12,0x2b835f60,88,"BinaryOpStub_SHR_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",44646 +code-creation,LazyCompile,0,0x2b835fc0,344,"floor native math.js:99",0x4422241c,~ +timer-event-end,"V8.CompileLazy",44657 +code-creation,Stub,13,0x2b836120,404,"CompareICStub" +code-creation,Stub,13,0x2b8362c0,232,"CompareICStub" +code-creation,Stub,13,0x2b8363c0,404,"CompareICStub" +code-creation,Stub,13,0x2b836560,240,"CompareICStub" +code-creation,Stub,12,0x2b836660,349,"BinaryOpStub_SHR_Alloc_Number+Smi" +code-creation,Stub,12,0x2b8367c0,246,"BinaryOpStub_SUB_Alloc_Number+Smi" +code-creation,Stub,12,0x2b8368c0,245,"BinaryOpStub_MUL_OverwriteLeft_Number+Number" +code-creation,Stub,12,0x2b8369c0,407,"BinaryOpStub_BIT_OR_OverwriteLeft_Number+Smi" +code-creation,Stub,2,0x2b836b60,1808,"RecordWriteStub" +code-creation,Stub,2,0x2b837280,606,"KeyedStoreElementStub" +code-creation,KeyedStoreIC,10,0x2b8374e0,91,"" +tick,0x31e6020f,45036,0,0x2b836b61,0,0x2b8357c1,0x2b835208,0x2b83464f +code-creation,LoadIC,5,0x2b837540,114,"Math" +code-creation,CallIC,7,0x2b8375c0,289,"floor" +code-creation,Stub,2,0x2b837700,80,"LoadFieldStub" +code-creation,Stub,2,0x2b837760,95,"N" +code-creation,LoadIC,5,0x2b8377c0,93,"N" +code-creation,CallIC,7,0x2b837820,113,"pow" +code-creation,Stub,2,0x2b8378a0,80,"LoadFieldStub" +code-creation,Stub,2,0x2b837900,95,"a" +code-creation,LoadIC,5,0x2b837960,93,"a" +code-creation,Stub,12,0x2b8379c0,190,"BinaryOpStub_MOD_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b837a80,181,"BinaryOpStub_MOD_Alloc_Smi+Smi" +timer-event-start,"V8.ParseLazy",45383 +timer-event-end,"V8.ParseLazy",45402 +timer-event-start,"V8.CompileLazy",45408 +timer-event-start,"V8.CompileFullCode",45413 +timer-event-end,"V8.CompileFullCode",45428 +code-creation,LazyCompile,0,0x2b837b40,264,"sjcl.hash.sha256.reset bsuite/kraken-once/stanford-crypto-ccm.js:16",0x2f33a070,~ +timer-event-end,"V8.CompileLazy",45442 +code-creation,StoreIC,9,0x2b837c60,138,"codec" +code-creation,StoreIC,9,0x2b837d00,141,"hex" +tick,0x8294f6f,46096,0,0xff820124,0,0x2b834ff0 +code-creation,StoreIC,9,0x2b837da0,171,"ccm" +timer-event-start,"V8.ParseLazy",46605 +timer-event-end,"V8.ParseLazy",46625 +timer-event-start,"V8.CompileLazy",46630 +timer-event-start,"V8.CompileFullCode",46635 +timer-event-end,"V8.CompileFullCode",46649 +code-creation,LazyCompile,0,0x2b837e60,300,"sjcl.test.TestCase bsuite/kraken-once/stanford-crypto-ccm.js:99",0x2f33b210,~ +timer-event-end,"V8.CompileLazy",46663 +timer-event-start,"V8.ParseLazy",46681 +timer-event-end,"V8.ParseLazy",46712 +timer-event-start,"V8.CompileLazy",46718 +timer-event-start,"V8.CompileFullCode",46725 +code-creation,CallInitialize,7,0x2b837fa0,178,"args_count: 4" +timer-event-end,"V8.CompileFullCode",46771 +code-creation,LazyCompile,0,0x2b838060,953,"sjcl.test.run bsuite/kraken-once/stanford-crypto-ccm.js:180",0x2f33b4b0,~ +timer-event-end,"V8.CompileLazy",46788 +code-creation,Stub,13,0x2b838420,485,"CompareICStub" +code-creation,CallIC,7,0x2b838620,128,"ToString" +code-creation,CallPreMonomorphic,7,0x2b8386a0,178,"args_count: 4" +timer-event-start,"V8.ParseLazy",46859 +timer-event-end,"V8.ParseLazy",46876 +timer-event-start,"V8.CompileLazy",46881 +timer-event-start,"V8.CompileFullCode",46888 +code-creation,CallInitialize,7,0x2b838760,178,"args_count: 5" +timer-event-end,"V8.CompileFullCode",46910 +code-creation,LazyCompile,0,0x2b838820,320,"browserUtil.cpsMap bsuite/kraken-once/stanford-crypto-ccm.js:63",0x2f33b030,~ +timer-event-end,"V8.CompileLazy",46922 +code-creation,CallPreMonomorphic,7,0x2b838960,178,"args_count: 5" +timer-event-start,"V8.ParseLazy",46937 +timer-event-end,"V8.ParseLazy",46959 +timer-event-start,"V8.CompileLazy",46965 +timer-event-start,"V8.CompileFullCode",46972 +code-creation,Stub,2,0x2b838a20,172,"FastNewContextStub" +timer-event-end,"V8.CompileFullCode",46995 +code-creation,LazyCompile,0,0x2b838ae0,420,"browserUtil.cpsIterate bsuite/kraken-once/stanford-crypto-ccm.js:49",0x2f33afd0,~ +timer-event-end,"V8.CompileLazy",47008 +timer-event-start,"V8.ParseLazy",47013 +timer-event-end,"V8.ParseLazy",47029 +timer-event-start,"V8.CompileLazy",47034 +timer-event-start,"V8.CompileFullCode",47041 +code-creation,Stub,2,0x2b838ca0,328,"CallFunctionStub_Args0_Recording" +timer-event-end,"V8.CompileFullCode",47070 +code-creation,LazyCompile,0,0x2b838e00,372,"go bsuite/kraken-once/stanford-crypto-ccm.js:50",0x2f33da7c,~ +timer-event-end,"V8.CompileLazy",47082 +timer-event-start,"V8.ParseLazy",47088 +timer-event-end,"V8.ParseLazy",47110 +timer-event-start,"V8.CompileLazy",47115 +timer-event-start,"V8.CompileFullCode",47121 +timer-event-end,"V8.CompileFullCode",47134 +code-creation,LazyCompile,0,0x2b838f80,236," bsuite/kraken-once/stanford-crypto-ccm.js:64",0x2f33d9d4,~ +timer-event-end,"V8.CompileLazy",47146 +tick,0xf776d430,47160,0,0x90ec418,2,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,KeyedLoadIC,6,0x2b839080,91,"" +timer-event-start,"V8.ParseLazy",47296 +timer-event-end,"V8.ParseLazy",47317 +timer-event-start,"V8.CompileLazy",47323 +timer-event-start,"V8.CompileFullCode",47329 +code-creation,CallInitialize,7,0x2b8390e0,178,"args_count: 3" +timer-event-end,"V8.CompileFullCode",47355 +code-creation,LazyCompile,0,0x2b8391a0,260," bsuite/kraken-once/stanford-crypto-ccm.js:192",0x2f33d920,~ +timer-event-end,"V8.CompileLazy",47368 +code-creation,CallPreMonomorphic,7,0x2b8392c0,178,"args_count: 3" +timer-event-start,"V8.ParseLazy",47390 +timer-event-end,"V8.ParseLazy",47409 +timer-event-start,"V8.CompileLazy",47415 +timer-event-start,"V8.CompileFullCode",47421 +timer-event-end,"V8.CompileFullCode",47438 +code-creation,LazyCompile,0,0x2b839380,344,"sjcl.test.TestCase.run bsuite/kraken-once/stanford-crypto-ccm.js:168",0x2f33b450,~ +timer-event-end,"V8.CompileLazy",47452 +timer-event-start,"V8.ParseLazy",47462 +timer-event-end,"V8.ParseLazy",47476 +timer-event-start,"V8.CompileLazy",47481 +timer-event-start,"V8.CompileFullCode",47485 +timer-event-end,"V8.CompileFullCode",47496 +code-creation,LazyCompile,0,0x2b8394e0,208,"valueOf native date.js:361",0x44218984,~ +timer-event-end,"V8.CompileLazy",47507 +timer-event-start,"V8.ParseLazy",47517 +timer-event-end,"V8.ParseLazy",47526 +timer-event-start,"V8.CompileLazy",47531 +timer-event-start,"V8.CompileFullCode",47536 +timer-event-end,"V8.CompileFullCode",47545 +code-creation,LazyCompile,0,0x2b8395c0,192,"browserUtil.pauseAndThen bsuite/kraken-once/stanford-crypto-ccm.js:47",0x2f33af70,~ +timer-event-end,"V8.CompileLazy",47557 +timer-event-start,"V8.ParseLazy",47561 +timer-event-end,"V8.ParseLazy",47571 +timer-event-start,"V8.CompileLazy",47576 +timer-event-start,"V8.CompileFullCode",47581 +timer-event-end,"V8.CompileFullCode",47591 +code-creation,LazyCompile,0,0x2b839680,192," bsuite/kraken-once/stanford-crypto-ccm.js:171",0x2f33dc70,~ +timer-event-end,"V8.CompileLazy",47602 +timer-event-start,"V8.ParseLazy",47608 +timer-event-end,"V8.ParseLazy",47674 +timer-event-start,"V8.CompileLazy",47681 +timer-event-start,"V8.CompileFullCode",47693 +code-creation,Stub,2,0x2b839740,196,"FastNewContextStub" +code-creation,Stub,12,0x2b839820,88,"BinaryOpStub_DIV_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",47755 +code-creation,LazyCompile,0,0x2b839880,716," bsuite/kraken-once/stanford-crypto-ccm.js:7235",0x2f33b5d0,~ +timer-event-end,"V8.CompileLazy",47768 +code-creation,Stub,12,0x2b839b60,196,"BinaryOpStub_DIV_Alloc_Smi+Smi" +timer-event-start,"V8.ParseLazy",47798 +timer-event-end,"V8.ParseLazy",47845 +timer-event-start,"V8.CompileLazy",47851 +timer-event-start,"V8.CompileFullCode",47863 +code-creation,Stub,12,0x2b839c40,88,"BinaryOpStub_MUL_OverwriteRight_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",47917 +code-creation,LazyCompile,0,0x2b839ca0,2065," bsuite/kraken-once/stanford-crypto-ccm.js:7243",0x2f33de10, +timer-event-end,"V8.CompileLazy",47930 +code-creation,Stub,12,0x2b83a4c0,167,"BinaryOpStub_MUL_OverwriteRight_Smi+Smi" +timer-event-start,"V8.ParseLazy",47958 +timer-event-end,"V8.ParseLazy",47986 +timer-event-start,"V8.CompileLazy",47992 +timer-event-start,"V8.CompileFullCode",47998 +code-creation,Stub,12,0x2b83a580,88,"BinaryOpStub_BIT_XOR_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",48031 +code-creation,LazyCompile,0,0x2b83a5e0,717,"sjcl.codec.hex.toBits bsuite/kraken-once/stanford-crypto-ccm.js:13",0x2f339e90,~ +timer-event-end,"V8.CompileLazy",48044 +timer-event-start,"V8.ParseLazy",48061 +timer-event-end,"V8.ParseLazy",48119 +timer-event-start,"V8.CompileLazy",48126 +timer-event-start,"V8.CompileFullCode",48135 +timer-event-end,"V8.CompileFullCode",48188 +code-creation,LazyCompile,0,0x2b83a8c0,1601,"DoConstructRegExp native regexp.js:39",0x44222a28,~ +timer-event-end,"V8.CompileLazy",48203 +timer-event-start,"V8.ParseLazy",48213 +tick,0x80eabd3,48226,0,0xff81fb44,2,0x2b821ae3,0x2b83a6a4,0x2b839e4e,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.ParseLazy",48288 +timer-event-start,"V8.CompileLazy",48309 +timer-event-start,"V8.CompileFullCode",48323 +timer-event-end,"V8.CompileFullCode",48372 +code-creation,LazyCompile,0,0x2b83af20,1284,"charAt native string.js:64",0x44215fa8,~ +timer-event-end,"V8.CompileLazy",48386 +code-creation,Stub,14,0x2b83b440,144,"CompareNilICStub(NullValue)(MonomorphicMap)" +code-creation,Stub,5,0x2b83b4e0,97,"StringLengthStub" +timer-event-start,"V8.ParseLazy",48435 +timer-event-end,"V8.ParseLazy",48536 +timer-event-start,"V8.CompileLazy",48543 +timer-event-start,"V8.CompileFullCode",48555 +code-creation,Stub,2,0x2b83b560,828,"SubStringStub" +timer-event-end,"V8.CompileFullCode",48640 +code-creation,LazyCompile,0,0x2b83b8a0,2428,"replace native string.js:213",0x44216248,~ +timer-event-end,"V8.CompileLazy",48654 +code-creation,StoreIC,9,0x2b83c220,135,"lastIndex" +code-creation,Stub,14,0x2b83c2c0,124,"CompareNilICStub(NullValue)(Null)" +code-creation,RegExp,4,0x2b83c340,758,"\\s|0x" +timer-event-start,"V8.ParseLazy",48827 +timer-event-end,"V8.ParseLazy",48873 +timer-event-start,"V8.CompileLazy",48879 +timer-event-start,"V8.CompileFullCode",48886 +timer-event-end,"V8.CompileFullCode",48916 +code-creation,LazyCompile,0,0x2b83c640,960,"substr native string.js:749",0x44216608,~ +timer-event-end,"V8.CompileLazy",48930 +code-creation,Stub,14,0x2b83ca00,144,"CompareNilICStub(NullValue)(MonomorphicMap)" +code-creation,Stub,13,0x2b83caa0,122,"CompareICStub" +timer-event-start,"V8.ParseLazy",48959 +timer-event-end,"V8.ParseLazy",49000 +timer-event-start,"V8.CompileLazy",49006 +timer-event-start,"V8.CompileFullCode",49012 +code-creation,Stub,12,0x2b83cb20,88,"BinaryOpStub_BIT_OR_Alloc_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b83cb80,88,"BinaryOpStub_SAR_Alloc_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",49062 +code-creation,LazyCompile,0,0x2b83cbe0,1096,"parseInt native v8natives.js:130",0x4421ec1c,~ +timer-event-end,"V8.CompileLazy",49075 +code-creation,Stub,12,0x2b83d040,399,"BinaryOpStub_BIT_XOR_Alloc_Number+Smi" +code-creation,CallIC,7,0x2b83d1e0,147,"substr" +code-creation,CallIC,7,0x2b83d280,129,"parseInt" +code-creation,Stub,2,0x2b83d320,1433,"RecordWriteStub" +code-creation,Stub,2,0x2b83d8c0,611,"RecordWriteStub" +code-creation,CallIC,7,0x2b83db40,656,"push" +timer-event-start,"V8.ParseLazy",49192 +timer-event-end,"V8.ParseLazy",49229 +timer-event-start,"V8.CompileLazy",49235 +timer-event-start,"V8.CompileFullCode",49242 +code-creation,Stub,12,0x2b83dde0,88,"BinaryOpStub_SAR_OverwriteRight_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b83de40,88,"BinaryOpStub_BIT_AND_OverwriteRight_Uninitialized+Uninitialized" +tick,0x8250358,49284,0,0xff81fe84,2,0x2b83a871,0x2b839e4e,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.CompileFullCode",49346 +code-creation,LazyCompile,0,0x2b83dea0,536,"sjcl.bitArray.clamp bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339b30,~ +timer-event-end,"V8.CompileLazy",49390 +timer-event-start,"V8.ParseLazy",49402 +timer-event-end,"V8.ParseLazy",49416 +timer-event-start,"V8.CompileLazy",49421 +timer-event-start,"V8.CompileFullCode",49426 +timer-event-end,"V8.CompileFullCode",49438 +code-creation,LazyCompile,0,0x2b83e0c0,248,"ceil native math.js:81",0x442222fc,~ +timer-event-end,"V8.CompileLazy",49450 +timer-event-start,"V8.ParseLazy",49466 +timer-event-end,"V8.ParseLazy",49529 +timer-event-start,"V8.CompileLazy",49535 +timer-event-start,"V8.CompileFullCode",49544 +code-creation,Stub,2,0x2b83e1c0,647,"FastCloneShallowArrayStub" +code-creation,Stub,12,0x2b83e460,88,"BinaryOpStub_SHL_Alloc_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b83e4c0,88,"BinaryOpStub_BIT_AND_OverwriteLeft_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b83e520,88,"BinaryOpStub_BIT_XOR_OverwriteLeft_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",49801 +code-creation,LazyCompile,0,0x2b83e580,3002,"sjcl.cipher.aes bsuite/kraken-once/stanford-crypto-ccm.js:4",0x2f339830,~ +timer-event-end,"V8.CompileLazy",49816 +timer-event-start,"V8.ParseLazy",49829 +timer-event-end,"V8.ParseLazy",49886 +timer-event-start,"V8.CompileLazy",49893 +timer-event-start,"V8.CompileFullCode",49902 +code-creation,Stub,12,0x2b83f140,88,"BinaryOpStub_BIT_XOR_OverwriteRight_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",49958 +code-creation,LazyCompile,0,0x2b83f1a0,2528,"sjcl.cipher.aes.w bsuite/kraken-once/stanford-crypto-ccm.js:6",0x2f339950,~ +timer-event-end,"V8.CompileLazy",49972 +code-creation,Stub,12,0x2b83fb80,167,"BinaryOpStub_SHL_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b83fc40,155,"BinaryOpStub_SAR_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b83fce0,167,"BinaryOpStub_MUL_OverwriteLeft_Smi+Smi" +code-creation,Stub,12,0x2b83fda0,146,"BinaryOpStub_BIT_XOR_OverwriteLeft_Smi+Smi" +code-creation,Stub,2,0x2b83fe40,1808,"RecordWriteStub" +code-creation,Stub,2,0x2b840560,554,"KeyedStoreElementStub" +code-creation,KeyedStoreIC,10,0x2b8407a0,91,"" +code-creation,Stub,12,0x2b840800,146,"BinaryOpStub_BIT_XOR_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b8408a0,146,"BinaryOpStub_BIT_XOR_OverwriteRight_Smi+Smi" +tick,0x82d1790,50347,0,0xff81fdb8,0,0x2b83f388,0x2b83e64a,0x2b839e65,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,12,0x2b840940,383,"BinaryOpStub_BIT_XOR_OverwriteLeft_Smi+Int32" +code-creation,Stub,12,0x2b840ac0,375,"BinaryOpStub_SHL_Alloc_Int32+Smi" +code-creation,Stub,12,0x2b840c40,325,"BinaryOpStub_SHR_Alloc_Int32+Smi" +code-creation,Stub,12,0x2b840da0,167,"BinaryOpStub_SHR_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b840e60,383,"BinaryOpStub_BIT_XOR_OverwriteLeft_Int32+Smi" +code-creation,Stub,2,0x2b840fe0,794,"ElementsTransitionAndStoreStub" +code-creation,KeyedStorePolymorphicIC,10,0x2b841300,107,"" +code-creation,KeyedStorePolymorphicIC,10,0x2b841300,107,"args_count: 0" +code-creation,Stub,2,0x2b841380,204,"KeyedLoadElementStub" +code-creation,KeyedLoadIC,6,0x2b841460,91,"" +code-creation,Stub,2,0x2b8414c0,405,"ElementsTransitionAndStoreStub" +code-creation,Stub,2,0x2b841660,554,"KeyedStoreElementStub" +code-creation,KeyedStorePolymorphicIC,10,0x2b8418a0,107,"" +code-creation,KeyedStorePolymorphicIC,10,0x2b8418a0,107,"args_count: 0" +code-creation,Stub,12,0x2b841920,233,"BinaryOpStub_MUL_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b841a20,407,"BinaryOpStub_BIT_XOR_OverwriteLeft_Number+Smi" +code-creation,Stub,12,0x2b841bc0,407,"BinaryOpStub_BIT_XOR_OverwriteLeft_Smi+Number" +code-creation,Stub,12,0x2b841d60,355,"BinaryOpStub_BIT_XOR_OverwriteLeft_Int32+Int32" +code-creation,Stub,12,0x2b841ee0,379,"BinaryOpStub_BIT_XOR_OverwriteLeft_Int32+Number" +code-creation,Stub,15,0x2b842060,144,"ToBooleanStub(Undefined,Smi)" +code-creation,Stub,2,0x2b842100,236,"KeyedStoreElementStub" +code-creation,KeyedStoreIC,10,0x2b842200,91,"" +code-creation,CallIC,7,0x2b842260,136,"slice" +code-creation,CallMegamorphic,7,0x2b842300,685,"args_count: 1" +code-creation,Stub,12,0x2b8425c0,146,"BinaryOpStub_ADD_OverwriteLeft_Smi+Smi" +code-creation,Stub,12,0x2b842660,148,"BinaryOpStub_SUB_Alloc_Smi+Smi" +code-creation,Stub,2,0x2b842700,301,"KeyedLoadElementStub" +code-creation,KeyedLoadIC,6,0x2b842840,91,"" +tick,0x817d391,51438,0,0xff81f9a4,0,0x2b83e81e,0x2b839e65,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,12,0x2b8428a0,190,"BinaryOpStub_MOD_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b842960,146,"BinaryOpStub_BIT_AND_OverwriteLeft_Smi+Smi" +code-creation,Stub,12,0x2b842a00,347,"BinaryOpStub_BIT_XOR_Alloc_Int32+Int32" +code-creation,Stub,12,0x2b842b60,214,"BinaryOpStub_SHL_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b842c40,375,"BinaryOpStub_SAR_Alloc_Int32+Smi" +code-creation,Stub,12,0x2b842dc0,375,"BinaryOpStub_BIT_AND_Alloc_Int32+Smi" +code-creation,CallIC,7,0x2b842f40,147,"replace" +code-creation,Stub,2,0x2b842fe0,76,"LoadFieldStub" +code-creation,LoadIC,5,0x2b843040,93,"lastIndex" +code-creation,Stub,2,0x2b8430a0,76,"LoadFieldStub" +code-creation,LoadIC,5,0x2b843100,93,"global" +code-creation,LoadIC,5,0x2b843160,103,"lastMatchInfoOverride" +code-creation,LoadIC,5,0x2b8431e0,103,"lastMatchInfo" +code-creation,LoadIC,5,0x2b843260,103,"sjcl" +code-creation,LoadIC,5,0x2b8432e0,93,"bitArray" +code-creation,CallIC,7,0x2b843340,113,"clamp" +code-creation,LoadIC,5,0x2b8433c0,93,"length" +code-creation,CallIC,7,0x2b843420,113,"ceil" +code-creation,CallIC,7,0x2b8434a0,136,"slice" +code-creation,Stub,12,0x2b843540,264,"BinaryOpStub_DIV_Alloc_Smi+Smi" +code-creation,Stub,12,0x2b843660,407,"BinaryOpStub_SAR_OverwriteRight_Number+Smi" +code-creation,Stub,12,0x2b843800,383,"BinaryOpStub_BIT_AND_OverwriteRight_Int32+Smi" +timer-event-start,"V8.ParseLazy",51907 +timer-event-end,"V8.ParseLazy",51924 +timer-event-start,"V8.CompileLazy",51930 +timer-event-start,"V8.CompileFullCode",51935 +code-creation,Stub,12,0x2b843980,88,"BinaryOpStub_SHL_OverwriteRight_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b8439e0,88,"BinaryOpStub_ADD_OverwriteRight_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",51966 +code-creation,LazyCompile,0,0x2b843a40,288,"sjcl.bitArray.partial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339b90,~ +timer-event-end,"V8.CompileLazy",51979 +code-creation,Stub,12,0x2b843b60,375,"BinaryOpStub_BIT_OR_Alloc_Int32+Smi" +code-creation,Stub,12,0x2b843ce0,247,"BinaryOpStub_MUL_Alloc_Smi+Number" +code-creation,Stub,12,0x2b843de0,268,"BinaryOpStub_ADD_OverwriteRight_Int32+Number" +code-creation,Stub,2,0x2b843f00,240,"KeyedStoreElementStub" +code-creation,KeyedStoreIC,10,0x2b844000,91,"" +code-creation,CallMiss,7,0x2b844060,178,"args_count: 3" +code-creation,CallIC,7,0x2b844120,113,"partial" +timer-event-start,"V8.ParseLazy",52165 +timer-event-end,"V8.ParseLazy",52210 +timer-event-start,"V8.CompileLazy",52217 +timer-event-start,"V8.CompileFullCode",52225 +code-creation,Stub,12,0x2b8441a0,88,"BinaryOpStub_SHR_OverwriteRight_Uninitialized+Uninitialized" +code-creation,CallInitialize,7,0x2b844200,178,"args_count: 6" +timer-event-end,"V8.CompileFullCode",52278 +code-creation,LazyCompile,0,0x2b8442c0,1057,"sjcl.mode.ccm.encrypt bsuite/kraken-once/stanford-crypto-ccm.js:19",0x2f33a250,~ +timer-event-end,"V8.CompileLazy",52296 +timer-event-start,"V8.ParseLazy",52306 +timer-event-end,"V8.ParseLazy",52324 +timer-event-start,"V8.CompileLazy",52329 +timer-event-start,"V8.CompileFullCode",52334 +timer-event-end,"V8.CompileFullCode",52349 +code-creation,LazyCompile,0,0x2b844700,336,"sjcl.bitArray.bitLength bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339ad0,~ +timer-event-end,"V8.CompileLazy",52362 +timer-event-start,"V8.ParseLazy",52375 +timer-event-end,"V8.ParseLazy",52388 +timer-event-start,"V8.CompileLazy",52392 +timer-event-start,"V8.CompileFullCode",52398 +timer-event-end,"V8.CompileFullCode",52420 +code-creation,LazyCompile,0,0x2b844860,236,"sjcl.bitArray.getPartial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339bf0,~ +timer-event-end,"V8.CompileLazy",52433 +code-creation,Stub,12,0x2b844960,264,"BinaryOpStub_DIV_Alloc_Int32+Number" +timer-event-start,"V8.ParseLazy",52455 +tick,0x8092495,52475,0,0xff81fcd0,2,0x2b844833,0x2b84437f,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.ParseLazy",52539 +timer-event-start,"V8.CompileLazy",52558 +timer-event-start,"V8.CompileFullCode",52577 +timer-event-end,"V8.CompileFullCode",52590 +code-creation,LazyCompile,0,0x2b844a80,248,"round native math.js:193",0x4422265c,~ +timer-event-end,"V8.CompileLazy",52602 +code-creation,CallIC,7,0x2b844b80,113,"getPartial" +code-creation,Stub,12,0x2b844c00,238,"BinaryOpStub_DIV_Alloc_Number+Number" +code-creation,CallIC,7,0x2b844d00,113,"round" +code-creation,Stub,12,0x2b844d80,167,"BinaryOpStub_SHR_OverwriteRight_Smi+Smi" +code-creation,CallPreMonomorphic,7,0x2b844e40,178,"args_count: 6" +timer-event-start,"V8.ParseLazy",52676 +timer-event-end,"V8.ParseLazy",52738 +timer-event-start,"V8.CompileLazy",52745 +timer-event-start,"V8.CompileFullCode",52753 +code-creation,Stub,12,0x2b844f00,88,"BinaryOpStub_SHL_OverwriteLeft_Uninitialized+Uninitialized" +code-creation,Stub,12,0x2b844f60,88,"BinaryOpStub_BIT_OR_OverwriteRight_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",52818 +code-creation,LazyCompile,0,0x2b844fc0,1838,"sjcl.mode.ccm.G bsuite/kraken-once/stanford-crypto-ccm.js:20",0x2f33a310,~ +timer-event-end,"V8.CompileLazy",52833 +code-creation,Stub,13,0x2b845700,241,"CompareICStub" +code-creation,Stub,12,0x2b845800,167,"BinaryOpStub_SHL_OverwriteLeft_Smi+Smi" +code-creation,Stub,12,0x2b8458c0,145,"BinaryOpStub_BIT_OR_OverwriteRight_Smi+Smi" +code-creation,Stub,12,0x2b845960,145,"BinaryOpStub_BIT_OR_OverwriteLeft_Smi+Smi" +code-creation,Stub,12,0x2b845a00,167,"BinaryOpStub_SHL_OverwriteRight_Smi+Smi" +timer-event-start,"V8.ParseLazy",52912 +timer-event-end,"V8.ParseLazy",52936 +timer-event-start,"V8.CompileLazy",52941 +timer-event-start,"V8.CompileFullCode",52947 +timer-event-end,"V8.CompileFullCode",52966 +code-creation,LazyCompile,0,0x2b845ac0,560,"sjcl.bitArray.concat bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a70,~ +timer-event-end,"V8.CompileLazy",52980 +code-creation,Stub,12,0x2b845d00,399,"BinaryOpStub_BIT_OR_Alloc_Number+Smi" +timer-event-start,"V8.ParseLazy",53013 +timer-event-end,"V8.ParseLazy",53049 +timer-event-start,"V8.CompileLazy",53055 +timer-event-start,"V8.CompileFullCode",53062 +timer-event-end,"V8.CompileFullCode",53095 +code-creation,LazyCompile,0,0x2b845ea0,1126,"sjcl.bitArray.P bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339cb0,~ +timer-event-end,"V8.CompileLazy",53110 +code-creation,Stub,13,0x2b846320,485,"CompareICStub" +code-creation,Stub,12,0x2b846520,383,"BinaryOpStub_BIT_OR_OverwriteRight_Int32+Smi" +code-creation,Stub,12,0x2b8466a0,383,"BinaryOpStub_SHL_OverwriteRight_Int32+Smi" +code-creation,Stub,12,0x2b846820,407,"BinaryOpStub_BIT_OR_OverwriteRight_Number+Smi" +timer-event-start,"V8.ParseLazy",53194 +timer-event-end,"V8.ParseLazy",53206 +timer-event-start,"V8.CompileLazy",53211 +timer-event-start,"V8.CompileFullCode",53216 +timer-event-end,"V8.CompileFullCode",53226 +code-creation,LazyCompile,0,0x2b8469c0,184,"sjcl.cipher.aes.encrypt bsuite/kraken-once/stanford-crypto-ccm.js:6",0x2f339890,~ +timer-event-end,"V8.CompileLazy",53243 +timer-event-start,"V8.ParseLazy",53249 +timer-event-end,"V8.ParseLazy",53325 +timer-event-start,"V8.CompileLazy",53332 +timer-event-start,"V8.CompileFullCode",53343 +code-creation,Stub,12,0x2b846a80,88,"BinaryOpStub_SUB_OverwriteLeft_Uninitialized+Uninitialized" +tick,0x8376055,53535,0,0x81bab7d,2,0x2b846a46,0x2b845312,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,2,0x2b846ae0,683,"FastCloneShallowArrayStub" +code-creation,Stub,11,0x2b846da0,132,"UnaryOpStubMinus(None)" +timer-event-end,"V8.CompileFullCode",53746 +code-creation,LazyCompile,0,0x2b846e40,3418,"sjcl.cipher.aes.H bsuite/kraken-once/stanford-crypto-ccm.js:7",0x2f3399b0,~ +timer-event-end,"V8.CompileLazy",53763 +code-creation,Stub,12,0x2b847ba0,375,"BinaryOpStub_BIT_XOR_Alloc_Smi+Int32" +code-creation,Stub,12,0x2b847d20,375,"BinaryOpStub_BIT_XOR_Alloc_Int32+Smi" +code-creation,Stub,12,0x2b847ea0,148,"BinaryOpStub_SUB_OverwriteLeft_Smi+Smi" +code-creation,Stub,15,0x2b847f40,164,"ToBooleanStub(Smi,HeapNumber)" +code-creation,CallMiss,7,0x2b848000,178,"args_count: 4" +code-creation,CallIC,7,0x2b8480c0,113,"P" +code-creation,LoadIC,5,0x2b848140,103,"undefined" +timer-event-start,"V8.ParseLazy",54007 +timer-event-end,"V8.ParseLazy",54027 +timer-event-start,"V8.CompileLazy",54032 +timer-event-start,"V8.CompileFullCode",54038 +timer-event-end,"V8.CompileFullCode",54052 +code-creation,LazyCompile,0,0x2b8481c0,388,"sjcl.bitArray.k bsuite/kraken-once/stanford-crypto-ccm.js:11",0x2f339d10,~ +timer-event-end,"V8.CompileLazy",54065 +code-creation,CallIC,7,0x2b848360,132,"H" +code-creation,LoadIC,5,0x2b848400,93,"a" +code-creation,Stub,2,0x2b848460,95,"h" +code-creation,LoadIC,5,0x2b8484c0,93,"h" +code-creation,CallIC,7,0x2b848520,132,"encrypt" +code-creation,Stub,12,0x2b8485c0,371,"BinaryOpStub_BIT_XOR_Alloc_Int32+Number" +timer-event-start,"V8.ParseLazy",54281 +timer-event-end,"V8.ParseLazy",54332 +timer-event-start,"V8.CompileLazy",54339 +timer-event-start,"V8.CompileFullCode",54347 +code-creation,Stub,2,0x2b848740,663,"FastCloneShallowArrayStub" +timer-event-end,"V8.CompileFullCode",54560 +code-creation,LazyCompile,0,0x2b8489e0,1221,"sjcl.mode.ccm.I bsuite/kraken-once/stanford-crypto-ccm.js:21",0x2f33a370,~ +timer-event-end,"V8.CompileLazy",54577 +tick,0x82f2dd2,54590,0,0xff81f67c,2,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,12,0x2b848ec0,371,"BinaryOpStub_BIT_XOR_Alloc_Number+Int32" +timer-event-start,"V8.ParseLazy",54663 +timer-event-end,"V8.ParseLazy",54685 +timer-event-start,"V8.CompileLazy",54691 +timer-event-start,"V8.CompileFullCode",54697 +code-creation,Stub,12,0x2b849040,88,"BinaryOpStub_SUB_OverwriteRight_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",54724 +code-creation,LazyCompile,0,0x2b8490a0,392,"sjcl.bitArray.bitSlice bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a10,~ +timer-event-end,"V8.CompileLazy",54737 +code-creation,Stub,12,0x2b849240,148,"BinaryOpStub_SUB_OverwriteRight_Smi+Smi" +code-creation,Stub,13,0x2b8492e0,494,"CompareICStub" +code-creation,CallMegamorphic,7,0x2b8494e0,685,"args_count: 2" +code-creation,Stub,12,0x2b8497a0,246,"BinaryOpStub_ADD_Alloc_Number+Smi" +code-creation,LoadPolymorphicIC,5,0x2b8498a0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b849920,105,"length" +timer-event-start,"V8.ParseLazy",54933 +timer-event-end,"V8.ParseLazy",54956 +timer-event-start,"V8.CompileLazy",54962 +timer-event-start,"V8.CompileFullCode",54968 +timer-event-end,"V8.CompileFullCode",54989 +code-creation,LazyCompile,0,0x2b8499a0,585,"sjcl.bitArray.equal bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339c50,~ +timer-event-end,"V8.CompileLazy",55003 +code-creation,Stub,12,0x2b849c00,395,"BinaryOpStub_BIT_XOR_Alloc_Number+Number" +code-creation,Stub,12,0x2b849da0,133,"BinaryOpStub_ADD_Alloc_String+Smi" +code-creation,Stub,12,0x2b849e40,133,"BinaryOpStub_ADD_OverwriteLeft_String+Smi" +timer-event-start,"V8.ParseLazy",55131 +timer-event-end,"V8.ParseLazy",55149 +timer-event-start,"V8.CompileLazy",55155 +timer-event-start,"V8.CompileFullCode",55160 +timer-event-end,"V8.CompileFullCode",55177 +code-creation,LazyCompile,0,0x2b849ee0,292,"sjcl.test.TestCase.require bsuite/kraken-once/stanford-crypto-ccm.js:131",0x2f33b390,~ +timer-event-end,"V8.CompileLazy",55190 +timer-event-start,"V8.ParseLazy",55198 +timer-event-end,"V8.ParseLazy",55206 +timer-event-start,"V8.CompileLazy",55211 +timer-event-start,"V8.CompileFullCode",55216 +timer-event-end,"V8.CompileFullCode",55228 +code-creation,LazyCompile,0,0x2b84a020,208,"sjcl.test.TestCase.pass bsuite/kraken-once/stanford-crypto-ccm.js:110",0x2f33b270,~ +timer-event-end,"V8.CompileLazy",55240 +code-creation,StoreIC,9,0x2b84a100,103,"passes" +timer-event-start,"V8.ParseLazy",55261 +timer-event-end,"V8.ParseLazy",55307 +timer-event-start,"V8.CompileLazy",55313 +timer-event-start,"V8.CompileFullCode",55321 +code-creation,Stub,12,0x2b84a180,88,"BinaryOpStub_DIV_OverwriteLeft_Uninitialized+Uninitialized" +timer-event-end,"V8.CompileFullCode",55365 +code-creation,LazyCompile,0,0x2b84a1e0,1229,"sjcl.mode.ccm.decrypt bsuite/kraken-once/stanford-crypto-ccm.js:19",0x2f33a2b0,~ +timer-event-end,"V8.CompileLazy",55379 +code-creation,CallIC,7,0x2b84a6c0,136,"slice" +code-creation,CallIC,7,0x2b84a760,128,"P" +code-creation,LoadPolymorphicIC,5,0x2b84a7e0,105,"length" +code-creation,KeyedLoadPolymorphicIC,6,0x2b84a860,105,"" +code-creation,CallIC,7,0x2b84a8e0,656,"push" +code-creation,Stub,12,0x2b84ab80,407,"BinaryOpStub_SHL_OverwriteRight_Number+Smi" +code-creation,LoadPolymorphicIC,5,0x2b84ad20,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84ada0,105,"length" +code-creation,CallIC,7,0x2b84ae20,136,"slice" +code-creation,Stub,12,0x2b84aec0,196,"BinaryOpStub_DIV_OverwriteLeft_Smi+Smi" +code-creation,Stub,2,0x2b84afa0,70,"k" +code-creation,LoadIC,5,0x2b84b000,93,"k" +code-creation,CallIC,7,0x2b84b060,113,"bitLength" +code-creation,CallIC,7,0x2b84b0e0,128,"partial" +code-creation,CallIC,7,0x2b84b160,113,"concat" +code-creation,LoadPolymorphicIC,5,0x2b84b1e0,105,"length" +code-creation,CallIC,7,0x2b84b260,136,"concat" +code-creation,CallIC,7,0x2b84b300,113,"bitSlice" +code-creation,CallIC,7,0x2b84b380,136,"concat" +tick,0x8118ca4,55654,0,0x90ec418,0,0x2b848b2e,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,CallIC,7,0x2b84b420,136,"slice" +code-creation,StoreIC,9,0x2b84b4c0,138,"tag" +code-creation,StoreIC,9,0x2b84b560,138,"data" +code-creation,Stub,12,0x2b84b600,214,"BinaryOpStub_SHL_OverwriteRight_Smi+Smi" +code-creation,LoadPolymorphicIC,5,0x2b84b6e0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84b760,105,"length" +code-creation,CallMiss,7,0x2b84b7e0,178,"args_count: 0" +code-creation,CallIC,7,0x2b84b8a0,132,"pass" +code-creation,Stub,2,0x2b84b940,76,"LoadFieldStub" +code-creation,LoadIC,5,0x2b84b9a0,93,"passes" +code-creation,LoadIC,5,0x2b84ba00,93,"key" +code-creation,LoadIC,5,0x2b84ba60,93,"cipher" +code-creation,Stub,2,0x2b84bac0,70,"aes" +code-creation,LoadIC,5,0x2b84bb20,93,"aes" +code-creation,CallIC,7,0x2b84bb80,113,"toBits" +code-creation,Stub,2,0x2b84bc00,95,"h" +code-creation,LoadIC,5,0x2b84bc60,93,"h" +code-creation,StoreIC,9,0x2b84bcc0,246,"a" +code-creation,LoadIC,5,0x2b84bdc0,93,"iv" +code-creation,Stub,2,0x2b84be20,76,"LoadFieldStub" +code-creation,LoadIC,5,0x2b84be80,93,"adata" +code-creation,LoadIC,5,0x2b84bee0,93,"pt" +code-creation,Stub,2,0x2b84bf40,76,"LoadFieldStub" +code-creation,LoadIC,5,0x2b84bfa0,93,"ct" +code-creation,LoadIC,5,0x2b84c000,93,"tag" +code-creation,LoadIC,5,0x2b84c060,93,"mode" +code-creation,LoadIC,5,0x2b84c0c0,93,"ccm" +code-creation,CallMiss,7,0x2b84c120,178,"args_count: 5" +code-creation,CallIC,7,0x2b84c1e0,113,"encrypt" +code-creation,CallMiss,7,0x2b84c260,178,"args_count: 6" +code-creation,CallIC,7,0x2b84c320,113,"G" +code-creation,CallIC,7,0x2b84c3a0,193,"pop" +code-creation,CallIC,7,0x2b84c480,113,"I" +code-creation,LoadIC,5,0x2b84c500,93,"data" +code-creation,LoadIC,5,0x2b84c560,93,"tag" +code-creation,CallIC,7,0x2b84c5c0,113,"equal" +code-creation,CallIC,7,0x2b84c640,132,"require" +code-creation,CallIC,7,0x2b84c6e0,113,"decrypt" +code-creation,CallIC,7,0x2b84c760,128,"bitSlice" +code-creation,CallMegamorphic,7,0x2b84c7e0,685,"args_count: 0" +tick,0xf776d430,56728,0,0x90ec418,0,0x2b84a349,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,15,0x2b84caa0,172,"ToBooleanStub(Undefined,Smi,HeapNumber)" +code-creation,CallIC,7,0x2b84cb60,193,"pop" +code-creation,Stub,2,0x2b84cc40,725,"ElementsTransitionAndStoreStub" +code-creation,Stub,2,0x2b84cf20,1800,"RecordWriteStub" +code-creation,Stub,2,0x2b84d640,578,"KeyedStoreElementStub" +code-creation,KeyedStorePolymorphicIC,10,0x2b84d8a0,107,"" +code-creation,KeyedStorePolymorphicIC,10,0x2b84d8a0,107,"args_count: 0" +timer-event-start,"V8.RecompileSynchronous",57494 +timer-event-start,"V8.ParseLazy",57505 +timer-event-end,"V8.ParseLazy",57586 +code-creation,LazyCompile,0,0x2b84d920,3418,"sjcl.cipher.aes.H bsuite/kraken-once/stanford-crypto-ccm.js:7",0x2f3399b0,~ +tick,0x8092457,57778,0,0x19e,2,0x2b846a46,0x2b8455f6,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.RecompileSynchronous",57904 +timer-event-start,"V8.RecompileConcurrent",57929 +code-creation,Stub,2,0x2b84e680,559,"ElementsTransitionAndStoreStub" +code-creation,KeyedStorePolymorphicIC,10,0x2b84e8c0,107,"" +code-creation,KeyedStorePolymorphicIC,10,0x2b84e8c0,107,"args_count: 0" +code-creation,LoadPolymorphicIC,5,0x2b84e940,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84e9c0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84ea40,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84eac0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b84eb40,105,"length" +timer-event-start,"V8.RecompileSynchronous",58447 +timer-event-start,"V8.ParseLazy",58457 +timer-event-end,"V8.ParseLazy",58501 +code-creation,LazyCompile,0,0x2b84ebc0,1096,"parseInt native v8natives.js:130",0x4421ec1c,~ +timer-event-end,"V8.RecompileSynchronous",58637 +timer-event-start,"V8.GCScavenger",58779 +timer-event-start,"V8.External",58787 +timer-event-end,"V8.External",58791 +tick,0x810f40c,58868,0,0x0,1 +timer-event-start,"V8.External",59191 +timer-event-end,"V8.External",59200 +timer-event-end,"V8.GCScavenger",59205 +timer-event-end,"V8.RecompileConcurrent",59219 +timer-event-start,"V8.RecompileConcurrent",59254 +timer-event-start,"V8.RecompileSynchronous",59271 +code-creation,LazyCompile,1,0x2b84f020,4592,"sjcl.cipher.aes.H bsuite/kraken-once/stanford-crypto-ccm.js:7",0x2f3399b0,* +timer-event-end,"V8.RecompileSynchronous",59549 +timer-event-end,"V8.RecompileConcurrent",59567 +timer-event-start,"V8.RecompileSynchronous",59590 +code-creation,LazyCompile,1,0x2b850220,1662,"parseInt native v8natives.js:130",0x4421ec1c,* +timer-event-end,"V8.RecompileSynchronous",59672 +timer-event-start,"V8.RecompileSynchronous",59682 +timer-event-start,"V8.ParseLazy",59687 +timer-event-end,"V8.ParseLazy",59701 +code-creation,LazyCompile,0,0x2b8508a0,236,"sjcl.bitArray.getPartial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339bf0,~ +timer-event-end,"V8.RecompileSynchronous",59750 +timer-event-start,"V8.RecompileConcurrent",59776 +timer-event-start,"V8.RecompileSynchronous",59811 +timer-event-start,"V8.ParseLazy",59820 +timer-event-end,"V8.ParseLazy",59838 +code-creation,LazyCompile,0,0x2b8509a0,388,"sjcl.bitArray.k bsuite/kraken-once/stanford-crypto-ccm.js:11",0x2f339d10,~ +timer-event-end,"V8.RecompileConcurrent",59909 +timer-event-start,"V8.RecompileConcurrent",59926 +timer-event-end,"V8.RecompileSynchronous",59933 +timer-event-start,"V8.RecompileSynchronous",59950 +tick,0xf776d430,59966,0,0x90ec418,2,0x2b8455e6,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LazyCompile,1,0x2b850b40,536,"sjcl.bitArray.getPartial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339bf0,* +timer-event-end,"V8.RecompileSynchronous",60077 +timer-event-start,"V8.RecompileSynchronous",60141 +timer-event-start,"V8.ParseLazy",60149 +timer-event-end,"V8.RecompileConcurrent",60177 +timer-event-end,"V8.ParseLazy",60195 +code-creation,LazyCompile,0,0x2b850d60,960,"substr native string.js:749",0x44216608,~ +timer-event-end,"V8.RecompileSynchronous",60329 +timer-event-start,"V8.RecompileConcurrent",60356 +code-deopt,60375,544 +timer-event-start,"V8.RecompileSynchronous",60409 +code-creation,LazyCompile,1,0x2b851120,1534,"sjcl.bitArray.k bsuite/kraken-once/stanford-crypto-ccm.js:11",0x2f339d10,* +timer-event-end,"V8.RecompileSynchronous",60474 +code-creation,LoadPolymorphicIC,5,0x2b851720,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b8517a0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b851820,105,"length" +timer-event-end,"V8.RecompileConcurrent",60691 +timer-event-start,"V8.RecompileSynchronous",60716 +code-creation,LazyCompile,1,0x2b8518a0,1792,"substr native string.js:749",0x44216608,* +timer-event-end,"V8.RecompileSynchronous",60803 +tick,0x2b849c4b,60997,0,0x2b849afa,0,0x2b83a0df,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileSynchronous",61042 +timer-event-start,"V8.ParseLazy",61054 +timer-event-end,"V8.ParseLazy",61066 +code-creation,LazyCompile,0,0x2b851fa0,184,"sjcl.cipher.aes.encrypt bsuite/kraken-once/stanford-crypto-ccm.js:6",0x2f339890,~ +timer-event-end,"V8.RecompileSynchronous",61112 +timer-event-start,"V8.RecompileConcurrent",61139 +timer-event-start,"V8.RecompileSynchronous",61159 +timer-event-start,"V8.ParseLazy",61168 +timer-event-end,"V8.ParseLazy",61186 +timer-event-end,"V8.RecompileConcurrent",61201 +code-creation,LazyCompile,0,0x2b852060,336,"sjcl.bitArray.bitLength bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339ad0,~ +timer-event-start,"V8.ParseLazy",61249 +timer-event-end,"V8.ParseLazy",61264 +timer-event-end,"V8.RecompileSynchronous",61290 +timer-event-start,"V8.RecompileSynchronous",61309 +timer-event-start,"V8.RecompileConcurrent",61317 +code-creation,LazyCompile,1,0x2b8521c0,196,"sjcl.cipher.aes.encrypt bsuite/kraken-once/stanford-crypto-ccm.js:6",0x2f339890,* +timer-event-end,"V8.RecompileSynchronous",61348 +timer-event-start,"V8.RecompileSynchronous",61374 +timer-event-start,"V8.ParseLazy",61381 +timer-event-end,"V8.ParseLazy",61394 +timer-event-end,"V8.RecompileSynchronous",61418 +timer-event-start,"V8.RecompileSynchronous",61424 +timer-event-start,"V8.ParseLazy",61429 +timer-event-end,"V8.ParseLazy",61442 +code-creation,LazyCompile,0,0x2b8522a0,248,"round native math.js:193",0x4422265c,~ +timer-event-end,"V8.RecompileConcurrent",61471 +timer-event-start,"V8.RecompileConcurrent",61480 +timer-event-end,"V8.RecompileSynchronous",61487 +timer-event-start,"V8.RecompileSynchronous",61512 +timer-event-end,"V8.RecompileConcurrent",61536 +timer-event-start,"V8.RecompileConcurrent",61543 +code-creation,LazyCompile,1,0x2b8523a0,888,"sjcl.bitArray.bitLength bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339ad0,* +timer-event-end,"V8.RecompileSynchronous",61565 +timer-event-start,"V8.RecompileSynchronous",61570 +code-creation,LazyCompile,1,0x2b852720,536,"sjcl.bitArray.getPartial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339bf0,* +timer-event-end,"V8.RecompileSynchronous",61599 +timer-event-start,"V8.RecompileSynchronous",61606 +timer-event-end,"V8.RecompileConcurrent",61610 +code-creation,LazyCompile,1,0x2b852940,242,"round native math.js:193",0x4422265c,* +timer-event-end,"V8.RecompileSynchronous",61629 +code-creation,LoadPolymorphicIC,5,0x2b852a40,105,"length" +timer-event-start,"V8.RecompileSynchronous",61726 +timer-event-start,"V8.ParseLazy",61731 +timer-event-end,"V8.ParseLazy",61757 +code-creation,LazyCompile,0,0x2b852ac0,536,"sjcl.bitArray.clamp bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339b30,~ +timer-event-start,"V8.ParseLazy",61847 +timer-event-end,"V8.ParseLazy",61865 +code-creation,Function,0,0x2b852ce0,288,"sjcl.bitArray.partial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339b90,~ +timer-event-end,"V8.RecompileSynchronous",61926 +timer-event-start,"V8.RecompileSynchronous",61933 +timer-event-start,"V8.ParseLazy",61939 +timer-event-end,"V8.ParseLazy",61953 +timer-event-start,"V8.RecompileConcurrent",61961 +code-creation,LazyCompile,0,0x2b852e00,248,"ceil native math.js:81",0x442222fc,~ +timer-event-end,"V8.RecompileSynchronous",62019 +tick,0x811e913,62060,0,0xf773bff4,2,0x2b83dfae,0x2b8445e0,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-deopt,62122,544 +timer-event-end,"V8.RecompileConcurrent",62287 +timer-event-start,"V8.RecompileConcurrent",62297 +timer-event-start,"V8.RecompileSynchronous",62309 +timer-event-end,"V8.RecompileConcurrent",62353 +code-creation,Stub,2,0x2b852f00,1785,"RecordWriteStub" +code-creation,LazyCompile,1,0x2b853600,1514,"sjcl.bitArray.clamp bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339b30,* +timer-event-end,"V8.RecompileSynchronous",62415 +timer-event-start,"V8.RecompileSynchronous",62421 +code-creation,LazyCompile,1,0x2b853c00,242,"ceil native math.js:81",0x442222fc,* +timer-event-end,"V8.RecompileSynchronous",62445 +code-creation,LoadPolymorphicIC,5,0x2b853d00,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b853d80,105,"length" +timer-event-start,"V8.RecompileSynchronous",63048 +timer-event-start,"V8.ParseLazy",63067 +timer-event-end,"V8.ParseLazy",63085 +timer-event-end,"V8.RecompileSynchronous",63117 +tick,0xf776d430,63132,0,0x90ec418,0,0x2b8462cc,0x2b845cd7,0x2b848b0a,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileConcurrent",63203 +timer-event-end,"V8.RecompileConcurrent",63315 +timer-event-start,"V8.RecompileSynchronous",63329 +code-creation,LazyCompile,1,0x2b853e00,644,"sjcl.bitArray.partial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339b90,* +timer-event-end,"V8.RecompileSynchronous",63379 +timer-event-start,"V8.RecompileSynchronous",63494 +timer-event-start,"V8.ParseLazy",63503 +timer-event-end,"V8.ParseLazy",63517 +timer-event-end,"V8.RecompileSynchronous",63544 +timer-event-start,"V8.RecompileConcurrent",63572 +timer-event-start,"V8.RecompileSynchronous",63641 +timer-event-start,"V8.ParseLazy",63651 +timer-event-end,"V8.RecompileConcurrent",63664 +timer-event-end,"V8.ParseLazy",63678 +code-creation,LazyCompile,0,0x2b8540a0,560,"sjcl.bitArray.concat bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a70,~ +timer-event-start,"V8.ParseLazy",63757 +timer-event-end,"V8.ParseLazy",63772 +timer-event-start,"V8.ParseLazy",63808 +timer-event-end,"V8.ParseLazy",63848 +code-creation,Function,0,0x2b8542e0,1126,"sjcl.bitArray.P bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339cb0,~ +timer-event-start,"V8.ParseLazy",63977 +timer-event-end,"V8.ParseLazy",63994 +timer-event-start,"V8.ParseLazy",64023 +timer-event-end,"V8.ParseLazy",64039 +timer-event-end,"V8.RecompileSynchronous",64072 +timer-event-start,"V8.RecompileSynchronous",64079 +timer-event-start,"V8.RecompileConcurrent",64099 +code-creation,LazyCompile,1,0x2b854760,536,"sjcl.bitArray.getPartial bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339bf0,* +timer-event-end,"V8.RecompileSynchronous",64194 +tick,0xf776d430,64209,0,0x4059,2,0x2b845c29,0x2b848b0a,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-deopt,64271,544 +timer-event-start,"V8.RecompileSynchronous",64467 +timer-event-start,"V8.ParseLazy",64476 +timer-event-end,"V8.ParseLazy",64542 +code-creation,LazyCompile,0,0x2b854980,3002,"sjcl.cipher.aes bsuite/kraken-once/stanford-crypto-ccm.js:4",0x2f339830,~ +timer-event-end,"V8.RecompileSynchronous",64818 +timer-event-end,"V8.RecompileConcurrent",64871 +timer-event-start,"V8.RecompileConcurrent",64883 +timer-event-start,"V8.RecompileSynchronous",64890 +code-creation,LazyCompile,1,0x2b855540,3364,"sjcl.bitArray.concat bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a70,* +timer-event-end,"V8.RecompileSynchronous",65047 +code-deopt,65079,4608 +code-creation,LoadPolymorphicIC,5,0x2b856280,105,"length" +tick,0x2b8472a7,65264,0,0x52f0b0e1,0,0x2b852252,0x2b848c4b,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LoadPolymorphicIC,5,0x2b856300,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b856380,105,"length" +timer-event-start,"V8.GCScavenger",65757 +timer-event-start,"V8.External",65766 +timer-event-end,"V8.External",65770 +timer-event-start,"V8.External",66154 +timer-event-end,"V8.External",66162 +timer-event-end,"V8.GCScavenger",66166 +timer-event-end,"V8.RecompileConcurrent",66181 +timer-event-start,"V8.RecompileSynchronous",66254 +tick,0x81c09b0,66332,0,0x91632e8,2,0x2b839e65,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,2,0x2b856400,1785,"RecordWriteStub" +code-creation,Stub,2,0x2b856b00,1785,"RecordWriteStub" +code-creation,Stub,2,0x2b857200,783,"RecordWriteStub" +code-creation,Stub,2,0x2b857520,1772,"RecordWriteStub" +code-creation,Stub,2,0x2b857c20,1785,"RecordWriteStub" +code-creation,LazyCompile,1,0x2b858320,4397,"sjcl.cipher.aes bsuite/kraken-once/stanford-crypto-ccm.js:4",0x2f339830,* +timer-event-end,"V8.RecompileSynchronous",66661 +timer-event-start,"V8.RecompileSynchronous",66788 +timer-event-start,"V8.ParseLazy",66797 +timer-event-end,"V8.ParseLazy",66878 +timer-event-end,"V8.RecompileSynchronous",67067 +timer-event-start,"V8.RecompileConcurrent",67094 +tick,0x2b8473da,67403,0,0x2f392d35,0,0x2b852252,0x2b8455f6,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.RecompileConcurrent",68064 +timer-event-start,"V8.RecompileSynchronous",68081 +code-creation,LazyCompile,1,0x2b859460,4752,"sjcl.cipher.aes.H bsuite/kraken-once/stanford-crypto-ccm.js:7",0x2f3399b0,* +timer-event-end,"V8.RecompileSynchronous",68294 +code-creation,LoadPolymorphicIC,5,0x2b85a700,105,"length" +tick,0x2b85055a,68462,0,0x527b30d9,0,0x2b83a782,0x2b839f55,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",69250 +timer-event-start,"V8.External",69260 +timer-event-end,"V8.External",69264 +timer-event-start,"V8.External",69314 +timer-event-end,"V8.External",69320 +timer-event-end,"V8.GCScavenger",69324 +tick,0x82ec00c,69525,0,0xff81fcf4,0,0x2b85056f,0x2b83a782,0x2b839fd2,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LoadPolymorphicIC,5,0x2b85a780,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b85a800,117,"length" +code-creation,LoadPolymorphicIC,5,0x2b85a880,117,"length" +code-creation,LoadPolymorphicIC,5,0x2b85a900,117,"length" +code-creation,LoadPolymorphicIC,5,0x2b85a980,117,"length" +code-creation,LoadPolymorphicIC,5,0x2b85aa00,117,"length" +tick,0x81168ba,70588,0,0x90d5060,0,0x2b85056f,0x2b83a782,0x2b839f04,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileSynchronous",71064 +timer-event-start,"V8.ParseLazy",71076 +timer-event-end,"V8.ParseLazy",71094 +code-creation,LazyCompile,0,0x2b85aa80,292,"sjcl.test.TestCase.require bsuite/kraken-once/stanford-crypto-ccm.js:131",0x2f33b390,~ +timer-event-start,"V8.ParseLazy",71142 +timer-event-end,"V8.ParseLazy",71152 +code-creation,Function,0,0x2b85abc0,208,"sjcl.test.TestCase.pass bsuite/kraken-once/stanford-crypto-ccm.js:110",0x2f33b270,~ +timer-event-end,"V8.RecompileSynchronous",71195 +timer-event-start,"V8.RecompileSynchronous",71204 +timer-event-start,"V8.ParseLazy",71210 +timer-event-start,"V8.RecompileConcurrent",71216 +timer-event-end,"V8.ParseLazy",71228 +timer-event-end,"V8.RecompileSynchronous",71254 +timer-event-end,"V8.RecompileConcurrent",71304 +timer-event-start,"V8.RecompileConcurrent",71312 +timer-event-start,"V8.RecompileSynchronous",71316 +code-creation,LazyCompile,1,0x2b85aca0,322,"sjcl.test.TestCase.require bsuite/kraken-once/stanford-crypto-ccm.js:131",0x2f33b390,* +timer-event-end,"V8.RecompileSynchronous",71361 +timer-event-start,"V8.RecompileSynchronous",71367 +timer-event-end,"V8.RecompileConcurrent",71373 +code-creation,LazyCompile,1,0x2b85ae00,198,"sjcl.test.TestCase.pass bsuite/kraken-once/stanford-crypto-ccm.js:110",0x2f33b270,* +timer-event-end,"V8.RecompileSynchronous",71390 +tick,0x2b83c3b1,71653,0,0xffffff6b,0,0x2b83bd35,0x2b83a725,0x2b839f55,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",72513 +timer-event-start,"V8.External",72524 +timer-event-end,"V8.External",72530 +timer-event-start,"V8.External",72583 +timer-event-end,"V8.External",72591 +timer-event-end,"V8.GCScavenger",72596 +tick,0x8116878,72711,0,0x90d5060,0,0x2b85056f,0x2b83a782,0x2b839f04,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,CallIC,7,0x2b85aee0,136,"concat" +timer-event-start,"V8.RecompileSynchronous",72947 +timer-event-start,"V8.ParseLazy",72956 +timer-event-end,"V8.ParseLazy",72977 +code-creation,LazyCompile,0,0x2b85af80,392,"sjcl.bitArray.bitSlice bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a10,~ +timer-event-start,"V8.ParseLazy",73044 +timer-event-end,"V8.ParseLazy",73083 +timer-event-start,"V8.ParseLazy",73169 +timer-event-end,"V8.ParseLazy",73185 +timer-event-start,"V8.ParseLazy",73217 +timer-event-end,"V8.ParseLazy",73232 +timer-event-start,"V8.ParseLazy",73263 +timer-event-end,"V8.ParseLazy",73289 +timer-event-start,"V8.ParseLazy",73339 +timer-event-end,"V8.ParseLazy",73356 +timer-event-end,"V8.RecompileSynchronous",73393 +timer-event-start,"V8.RecompileConcurrent",73422 +tick,0x82eea09,73786,0,0x90de9b0,0,0x2b85056f,0x2b83a782,0x2b839e4e,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.ParseLazy",74228 +timer-event-end,"V8.RecompileConcurrent",74243 +timer-event-end,"V8.ParseLazy",74259 +timer-event-start,"V8.CompileLazy",74267 +timer-event-start,"V8.CompileFullCode",74273 +timer-event-end,"V8.CompileFullCode",74291 +code-creation,LazyCompile,0,0x2b85b120,332," bsuite/kraken-once/stanford-crypto-ccm.js:55",0x2f33db50,~ +timer-event-end,"V8.CompileLazy",74304 +timer-event-start,"V8.RecompileSynchronous",74351 +code-creation,LazyCompile,1,0x2b85b280,4132,"sjcl.bitArray.bitSlice bsuite/kraken-once/stanford-crypto-ccm.js:9",0x2f339a10,* +timer-event-end,"V8.RecompileSynchronous",74533 +tick,0x2b85a2b8,74843,0,0xf5,0,0x2b852252,0x2b8454f6,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b84a934,75905,0,0x2b855c42,0,0x2b8446a3,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",76182 +timer-event-start,"V8.External",76193 +timer-event-end,"V8.External",76197 +timer-event-start,"V8.External",76251 +timer-event-end,"V8.External",76258 +timer-event-end,"V8.GCScavenger",76262 +tick,0x81168ba,76974,0,0x90d5060,0,0x2b85056f,0x2b83a782,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x81168ba,78047,0,0x90d5060,0,0x2b85056f,0x2b83a782,0x2b839f55,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileSynchronous",78403 +timer-event-start,"V8.ParseLazy",78415 +timer-event-end,"V8.ParseLazy",78444 +code-creation,LazyCompile,0,0x2b85c2c0,717,"sjcl.codec.hex.toBits bsuite/kraken-once/stanford-crypto-ccm.js:13",0x2f339e90,~ +timer-event-start,"V8.ParseLazy",78530 +timer-event-end,"V8.ParseLazy",78559 +timer-event-start,"V8.ParseLazy",78614 +timer-event-end,"V8.ParseLazy",78632 +timer-event-end,"V8.RecompileSynchronous",78666 +timer-event-start,"V8.RecompileConcurrent",78695 +timer-event-end,"V8.RecompileConcurrent",79073 +timer-event-start,"V8.RecompileSynchronous",79089 +tick,0x2b859d1c,79108,0,0x6,0,0x2b852252,0x2b8455f6,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,2,0x2b85c5a0,1421,"StringAddStub" +code-creation,LazyCompile,1,0x2b85cb40,2261,"sjcl.codec.hex.toBits bsuite/kraken-once/stanford-crypto-ccm.js:13",0x2f339e90,* +timer-event-end,"V8.RecompileSynchronous",79251 +timer-event-start,"V8.GCScavenger",79473 +timer-event-start,"V8.External",79482 +timer-event-end,"V8.External",79486 +timer-event-start,"V8.External",79534 +timer-event-end,"V8.External",79540 +timer-event-end,"V8.GCScavenger",79544 +tick,0x2b85b446,80176,0,0x256b20d1,0,0x2b848b8c,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x80c4222,81235,0,0x90d5060,0,0x2b85b578,0x2b84a349,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",82255 +timer-event-start,"V8.External",82266 +timer-event-end,"V8.External",82270 +tick,0x2b858631,82290,0,0x2b80a276,0,0x2b839e65,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.External",82339 +timer-event-end,"V8.External",82349 +timer-event-end,"V8.GCScavenger",82353 +tick,0x2b82f581,83363,0,0x2b84539a,0,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x808cf8f,84440,0,0x90dabb0,0,0x2b85599a,0x2b845482,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",85035 +timer-event-start,"V8.External",85046 +timer-event-end,"V8.External",85050 +timer-event-start,"V8.External",85093 +timer-event-end,"V8.External",85099 +timer-event-end,"V8.GCScavenger",85103 +tick,0x2b829c56,85495,0,0x3e60ce29,0,0x2b852252,0x2b8454f6,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x808b74f,86567,0,0x2f308081,0,0x2b8537a0,0x2b8456a8,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b85d04c,87632,0,0x2b839f55,0,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",87755 +timer-event-start,"V8.External",87766 +timer-event-end,"V8.External",87770 +timer-event-start,"V8.External",87822 +timer-event-end,"V8.External",87829 +timer-event-end,"V8.GCScavenger",87833 +timer-event-start,"V8.RecompileSynchronous",88294 +timer-event-start,"V8.ParseLazy",88303 +timer-event-end,"V8.ParseLazy",88361 +code-creation,LazyCompile,0,0x2b85d420,1221,"sjcl.mode.ccm.I bsuite/kraken-once/stanford-crypto-ccm.js:21",0x2f33a370,~ +timer-event-start,"V8.ParseLazy",88473 +timer-event-end,"V8.ParseLazy",88492 +timer-event-start,"V8.ParseLazy",88532 +timer-event-end,"V8.ParseLazy",88545 +timer-event-start,"V8.ParseLazy",88572 +timer-event-end,"V8.ParseLazy",88588 +timer-event-start,"V8.ParseLazy",88612 +timer-event-end,"V8.ParseLazy",88645 +timer-event-start,"V8.ParseLazy",88688 +timer-event-end,"V8.ParseLazy",88714 +tick,0x81fc61b,88727,0,0xff81ebbc,2,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.ParseLazy",88792 +timer-event-end,"V8.ParseLazy",88867 +timer-event-start,"V8.ParseLazy",88951 +timer-event-end,"V8.ParseLazy",88967 +timer-event-start,"V8.ParseLazy",88996 +timer-event-end,"V8.ParseLazy",89012 +timer-event-end,"V8.RecompileSynchronous",89134 +timer-event-start,"V8.RecompileConcurrent",89160 +timer-event-start,"V8.RecompileSynchronous",89215 +timer-event-start,"V8.ParseLazy",89224 +timer-event-end,"V8.ParseLazy",89245 +code-creation,LazyCompile,0,0x2b85d900,585,"sjcl.bitArray.equal bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339c50,~ +timer-event-start,"V8.ParseLazy",89309 +timer-event-end,"V8.ParseLazy",89326 +timer-event-start,"V8.ParseLazy",89356 +timer-event-end,"V8.ParseLazy",89369 +timer-event-start,"V8.ParseLazy",89391 +timer-event-end,"V8.ParseLazy",89406 +timer-event-start,"V8.ParseLazy",89433 +timer-event-end,"V8.ParseLazy",89445 +timer-event-end,"V8.RecompileSynchronous",89485 +timer-event-start,"V8.RecompileSynchronous",89730 +timer-event-start,"V8.ParseLazy",89740 +tick,0x81168ba,89761,0,0x90d5060,0,0x2b85056f,0x2b85cd2d,0x2b839f04,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.ParseLazy",89805 +code-creation,LazyCompile,0,0x2b85db60,1838,"sjcl.mode.ccm.G bsuite/kraken-once/stanford-crypto-ccm.js:20",0x2f33a310,~ +timer-event-start,"V8.ParseLazy",89969 +timer-event-end,"V8.ParseLazy",89990 +timer-event-start,"V8.ParseLazy",90016 +timer-event-end,"V8.ParseLazy",90042 +timer-event-start,"V8.ParseLazy",90084 +timer-event-end,"V8.ParseLazy",90098 +timer-event-start,"V8.ParseLazy",90129 +timer-event-end,"V8.ParseLazy",90170 +timer-event-start,"V8.ParseLazy",90271 +timer-event-end,"V8.ParseLazy",90286 +timer-event-start,"V8.ParseLazy",90326 +timer-event-end,"V8.ParseLazy",90344 +timer-event-end,"V8.RecompileSynchronous",90480 +tick,0x2b8596f9,90829,0,0x8,0,0x2b852252,0x2b8454f6,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.RecompileConcurrent",91133 +timer-event-start,"V8.RecompileConcurrent",91145 +timer-event-start,"V8.RecompileSynchronous",91197 +code-creation,Stub,2,0x2b85e2a0,1800,"RecordWriteStub" +code-creation,Stub,2,0x2b85e9c0,1805,"RecordWriteStub" +code-creation,Stub,2,0x2b85f0e0,1785,"RecordWriteStub" +code-creation,Stub,2,0x2b85f7e0,1797,"RecordWriteStub" +timer-event-end,"V8.RecompileConcurrent",91529 +timer-event-start,"V8.RecompileConcurrent",91540 +code-creation,Stub,2,0x2b85ff00,1789,"RecordWriteStub" +code-creation,Stub,2,0x2b860600,1805,"RecordWriteStub" +code-creation,LazyCompile,1,0x2b860d20,9288,"sjcl.mode.ccm.I bsuite/kraken-once/stanford-crypto-ccm.js:21",0x2f33a370,* +timer-event-end,"V8.RecompileSynchronous",91729 +timer-event-start,"V8.RecompileSynchronous",91735 +code-creation,LazyCompile,1,0x2b863180,2119,"sjcl.bitArray.equal bsuite/kraken-once/stanford-crypto-ccm.js:10",0x2f339c50,* +timer-event-end,"V8.RecompileSynchronous",91833 +tick,0xf74c34b6,91883,0,0x90ebc51,2,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-deopt,91990,9312 +code-creation,LoadPolymorphicIC,5,0x2b8639e0,105,"length" +tick,0x2b859a99,92950,0,0x4,0,0x2b852252,0x2b8455f6,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",93234 +timer-event-start,"V8.External",93245 +timer-event-end,"V8.External",93249 +timer-event-end,"V8.RecompileConcurrent",93304 +timer-event-start,"V8.External",93319 +timer-event-end,"V8.External",93327 +timer-event-end,"V8.GCScavenger",93331 +timer-event-start,"V8.RecompileSynchronous",93353 +code-creation,Stub,2,0x2b863a60,1800,"RecordWriteStub" +code-creation,Stub,2,0x2b864180,1780,"RecordWriteStub" +code-creation,LazyCompile,1,0x2b864880,7990,"sjcl.mode.ccm.G bsuite/kraken-once/stanford-crypto-ccm.js:20",0x2f33a310,* +timer-event-end,"V8.RecompileSynchronous",93732 +code-creation,LoadPolymorphicIC,5,0x2b8667c0,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b866840,105,"length" +code-creation,LoadPolymorphicIC,5,0x2b8668c0,105,"length" +tick,0x2b848cbd,94006,0,0xa,0,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LoadPolymorphicIC,5,0x2b866940,105,"length" +tick,0x8231000,95074,0,0x90d5060,0,0x2b848e54,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x83b9d75,96149,0,0x527db159,0,0x2b82364b,0x2b83a13d,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",96446 +timer-event-start,"V8.External",96457 +timer-event-end,"V8.External",96461 +timer-event-start,"V8.External",96513 +timer-event-end,"V8.External",96520 +timer-event-end,"V8.GCScavenger",96524 +tick,0x2b85960c,97208,0,0xfee0,0,0x2b852252,0x2b848c4b,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b83b5b3,98279,0,0x2b851c24,0,0x2b85cd19,0x2b839f04,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",99128 +timer-event-start,"V8.External",99139 +timer-event-end,"V8.External",99143 +timer-event-start,"V8.External",99189 +timer-event-end,"V8.External",99195 +timer-event-end,"V8.GCScavenger",99199 +tick,0x821c54b,99345,0,0x5270e530,0,0x2b83bd35,0x2b85ccab,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b85a010,100416,0,0x0,0,0x2b852252,0x2b865810,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x808b5f1,101472,0,0x2f308081,0,0x2b8537a0,0x2b84a325,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",101820 +timer-event-start,"V8.External",101831 +timer-event-end,"V8.External",101835 +timer-event-start,"V8.External",101885 +timer-event-end,"V8.External",101891 +timer-event-end,"V8.GCScavenger",101895 +tick,0x2b85a376,102533,0,0x9c155cd6,0,0x2b852252,0x2b865810,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b863678,103607,0,0x4c0,0,0x2b83a0df,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",104515 +timer-event-start,"V8.External",104529 +timer-event-end,"V8.External",104533 +timer-event-start,"V8.External",104581 +timer-event-end,"V8.External",104588 +timer-event-end,"V8.GCScavenger",104592 +tick,0x2b85a2dc,104658,0,0x29,0,0x2b852252,0x2b8658f7,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b859e24,105742,0,0x80c5e06,0,0x2b852252,0x2b8654d2,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-deopt,106093,4416 +code-creation,Stub,12,0x2b8669c0,190,"BinaryOpStub_MOD_Alloc_Smi+Smi" +tick,0x2b8514f9,106811,0,0xd1b6f5df,0,0x2b8657f1,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",107254 +timer-event-start,"V8.External",107264 +timer-event-end,"V8.External",107268 +timer-event-start,"V8.External",107317 +timer-event-end,"V8.External",107323 +timer-event-end,"V8.GCScavenger",107327 +timer-event-start,"V8.RecompileSynchronous",107462 +timer-event-start,"V8.ParseLazy",107471 +timer-event-end,"V8.ParseLazy",107537 +timer-event-end,"V8.RecompileSynchronous",107729 +timer-event-start,"V8.RecompileConcurrent",107764 +tick,0x2b859da9,107874,0,0x2,0,0x2b852252,0x2b848b65,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-end,"V8.RecompileConcurrent",108795 +timer-event-start,"V8.RecompileSynchronous",108885 +tick,0x2b859d60,108935,0,0x0,0,0x2b852252,0x2b8658f7,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,Stub,2,0x2b866a80,783,"RecordWriteStub" +code-creation,Stub,2,0x2b866da0,1772,"RecordWriteStub" +code-creation,LazyCompile,1,0x2b8674a0,4040,"sjcl.cipher.aes bsuite/kraken-once/stanford-crypto-ccm.js:4",0x2f339830,* +timer-event-end,"V8.RecompileSynchronous",109204 +tick,0x2b851bd9,110005,0,0x68,0,0x2b85cd19,0x2b839f04,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",110651 +timer-event-start,"V8.External",110662 +timer-event-end,"V8.External",110666 +timer-event-start,"V8.External",110715 +timer-event-end,"V8.External",110721 +timer-event-end,"V8.GCScavenger",110725 +tick,0x2b85a1d8,111072,0,0x0,0,0x2b852252,0x2b8658f7,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b848d38,112161,0,0x4c,0,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileSynchronous",112323 +timer-event-start,"V8.ParseLazy",112335 +timer-event-end,"V8.ParseLazy",112387 +timer-event-start,"V8.ParseLazy",112444 +timer-event-end,"V8.ParseLazy",112463 +timer-event-start,"V8.ParseLazy",112496 +timer-event-end,"V8.ParseLazy",112509 +timer-event-start,"V8.ParseLazy",112536 +timer-event-end,"V8.ParseLazy",112552 +timer-event-start,"V8.ParseLazy",112576 +timer-event-end,"V8.ParseLazy",112598 +timer-event-start,"V8.ParseLazy",112639 +timer-event-end,"V8.ParseLazy",112653 +timer-event-start,"V8.ParseLazy",112685 +timer-event-end,"V8.ParseLazy",112722 +timer-event-start,"V8.ParseLazy",112803 +timer-event-end,"V8.ParseLazy",112819 +timer-event-start,"V8.ParseLazy",112848 +timer-event-end,"V8.ParseLazy",112863 +timer-event-end,"V8.RecompileSynchronous",112986 +timer-event-start,"V8.RecompileConcurrent",113012 +tick,0x2b867dc3,113148,0,0x100,0,0x2b839e65,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",114171 +timer-event-start,"V8.External",114182 +timer-event-end,"V8.External",114186 +tick,0x82c920e,114254,0,0x0,1 +timer-event-start,"V8.External",114309 +timer-event-end,"V8.External",114330 +timer-event-end,"V8.GCScavenger",114350 +timer-event-end,"V8.RecompileConcurrent",115013 +timer-event-start,"V8.RecompileSynchronous",115032 +tick,0x8369515,115325,0,0x9135ff0,2,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LazyCompile,1,0x5120a000,9284,"sjcl.mode.ccm.I bsuite/kraken-once/stanford-crypto-ccm.js:21",0x2f33a370,* +timer-event-end,"V8.RecompileSynchronous",115434 +code-deopt,115666,9312 +tick,0x2b85056f,116392,0,0x52f8f619,0,0x2b85cd2d,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b812420,117465,0,0x2b85592e,0,0x2b86573b,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",117571 +timer-event-start,"V8.External",117583 +timer-event-end,"V8.External",117587 +timer-event-start,"V8.External",117636 +timer-event-end,"V8.External",117642 +timer-event-end,"V8.GCScavenger",117646 +tick,0x811db13,118481,0,0x90d5060,0,0x2b85cd53,0x2b839eb3,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x80c4222,119548,0,0x90d5060,0,0x2b85599a,0x2b86573b,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",120368 +timer-event-start,"V8.External",120379 +timer-event-end,"V8.External",120383 +timer-event-start,"V8.External",120428 +timer-event-end,"V8.External",120434 +timer-event-end,"V8.GCScavenger",120438 +tick,0x2b867eb3,120610,0,0x100,0,0x2b839e65,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b859eae,121680,0,0x80c5e06,0,0x2b852252,0x2b8658f7,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b85981d,122808,0,0x21,0,0x2b852252,0x2b848c4b,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",123188 +timer-event-start,"V8.External",123199 +timer-event-end,"V8.External",123203 +timer-event-start,"V8.External",123248 +timer-event-end,"V8.External",123254 +timer-event-end,"V8.GCScavenger",123258 +tick,0x2b859ca8,123878,0,0x0,0,0x2b852252,0x2b865810,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x80fa2d1,124943,0,0x5279ab29,0,0x2b83bd35,0x2b85ccab,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",126000 +timer-event-start,"V8.External",126017 +timer-event-end,"V8.External",126022 +tick,0x808b6b0,126038,0,0x2f308081,0,0x2b855838,0x2b848b0a,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.External",126109 +timer-event-end,"V8.External",126129 +timer-event-end,"V8.GCScavenger",126139 +tick,0x808b656,127081,0,0x2f308081,0,0x2b8658be,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b85a1f0,128141,0,0x1f,0,0x2b852252,0x2b848c4b,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",128896 +timer-event-start,"V8.External",128907 +timer-event-end,"V8.External",128911 +timer-event-start,"V8.External",128958 +timer-event-end,"V8.External",128964 +timer-event-end,"V8.GCScavenger",128968 +tick,0x2b867d2b,129212,0,0x100,0,0x2b839e65,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b859a7b,130285,0,0x80c5e06,0,0x2b852252,0x2b865810,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b859c3b,131350,0,0x0,0,0x2b852252,0x2b8658f7,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",131713 +timer-event-start,"V8.External",131723 +timer-event-end,"V8.External",131727 +timer-event-start,"V8.External",131772 +timer-event-end,"V8.External",131778 +timer-event-end,"V8.GCScavenger",131782 +tick,0x80c413f,132412,0,0x90d5060,0,0x2b855ca8,0x2b8446a3,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x80a1baf,133466,0,0x811e5c0,0,0x2b848b2e,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",134532 +tick,0x2b85d126,134550,0,0x2,0,0x2b839f04,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.External",134619 +timer-event-end,"V8.External",134636 +timer-event-start,"V8.External",134702 +timer-event-end,"V8.External",134708 +timer-event-end,"V8.GCScavenger",134712 +tick,0x2b8594d3,135617,0,0x80c5e06,0,0x2b852252,0x2b8654d2,0x2b844628,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.RecompileSynchronous",135776 +timer-event-start,"V8.ParseLazy",135787 +timer-event-end,"V8.ParseLazy",135838 +timer-event-start,"V8.ParseLazy",135894 +timer-event-end,"V8.ParseLazy",135913 +timer-event-start,"V8.ParseLazy",135946 +timer-event-end,"V8.ParseLazy",135960 +timer-event-start,"V8.ParseLazy",135987 +timer-event-end,"V8.ParseLazy",136002 +timer-event-start,"V8.ParseLazy",136026 +timer-event-end,"V8.ParseLazy",136048 +timer-event-start,"V8.ParseLazy",136089 +timer-event-end,"V8.ParseLazy",136103 +timer-event-start,"V8.ParseLazy",136135 +timer-event-end,"V8.ParseLazy",136172 +timer-event-start,"V8.ParseLazy",136253 +timer-event-end,"V8.ParseLazy",136270 +timer-event-start,"V8.ParseLazy",136301 +timer-event-end,"V8.ParseLazy",136317 +timer-event-end,"V8.RecompileSynchronous",136440 +timer-event-start,"V8.RecompileConcurrent",136466 +tick,0x2b859c6e,136680,0,0x0,0,0x2b852252,0x2b8658f7,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-creation,LoadPolymorphicIC,5,0x5120c460,105,"length" +code-creation,LoadPolymorphicIC,5,0x5120c4e0,117,"length" +code-creation,LoadPolymorphicIC,5,0x5120c560,117,"length" +code-creation,LoadPolymorphicIC,5,0x5120c5e0,105,"length" +code-creation,LoadPolymorphicIC,5,0x5120c660,105,"length" +tick,0x2b855ece,137742,0,0x527d0961,0,0x2b8446a3,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",138203 +timer-event-start,"V8.External",138213 +timer-event-end,"V8.External",138217 +timer-event-start,"V8.External",138271 +timer-event-end,"V8.External",138277 +timer-event-end,"V8.GCScavenger",138281 +timer-event-end,"V8.RecompileConcurrent",138393 +timer-event-start,"V8.RecompileSynchronous",138412 +code-creation,LazyCompile,1,0x5120c6e0,9284,"sjcl.mode.ccm.I bsuite/kraken-once/stanford-crypto-ccm.js:21",0x2f33a370,* +timer-event-end,"V8.RecompileSynchronous",138781 +tick,0x83647f0,138812,0,0xf633ddf4,2,0x2b844670,0x2b83a0cc,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +code-deopt,138895,9312 +tick,0x2b851212,139867,0,0xff81fd00,0,0x2b8657f1,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x82ebff7,140937,0,0x2f33ca81,0,0x2b85056f,0x2b85cd2d,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",141540 +timer-event-start,"V8.External",141551 +timer-event-end,"V8.External",141555 +timer-event-start,"V8.External",141605 +timer-event-end,"V8.External",141611 +timer-event-end,"V8.GCScavenger",141615 +tick,0x2b85a0a6,142005,0,0x0,0,0x2b852252,0x2b865810,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x8116886,143088,0,0x90d5060,0,0x2b85b862,0x2b848b8c,0x2b84a58b,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b83dbaf,144137,0,0x2b85cd53,0,0x2b839fd2,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.GCScavenger",144365 +timer-event-start,"V8.External",144376 +timer-event-end,"V8.External",144380 +timer-event-start,"V8.External",144428 +timer-event-end,"V8.External",144434 +timer-event-end,"V8.GCScavenger",144438 +tick,0x81168ba,145212,0,0x90d5060,0,0x2b85056f,0x2b85cd2d,0x2b839f04,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +tick,0x2b851430,146268,0,0xff81fd00,0,0x2b8657f1,0x2b84a5e0,0x2b83a281,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b85b238,0x2b83a474,0x2b838f3f,0x2b838c50,0x2b839b39,0x2b83970e,0x2b83964b,0x2b8394a8,0x2b839273,0x2b839036,0x2b838f3f,0x2b838c50,0x2b83892e,0x2b8383df,0x2b8350ac +timer-event-start,"V8.ParseLazy",146339 +timer-event-end,"V8.ParseLazy",146358 +timer-event-start,"V8.CompileLazy",146364 +timer-event-start,"V8.CompileFullCode",146369 +timer-event-end,"V8.CompileFullCode",146386 +code-creation,LazyCompile,0,0x5120eb40,212," bsuite/kraken-once/stanford-crypto-ccm.js:172",0x2f33dd88,~ +timer-event-end,"V8.CompileLazy",146400 +code-creation,Stub,12,0x5120ec20,311,"BinaryOpStub_SUB_Alloc_Generic+Generic" +timer-event-start,"V8.ParseLazy",146431 +timer-event-end,"V8.ParseLazy",146461 +timer-event-start,"V8.CompileLazy",146467 +timer-event-start,"V8.CompileFullCode",146475 +timer-event-end,"V8.CompileFullCode",146495 +code-creation,LazyCompile,0,0x5120ed60,580,"NonNumberToNumber native runtime.js:548",0x44225f78,~ +timer-event-end,"V8.CompileLazy",146508 +code-creation,Stub,2,0x5120efc0,98,"valueOf" +code-creation,LoadPolymorphicIC,5,0x5120f040,117,"valueOf" +code-creation,CallIC,7,0x5120f0c0,129,"ToNumber" +timer-event-start,"V8.ParseLazy",146556 +timer-event-end,"V8.ParseLazy",146569 +timer-event-start,"V8.CompileLazy",146574 +timer-event-start,"V8.CompileFullCode",146580 +timer-event-end,"V8.CompileFullCode",146591 +code-creation,LazyCompile,0,0x5120f160,208,"record bsuite/kraken-once/stanford-crypto-ccm.js:7229",0x2f339680,~ +timer-event-end,"V8.CompileLazy",146603 +timer-event-start,"V8.External",146613 +timer-event-end,"V8.External",146656 +timer-event-end,"V8.Execute",146662 +timer-event-start,"V8.RecompileConcurrent",146700 +timer-event-end,"V8.RecompileConcurrent",146738 +profiler,"end" diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test-func-info.log b/deps/v8/test/mjsunit/tools/tickprocessor-test-func-info.log new file mode 100644 index 00000000000000..94aa56d36c4ad2 --- /dev/null +++ b/deps/v8/test/mjsunit/tools/tickprocessor-test-func-info.log @@ -0,0 +1,11 @@ +shared-library,"shell",0x08048000,0x081ee000 +shared-library,"/lib32/libm-2.7.so",0xf7db6000,0xf7dd9000 +shared-library,"ffffe000-fffff000",0xffffe000,0xfffff000 +profiler,"begin",1 +code-creation,Stub,0,0x424260,348,"CompareStub_GE" +code-creation,LazyCompile,0,0x2a8100,18535,"DrawQube 3d-cube.js:188",0xf43abcac, +code-creation,LazyCompile,0,0x480100,3908,"DrawLine 3d-cube.js:17",0xf43abc50, +tick,0x424284,0,0,0x480600,0,0x2aaaa5 +tick,0x42429f,0,0,0x480600,0,0x2aacb4 +tick,0x48063d,0,0,0x2d0f7c,0,0x2aaec6 +profiler,"end" diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test.log b/deps/v8/test/mjsunit/tools/tickprocessor-test.log new file mode 100644 index 00000000000000..cf8b90d73bfd12 --- /dev/null +++ b/deps/v8/test/mjsunit/tools/tickprocessor-test.log @@ -0,0 +1,25 @@ +shared-library,"shell",0x08048000,0x081ee000 +shared-library,"/lib32/libm-2.7.so",0xf7db6000,0xf7dd9000 +shared-library,"ffffe000-fffff000",0xffffe000,0xfffff000 +profiler,"begin",1 +code-creation,Stub,0,0xf540a100,474,"CEntryStub" +code-creation,Script,0,0xf541cd80,736,"exp.js" +code-creation,Stub,0,0xf541d0e0,47,"RuntimeStub_Math_exp" +code-creation,LazyCompile,0,0xf541d120,145,"exp native math.js:41" +function-creation,0xf441d280,0xf541d120 +code-creation,LoadIC,0,0xf541d280,117,"j" +code-creation,LoadIC,0,0xf541d360,63,"i" +tick,0x80f82d1,0,0,0,0,0xf541ce5c +tick,0x80f89a1,0,0,0,0,0xf541ce5c +tick,0x8123b5c,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0x8123b65,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf541d2be,0,0,0,0 +tick,0xf541d320,0,0,0,0 +tick,0xf541d384,0,0,0,0 +tick,0xf7db94da,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7db951c,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7dbc508,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7dbff21,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7edec90,0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xffffe402,0,0,0,0 +profiler,"end" diff --git a/tools/make-v8.sh b/tools/make-v8.sh new file mode 100755 index 00000000000000..f6efb66a565d54 --- /dev/null +++ b/tools/make-v8.sh @@ -0,0 +1,38 @@ +#!/bin/bash + + +git_origin=$(git config --get remote.origin.url | sed 's/.\+[\/:]\([^\/]\+\/[^\/]\+\)$/\1/') +git_branch=$(git rev-parse --abbrev-ref HEAD) +v8ver=${1:-v8} #default v8 +svn_prefix=https://github.com +svn_path="$svn_prefix/$git_origin/branches/$git_branch/deps/$v8ver" +#svn_path="$git_origin/branches/$git_branch/deps/$v8ver" +gclient_string="solutions = [{'name': 'v8', 'url': '$svn_path', 'managed': False}]" + +# clean up if someone presses ctrl-c +trap cleanup INT + +function cleanup() { + trap - INT + + rm .gclient || true + rm .gclient_entries || true + rm -rf _bad_scm/ || true + + #if v8ver isn't v8, move the v8 folders + #back to what they were + if [ "$v8ver" != "v8" ]; then + mv v8 $v8ver + mv .v8old v8 + fi + exit 0 +} + +cd deps +echo $gclient_string > .gclient +if [ "$v8ver" != "v8" ]; then + mv v8 .v8old + mv $v8ver v8 +fi +gclient sync +cleanup From 98099924361d740d06ae5b59329c76113bf8272d Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 28 Jun 2016 01:18:54 -0700 Subject: [PATCH 027/261] deps: backport 9c927d0f01 from V8 upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [test] Set default locale in test runner BUG=v8:4437,v8:2899,chromium:604310 LOG=n Review URL: https://codereview.chromium.org/1402373002 Cr-Commit-Position: refs/heads/master@{#35614} PR-URL: https://github.com/nodejs/node/pull/7451 Reviewed-By: Ben Noordhuis Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- deps/v8/tools/run-tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deps/v8/tools/run-tests.py b/deps/v8/tools/run-tests.py index 76476271f1241a..9e2fd674e5645c 100755 --- a/deps/v8/tools/run-tests.py +++ b/deps/v8/tools/run-tests.py @@ -326,6 +326,9 @@ def ProcessOptions(options): global VARIANT_FLAGS global VARIANTS + # Many tests assume an English interface. + os.environ['LANG'] = 'en_US.UTF-8' + # Architecture and mode related stuff. if options.arch_and_mode: options.arch_and_mode = [arch_and_mode.split(".") From 4c423e649cbe3478f4f326ee243ce9b8d1bbae8b Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 28 Jun 2016 11:35:18 -0700 Subject: [PATCH 028/261] tools: explicit path for V8 test tap output Currently we do not specific an absolute path for the tap output of the V8 test suite. This is proving to be unreliable across release lines. By prepending `$(PWD)` to each path we can guarantee it will always be in the root folder. PR-URL: https://github.com/nodejs/node/pull/7460 Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1823d9b771853e..55ddb86db600ef 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ ifdef QUICKCHECK endif ifdef ENABLE_V8_TAP - TAP_V8 := --junitout v8-tap.xml - TAP_V8_INTL := --junitout v8-intl-tap.xml - TAP_V8_BENCHMARKS := --junitout v8-benchmarks-tap.xml + TAP_V8 := --junitout $(PWD)/v8-tap.xml + TAP_V8_INTL := --junitout $(PWD)/v8-intl-tap.xml + TAP_V8_BENCHMARKS := --junitout $(PWD)/v8-benchmarks-tap.xml endif ifdef DISABLE_V8_I18N From 7d66752f1f2de8173c0804af6ef4f32fcff8462b Mon Sep 17 00:00:00 2001 From: Matt Lavin Date: Tue, 24 May 2016 11:27:00 -0400 Subject: [PATCH 029/261] zlib: release callback and buffer after processing PR-URL: https://github.com/nodejs/node/pull/6955 Reviewed-By: Anna Henningsen Reviewed-By: Yuval Brik --- lib/zlib.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/zlib.js b/lib/zlib.js index 6715ff11604920..ecddfda653f7cb 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -560,6 +560,16 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) { req.callback = callback; function callback(availInAfter, availOutAfter) { + // When the callback is used in an async write, the callback's + // context is the `req` object that was created. The req object + // is === this._handle, and that's why it's important to null + // out the values after they are done being used. `this._handle` + // can stay in memory longer than the callback and buffer are needed. + if (this) { + this.buffer = null; + this.callback = null; + } + if (self._hadError) return; From b9dfdfe1d32fe765c1351b784830ebec3800cc07 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 20 May 2016 22:55:37 +0200 Subject: [PATCH 030/261] vm: don't abort process when stack space runs out Make less assumptions about what objects will be available when vm context creation or error message printing fail because V8 runs out of JS stack space. Ref: https://github.com/nodejs/node/issues/6899 PR-URL: https://github.com/nodejs/node/pull/6907 Reviewed-By: Ben Noordhuis --- src/node_contextify.cc | 6 +++++- test/parallel/test-vm-low-stack-space.js | 26 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-vm-low-stack-space.js diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 18bbc580054349..7b4d472d94e0cb 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -205,7 +205,11 @@ class ContextifyContext { Local ctx = Context::New(env->isolate(), nullptr, object_template); - CHECK(!ctx.IsEmpty()); + if (ctx.IsEmpty()) { + env->ThrowError("Could not instantiate context"); + return Local(); + } + ctx->SetSecurityToken(env->context()->GetSecurityToken()); // We need to tie the lifetime of the sandbox object with the lifetime of diff --git a/test/parallel/test-vm-low-stack-space.js b/test/parallel/test-vm-low-stack-space.js new file mode 100644 index 00000000000000..7c1313d47c1ad9 --- /dev/null +++ b/test/parallel/test-vm-low-stack-space.js @@ -0,0 +1,26 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const vm = require('vm'); + +function a() { + try { + return a(); + } catch (e) { + // Throw an exception as near to the recursion-based RangeError as possible. + return vm.runInThisContext('() => 42')(); + } +} + +assert.strictEqual(a(), 42); + +function b() { + try { + return b(); + } catch (e) { + // This writes a lot of noise to stderr, but it still works. + return vm.runInNewContext('() => 42')(); + } +} + +assert.strictEqual(b(), 42); From 5782ec24273706dbacd669d36c14d89d78ea230b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 20 May 2016 23:11:27 +0200 Subject: [PATCH 031/261] module: don't cache uninitialized builtins Don't cache the exported values of fully uninitialized builtins. This works by adding an additional `loading` flag that is only active during initial loading of an internal module and checking that either the module is fully loaded or is in that state before using its cached value. This has the effect that builtins modules which could not be loaded (e.g. because compilation failed due to missing stack space) can be loaded at a later point. Fixes: https://github.com/nodejs/node/issues/6899 Ref: https://github.com/nodejs/node/issues/6899 PR-URL: https://github.com/nodejs/node/pull/6907 Reviewed-By: Ben Noordhuis --- src/node.js | 20 +++++++++++++------- test/message/console_low_stack_space.js | 22 ++++++++++++++++++++++ test/message/console_low_stack_space.out | 1 + 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 test/message/console_low_stack_space.js create mode 100644 test/message/console_low_stack_space.out diff --git a/src/node.js b/src/node.js index 7301d9d114ed98..a4d86da6a93a69 100644 --- a/src/node.js +++ b/src/node.js @@ -877,6 +877,7 @@ this.id = id; this.exports = {}; this.loaded = false; + this.loading = true; } NativeModule._source = process.binding('natives'); @@ -888,7 +889,7 @@ } var cached = NativeModule.getCached(id); - if (cached) { + if (cached && (cached.loaded || cached.loading)) { return cached.exports; } @@ -952,13 +953,18 @@ var source = NativeModule.getSource(this.id); source = NativeModule.wrap(source); - var fn = runInThisContext(source, { - filename: this.filename, - lineOffset: 0 - }); - fn(this.exports, NativeModule.require, this, this.filename); + this.loading = true; + try { + var fn = runInThisContext(source, { + filename: this.filename, + lineOffset: 0 + }); + fn(this.exports, NativeModule.require, this, this.filename); - this.loaded = true; + this.loaded = true; + } finally { + this.loading = false; + } }; NativeModule.prototype.cache = function() { diff --git a/test/message/console_low_stack_space.js b/test/message/console_low_stack_space.js new file mode 100644 index 00000000000000..1685a35a1f9304 --- /dev/null +++ b/test/message/console_low_stack_space.js @@ -0,0 +1,22 @@ +'use strict'; +// copy console accessor because requiring ../common touches it +const consoleDescriptor = Object.getOwnPropertyDescriptor(global, 'console'); +delete global.console; +global.console = {}; + +require('../common'); + +function a() { + try { + return a(); + } catch (e) { + const console = consoleDescriptor.get(); + if (console.log) { + console.log('Hello, World!'); + } else { + throw e; + } + } +} + +a(); diff --git a/test/message/console_low_stack_space.out b/test/message/console_low_stack_space.out new file mode 100644 index 00000000000000..8ab686eafeb1f4 --- /dev/null +++ b/test/message/console_low_stack_space.out @@ -0,0 +1 @@ +Hello, World! From d9e9d9fb11f05f55d7f0b2a7d88e88b544cee4bb Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 14 Jun 2016 22:39:06 -0700 Subject: [PATCH 032/261] deps: backport e7cc609 from upstream V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is part 1/2 of the fixes from v8:4871. This fixes a segfault in verify-heap. Original commit message: [crankshaft] Write fillers for folded old space allocations during verify-heap If we don't write fillers, we crash during PagedSpace verification when we try to iterate over dead memory (unused folded allocation slots). BUG=v8:4871,chromium:580959 LOG=N Review URL: https://codereview.chromium.org/1837163002 Cr-Commit-Position: refs/heads/master@{#35097} Fixes: https://github.com/nodejs/node/issues/5900 V8-Bug: https://bugs.chromium.org/p/v8/issues/detail?id=4871 PR-URL: https://github.com/nodejs/node/pull/7303 Reviewed-By: Michaël Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Fedor Indutny Reviewed-By: Myles Borins --- deps/v8/src/hydrogen-instructions.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/v8/src/hydrogen-instructions.cc b/deps/v8/src/hydrogen-instructions.cc index 2843195e867747..bf3c82ecb60e88 100644 --- a/deps/v8/src/hydrogen-instructions.cc +++ b/deps/v8/src/hydrogen-instructions.cc @@ -3825,12 +3825,12 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, } } - bool keep_new_space_iterable = FLAG_log_gc || FLAG_heap_stats; + bool keep_heap_iterable = FLAG_log_gc || FLAG_heap_stats; #ifdef VERIFY_HEAP - keep_new_space_iterable = keep_new_space_iterable || FLAG_verify_heap; + keep_heap_iterable = keep_heap_iterable || FLAG_verify_heap; #endif - if (keep_new_space_iterable && dominator_allocate->IsNewSpaceAllocation()) { + if (keep_heap_iterable) { dominator_allocate->MakePrefillWithFiller(); } else { // TODO(hpayer): This is a short-term hack to make allocation mementos From 1164f542db8dc043678d9c419bbfa3a9603731da Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 14 Jun 2016 22:51:31 -0700 Subject: [PATCH 033/261] deps: fix segfault during gc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is part 2/2 of the fixes needed for v8:4871. This fix never landed upstream because the bug is not present in active V8 version. The patch is available from the upstream v8 bug however. The segfault occurs at the intersection of the following three conditions that are dependent on the allocation pattern of an application: A pretenured (1) allocation site has to be optimized into a merged allocation by the allocation folding optimization (2) and there needs to be overflow of the store buffer (3). This patch disables the allocation folding optimization for pretenured allocations. This may have some, hopefully negligible, performance impact on real world applications. Fixes: https://github.com/nodejs/node/issues/5900 PR-URL: https://github.com/nodejs/node/pull/7303 Reviewed-By: Michaël Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Fedor Indutny Reviewed-By: Myles Borins --- deps/v8/src/hydrogen-instructions.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/v8/src/hydrogen-instructions.cc b/deps/v8/src/hydrogen-instructions.cc index bf3c82ecb60e88..0d04ceb1b5262a 100644 --- a/deps/v8/src/hydrogen-instructions.cc +++ b/deps/v8/src/hydrogen-instructions.cc @@ -3693,6 +3693,11 @@ Representation HUnaryMathOperation::RepresentationFromInputs() { bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect, HValue* dominator) { + if (IsOldSpaceAllocation()) { + // Do not fold old space allocations because the store buffer might need + // to iterate old space pages during scavenges on overflow. + return false; + } DCHECK(side_effect == kNewSpacePromotion); Zone* zone = block()->zone(); Isolate* isolate = block()->isolate(); From 0b8124f205723d197ea2f0fd93e566234abbac09 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 20 May 2016 19:10:48 -0400 Subject: [PATCH 034/261] child_process: emit IPC messages on next tick Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- lib/internal/child_process.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index f482d85a2c84d3..3613bfd0efeec8 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -692,7 +692,9 @@ function handleMessage(target, message, handle) { message.cmd.slice(0, INTERNAL_PREFIX.length) === INTERNAL_PREFIX) { eventName = 'internalMessage'; } - target.emit(eventName, message, handle); + process.nextTick(() => { + target.emit(eventName, message, handle); + }); } function nop() { } From c0a42bc040b0770e176beaa29323bbc48f30aa78 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 21 May 2016 15:54:30 +0200 Subject: [PATCH 035/261] test: verify IPC messages are emitted on next tick The test in this commit runs correctly if IPC messages are properly consumed and emitted. Otherwise, the test times out. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-cluster-ipc-throw.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-cluster-ipc-throw.js diff --git a/test/parallel/test-cluster-ipc-throw.js b/test/parallel/test-cluster-ipc-throw.js new file mode 100644 index 00000000000000..f2e7f2822c7315 --- /dev/null +++ b/test/parallel/test-cluster-ipc-throw.js @@ -0,0 +1,23 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_RR; + +const server = http.createServer(); + +if (cluster.isMaster) { + server.listen(common.PORT); + const worker = cluster.fork(); + worker.on('exit', common.mustCall(() => { + server.close(); + })); +} else { + process.on('uncaughtException', common.mustCall((e) => {})); + server.listen(common.PORT); + server.on('error', common.mustCall((e) => { + cluster.worker.disconnect(); + throw e; + })); +} From f152adf5b7af8f19c91d5217d921cc0abe2d514a Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 23 May 2016 10:55:48 -0400 Subject: [PATCH 036/261] cluster: close ownerless handles on disconnect() When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- lib/cluster.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cluster.js b/lib/cluster.js index e4bbd5f3ff7838..62eb78eeba113e 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -703,7 +703,11 @@ function workerInit() { const handle = handles[key]; delete handles[key]; waitingCount++; - handle.owner.close(checkWaitingCount); + + if (handle.owner) + handle.owner.close(checkWaitingCount); + else + handle.close(checkWaitingCount); } checkWaitingCount(); From 72fb2819610b4d78d13f7bae373b92fcc7d9d0ad Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 22 Feb 2016 02:55:55 -0600 Subject: [PATCH 037/261] util: improve util.format performance By manually copying arguments and breaking the try/catch out, we are able to improve the performance of util.format by 20-100% (depending on the types). PR-URL: https://github.com/nodejs/node/pull/5360 Reviewed-By: James M Snell --- lib/util.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/util.js b/lib/util.js index c370d9509e1ca3..f56d812eee26f3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -9,39 +9,48 @@ const isError = internalUtil.isError; var Debug; +function tryStringify(arg) { + try { + return JSON.stringify(arg); + } catch (_) { + return '[Circular]'; + } +} + const formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (typeof f !== 'string') { - var objects = []; + const objects = new Array(arguments.length); for (var index = 0; index < arguments.length; index++) { - objects.push(inspect(arguments[index])); + objects[index] = inspect(arguments[index]); } return objects.join(' '); } if (arguments.length === 1) return f; - var i = 1; - var args = arguments; - var len = args.length; - var str = String(f).replace(formatRegExp, function(x) { + const len = arguments.length; + const args = new Array(len); + var i; + for (i = 0; i < len; i++) { + args[i] = arguments[i]; + } + + i = 1; + var str = f.replace(formatRegExp, function(x) { if (x === '%%') return '%'; if (i >= len) return x; switch (x) { case '%s': return String(args[i++]); case '%d': return Number(args[i++]); - case '%j': - try { - return JSON.stringify(args[i++]); - } catch (_) { - return '[Circular]'; - } + case '%j': return tryStringify(args[i++]); // falls through default: return x; } }); - for (var x = args[i]; i < len; x = args[++i]) { + while (i < len) { + const x = args[i++]; if (x === null || (typeof x !== 'object' && typeof x !== 'symbol')) { str += ' ' + x; } else { From d0bf09d3ad9ad1c325cb4aef11ad1e7c42b98f71 Mon Sep 17 00:00:00 2001 From: Brian White Date: Mon, 22 Feb 2016 20:47:20 -0500 Subject: [PATCH 038/261] util: improve format() performance further Replacing the regexp and replace function with a loop improves performance by ~60-200%. PR-URL: https://github.com/nodejs/node/pull/5360 Reviewed-By: James M Snell --- lib/util.js | 73 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/lib/util.js b/lib/util.js index f56d812eee26f3..79fdb33326ebc9 100644 --- a/lib/util.js +++ b/lib/util.js @@ -17,7 +17,6 @@ function tryStringify(arg) { } } -const formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (typeof f !== 'string') { const objects = new Array(arguments.length); @@ -27,30 +26,56 @@ exports.format = function(f) { return objects.join(' '); } - if (arguments.length === 1) return f; - - const len = arguments.length; - const args = new Array(len); - var i; - for (i = 0; i < len; i++) { - args[i] = arguments[i]; - } - - i = 1; - var str = f.replace(formatRegExp, function(x) { - if (x === '%%') return '%'; - if (i >= len) return x; - switch (x) { - case '%s': return String(args[i++]); - case '%d': return Number(args[i++]); - case '%j': return tryStringify(args[i++]); - // falls through - default: - return x; + var argLen = arguments.length; + + if (argLen === 1) return f; + + var str = ''; + var a = 1; + var lastPos = 0; + for (var i = 0; i < f.length;) { + if (f.charCodeAt(i) === 37/*'%'*/ && i + 1 < f.length) { + switch (f.charCodeAt(i + 1)) { + case 100: // 'd' + if (a >= argLen) + break; + if (lastPos < i) + str += f.slice(lastPos, i); + str += Number(arguments[a++]); + lastPos = i = i + 2; + continue; + case 106: // 'j' + if (a >= argLen) + break; + if (lastPos < i) + str += f.slice(lastPos, i); + str += tryStringify(arguments[a++]); + lastPos = i = i + 2; + continue; + case 115: // 's' + if (a >= argLen) + break; + if (lastPos < i) + str += f.slice(lastPos, i); + str += String(arguments[a++]); + lastPos = i = i + 2; + continue; + case 37: // '%' + if (lastPos < i) + str += f.slice(lastPos, i); + str += '%'; + lastPos = i = i + 2; + continue; + } } - }); - while (i < len) { - const x = args[i++]; + ++i; + } + if (lastPos === 0) + str = f; + else if (lastPos < f.length) + str += f.slice(lastPos); + while (a < argLen) { + const x = arguments[a++]; if (x === null || (typeof x !== 'object' && typeof x !== 'symbol')) { str += ' ' + x; } else { From 9aec1ddb4f8862b1e0f521e76ca84f4727d06bce Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 23 May 2016 20:04:24 +0200 Subject: [PATCH 039/261] test: test cluster worker disconnection on error This test checks that ownerless cluster worker handles are closed correctly on disconnection. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- ...test-cluster-worker-disconnect-on-error.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/parallel/test-cluster-worker-disconnect-on-error.js diff --git a/test/parallel/test-cluster-worker-disconnect-on-error.js b/test/parallel/test-cluster-worker-disconnect-on-error.js new file mode 100644 index 00000000000000..e52f7ddee60993 --- /dev/null +++ b/test/parallel/test-cluster-worker-disconnect-on-error.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_NONE; + +const server = http.createServer(); +if (cluster.isMaster) { + server.listen(common.PORT); + const worker = cluster.fork(); + worker.on('exit', common.mustCall(() => { + server.close(); + })); +} else { + server.listen(common.PORT); + server.on('error', common.mustCall((e) => { + cluster.worker.disconnect(); + })); +} From 8513232c825188f0ee926201b2afc13629cd0725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Wed, 15 Jun 2016 13:42:21 +0100 Subject: [PATCH 040/261] build: split CI rules in Makefile Some CI jobs compile Node and run the tests on different machines. This change enables collaborators to have finer control over what runs on these jobs, such as the exact suites to run. The test-ci rule was split into js and native, to allow for addons to be compiled only on the machines that are going to run them. Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel Reviewed-By: Rod Vagg PR-URL: https://github.com/nodejs/node/pull/7317 --- Makefile | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 55ddb86db600ef..86fe1da1ee29ee 100644 --- a/Makefile +++ b/Makefile @@ -166,9 +166,24 @@ test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node test-all-valgrind: test-build $(PYTHON) tools/test.py --mode=debug,release --valgrind +CI_NATIVE_SUITES := addons +CI_JS_SUITES := doctool message parallel sequential + +# Build and test addons without building anything else +test-ci-native: | test/addons/.buildstamp + $(PYTHON) tools/test.py -p tap --logfile test.tap \ + --mode=release --flaky-tests=$(FLAKY_TESTS) \ + $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) + +# This target should not use a native compiler at all +test-ci-js: + $(PYTHON) tools/test.py -p tap --logfile test.tap \ + --mode=release --flaky-tests=$(FLAKY_TESTS) \ + $(TEST_CI_ARGS) $(CI_JS_SUITES) + test-ci: | build-addons $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release --flaky-tests=$(FLAKY_TESTS) \ - $(TEST_CI_ARGS) addons doctool message parallel sequential + $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) $(CI_JS_SUITES) test-release: test-build $(PYTHON) tools/test.py --mode=release @@ -265,9 +280,11 @@ docopen: out/doc/api/all.html docclean: -rm -rf out/doc -run-ci: +build-ci: $(PYTHON) ./configure $(CONFIG_FLAGS) $(MAKE) + +run-ci: build-ci $(MAKE) test-ci RAWVER=$(shell $(PYTHON) tools/getnodeversion.py) @@ -650,4 +667,5 @@ lint-ci: lint blog blogclean tar binary release-only bench-http-simple bench-idle \ bench-all bench bench-misc bench-array bench-buffer bench-net \ bench-http bench-fs bench-tls cctest run-ci lint-ci bench-ci \ - test-v8 test-v8-intl test-v8-benchmarks test-v8-all v8 $(TARBALL)-headers + test-v8 test-v8-intl test-v8-benchmarks test-v8-all v8 \ + $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci From e06ab6470572bd55b7a47f67795769ee4cf2aa36 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 8 Jun 2016 01:00:25 -0400 Subject: [PATCH 041/261] deps: update to http-parser 2.7.0 Adds `2` as a return value of `on_headers_complete`, this mode will be used to fix handling responses to `CONNECT` requests. See: https://github.com/nodejs/node/pull/6198 PR-URL: https://github.com/nodejs/node/pull/6279 Reviewed-By: Brian White Reviewed-By: James M Snell --- deps/http_parser/AUTHORS | 1 + deps/http_parser/Makefile | 31 +++- deps/http_parser/README.md | 71 +++++++- deps/http_parser/contrib/url_parser.c | 3 +- deps/http_parser/http_parser.c | 157 +++++++++--------- deps/http_parser/http_parser.h | 48 ++++-- deps/http_parser/test.c | 226 +++++++++++++++++++++++--- 7 files changed, 415 insertions(+), 122 deletions(-) diff --git a/deps/http_parser/AUTHORS b/deps/http_parser/AUTHORS index 8e2df1d06e6f69..5323b685caefb9 100644 --- a/deps/http_parser/AUTHORS +++ b/deps/http_parser/AUTHORS @@ -65,3 +65,4 @@ Romain Giraud Jay Satiro Arne Steen Kjell Schubert +Olivier Mengué diff --git a/deps/http_parser/Makefile b/deps/http_parser/Makefile index b96b3e266bcf5f..5f4eb2252f241b 100644 --- a/deps/http_parser/Makefile +++ b/deps/http_parser/Makefile @@ -19,7 +19,19 @@ # IN THE SOFTWARE. PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') -SONAME ?= libhttp_parser.so.2.5.2 +HELPER ?= +BINEXT ?= +ifeq (darwin,$(PLATFORM)) +SONAME ?= libhttp_parser.2.7.0.dylib +SOEXT ?= dylib +else ifeq (wine,$(PLATFORM)) +CC = winegcc +BINEXT = .exe.so +HELPER = wine +else +SONAME ?= libhttp_parser.so.2.7.0 +SOEXT ?= so +endif CC?=gcc AR?=ar @@ -53,8 +65,8 @@ LDFLAGS_LIB += -Wl,-soname=$(SONAME) endif test: test_g test_fast - ./test_g - ./test_fast + $(HELPER) ./test_g$(BINEXT) + $(HELPER) ./test_fast$(BINEXT) test_g: http_parser_g.o test_g.o $(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@ @@ -81,7 +93,7 @@ http_parser.o: http_parser.c http_parser.h Makefile $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c test-run-timed: test_fast - while(true) do time ./test_fast > /dev/null; done + while(true) do time $(HELPER) ./test_fast$(BINEXT) > /dev/null; done test-valgrind: test_g valgrind ./test_g @@ -102,10 +114,10 @@ url_parser_g: http_parser_g.o contrib/url_parser.c $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@ parsertrace: http_parser.o contrib/parsertrace.c - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace + $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT) parsertrace_g: http_parser_g.o contrib/parsertrace.c - $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g + $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT) tags: http_parser.c http_parser.h test.c ctags $^ @@ -113,12 +125,12 @@ tags: http_parser.c http_parser.h test.c install: library $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h $(INSTALL) -D $(SONAME) $(LIBDIR)/$(SONAME) - ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so + ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT) install-strip: library $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h $(INSTALL) -D -s $(SONAME) $(LIBDIR)/$(SONAME) - ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so + ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT) uninstall: rm $(INCLUDEDIR)/http_parser.h @@ -128,7 +140,8 @@ uninstall: clean: rm -f *.o *.a tags test test_fast test_g \ http_parser.tar libhttp_parser.so.* \ - url_parser url_parser_g parsertrace parsertrace_g + url_parser url_parser_g parsertrace parsertrace_g \ + *.exe *.exe.so contrib/url_parser.c: http_parser.h contrib/parsertrace.c: http_parser.h diff --git a/deps/http_parser/README.md b/deps/http_parser/README.md index 7c54dd42d087c3..439b30998d43dd 100644 --- a/deps/http_parser/README.md +++ b/deps/http_parser/README.md @@ -1,7 +1,7 @@ HTTP Parser =========== -[![Build Status](https://travis-ci.org/joyent/http-parser.png?branch=master)](https://travis-ci.org/joyent/http-parser) +[![Build Status](https://api.travis-ci.org/nodejs/http-parser.svg?branch=master)](https://travis-ci.org/nodejs/http-parser) This is a parser for HTTP messages written in C. It parses both requests and responses. The parser is designed to be used in performance HTTP @@ -94,7 +94,7 @@ The Special Problem of Upgrade ------------------------------ HTTP supports upgrading the connection to a different protocol. An -increasingly common example of this is the Web Socket protocol which sends +increasingly common example of this is the WebSocket protocol which sends a request like GET /demo HTTP/1.1 @@ -106,8 +106,8 @@ a request like followed by non-HTTP data. -(See http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 for more -information the Web Socket protocol.) +(See [RFC6455](https://tools.ietf.org/html/rfc6455) for more information the +WebSocket protocol.) To support this, the parser will treat this as a normal HTTP message without a body, issuing both on_headers_complete and on_message_complete callbacks. However @@ -137,6 +137,69 @@ There are two types of callbacks: Callbacks must return 0 on success. Returning a non-zero value indicates error to the parser, making it exit immediately. +For cases where it is necessary to pass local information to/from a callback, +the `http_parser` object's `data` field can be used. +An example of such a case is when using threads to handle a socket connection, +parse a request, and then give a response over that socket. By instantiation +of a thread-local struct containing relevant data (e.g. accepted socket, +allocated memory for callbacks to write into, etc), a parser's callbacks are +able to communicate data between the scope of the thread and the scope of the +callback in a threadsafe manner. This allows http-parser to be used in +multi-threaded contexts. + +Example: +```c + typedef struct { + socket_t sock; + void* buffer; + int buf_len; + } custom_data_t; + + +int my_url_callback(http_parser* parser, const char *at, size_t length) { + /* access to thread local custom_data_t struct. + Use this access save parsed data for later use into thread local + buffer, or communicate over socket + */ + parser->data; + ... + return 0; +} + +... + +void http_parser_thread(socket_t sock) { + int nparsed = 0; + /* allocate memory for user data */ + custom_data_t *my_data = malloc(sizeof(custom_data_t)); + + /* some information for use by callbacks. + * achieves thread -> callback information flow */ + my_data->sock = sock; + + /* instantiate a thread-local parser */ + http_parser *parser = malloc(sizeof(http_parser)); + http_parser_init(parser, HTTP_REQUEST); /* initialise parser */ + /* this custom data reference is accessible through the reference to the + parser supplied to callback functions */ + parser->data = my_data; + + http_parser_settings settings; /* set up callbacks */ + settings.on_url = my_url_callback; + + /* execute parser */ + nparsed = http_parser_execute(parser, &settings, buf, recved); + + ... + /* parsed information copied from callback. + can now perform action on data copied into thread-local memory from callbacks. + achieves callback -> thread information flow */ + my_data->buffer; + ... +} + +``` + In case you parse HTTP message in chunks (i.e. `read()` request line from socket, parse, read half headers, parse, etc) your data callbacks may be called more than once. Http-parser guarantees that data pointer is only diff --git a/deps/http_parser/contrib/url_parser.c b/deps/http_parser/contrib/url_parser.c index 6650b414af9065..f235bed9e483dc 100644 --- a/deps/http_parser/contrib/url_parser.c +++ b/deps/http_parser/contrib/url_parser.c @@ -35,6 +35,7 @@ int main(int argc, char ** argv) { connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; printf("Parsing %s, connect %d\n", argv[2], connect); + http_parser_url_init(&u); result = http_parser_parse_url(argv[2], len, connect, &u); if (result != 0) { printf("Parse error : %d\n", result); @@ -43,4 +44,4 @@ int main(int argc, char ** argv) { printf("Parse ok, result : \n"); dump_url(argv[2], &u); return 0; -} \ No newline at end of file +} diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c index 228d130cb5e30f..3c896ffadcc0db 100644 --- a/deps/http_parser/http_parser.c +++ b/deps/http_parser/http_parser.c @@ -123,7 +123,7 @@ do { \ FOR##_mark = NULL; \ } \ } while (0) - + /* Run the data callback FOR and consume the current byte */ #define CALLBACK_DATA(FOR) \ CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) @@ -400,6 +400,8 @@ enum http_host_state , s_http_host , s_http_host_v6 , s_http_host_v6_end + , s_http_host_v6_zone_start + , s_http_host_v6_zone , s_http_host_port_start , s_http_host_port }; @@ -643,7 +645,6 @@ size_t http_parser_execute (http_parser *parser, const char *body_mark = 0; const char *status_mark = 0; enum state p_state = (enum state) parser->state; - const unsigned int lenient = parser->lenient_http_headers; /* We're in an error state. Don't bother doing anything. */ @@ -965,21 +966,23 @@ size_t http_parser_execute (http_parser *parser, parser->method = (enum http_method) 0; parser->index = 1; switch (ch) { + case 'A': parser->method = HTTP_ACL; break; + case 'B': parser->method = HTTP_BIND; break; case 'C': parser->method = HTTP_CONNECT; /* or COPY, CHECKOUT */ break; case 'D': parser->method = HTTP_DELETE; break; case 'G': parser->method = HTTP_GET; break; case 'H': parser->method = HTTP_HEAD; break; - case 'L': parser->method = HTTP_LOCK; break; + case 'L': parser->method = HTTP_LOCK; /* or LINK */ break; case 'M': parser->method = HTTP_MKCOL; /* or MOVE, MKACTIVITY, MERGE, M-SEARCH, MKCALENDAR */ break; case 'N': parser->method = HTTP_NOTIFY; break; case 'O': parser->method = HTTP_OPTIONS; break; case 'P': parser->method = HTTP_POST; /* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */ break; - case 'R': parser->method = HTTP_REPORT; break; + case 'R': parser->method = HTTP_REPORT; /* or REBIND */ break; case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break; case 'T': parser->method = HTTP_TRACE; break; - case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break; + case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE, UNBIND, UNLINK */ break; default: SET_ERRNO(HPE_INVALID_METHOD); goto error; @@ -1004,69 +1007,40 @@ size_t http_parser_execute (http_parser *parser, UPDATE_STATE(s_req_spaces_before_url); } else if (ch == matcher[parser->index]) { ; /* nada */ - } else if (parser->method == HTTP_CONNECT) { - if (parser->index == 1 && ch == 'H') { - parser->method = HTTP_CHECKOUT; - } else if (parser->index == 2 && ch == 'P') { - parser->method = HTTP_COPY; - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; - } - } else if (parser->method == HTTP_MKCOL) { - if (parser->index == 1 && ch == 'O') { - parser->method = HTTP_MOVE; - } else if (parser->index == 1 && ch == 'E') { - parser->method = HTTP_MERGE; - } else if (parser->index == 1 && ch == '-') { - parser->method = HTTP_MSEARCH; - } else if (parser->index == 2 && ch == 'A') { - parser->method = HTTP_MKACTIVITY; - } else if (parser->index == 3 && ch == 'A') { - parser->method = HTTP_MKCALENDAR; - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; - } - } else if (parser->method == HTTP_SUBSCRIBE) { - if (parser->index == 1 && ch == 'E') { - parser->method = HTTP_SEARCH; - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; - } - } else if (parser->index == 1 && parser->method == HTTP_POST) { - if (ch == 'R') { - parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ - } else if (ch == 'U') { - parser->method = HTTP_PUT; /* or HTTP_PURGE */ - } else if (ch == 'A') { - parser->method = HTTP_PATCH; - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; - } - } else if (parser->index == 2) { - if (parser->method == HTTP_PUT) { - if (ch == 'R') { - parser->method = HTTP_PURGE; - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; - } - } else if (parser->method == HTTP_UNLOCK) { - if (ch == 'S') { - parser->method = HTTP_UNSUBSCRIBE; - } else { + } else if (IS_ALPHA(ch)) { + + switch (parser->method << 16 | parser->index << 8 | ch) { +#define XX(meth, pos, ch, new_meth) \ + case (HTTP_##meth << 16 | pos << 8 | ch): \ + parser->method = HTTP_##new_meth; break; + + XX(POST, 1, 'U', PUT) + XX(POST, 1, 'A', PATCH) + XX(CONNECT, 1, 'H', CHECKOUT) + XX(CONNECT, 2, 'P', COPY) + XX(MKCOL, 1, 'O', MOVE) + XX(MKCOL, 1, 'E', MERGE) + XX(MKCOL, 2, 'A', MKACTIVITY) + XX(MKCOL, 3, 'A', MKCALENDAR) + XX(SUBSCRIBE, 1, 'E', SEARCH) + XX(REPORT, 2, 'B', REBIND) + XX(POST, 1, 'R', PROPFIND) + XX(PROPFIND, 4, 'P', PROPPATCH) + XX(PUT, 2, 'R', PURGE) + XX(LOCK, 1, 'I', LINK) + XX(UNLOCK, 2, 'S', UNSUBSCRIBE) + XX(UNLOCK, 2, 'B', UNBIND) + XX(UNLOCK, 3, 'I', UNLINK) +#undef XX + + default: SET_ERRNO(HPE_INVALID_METHOD); goto error; - } - } else { - SET_ERRNO(HPE_INVALID_METHOD); - goto error; } - } else if (parser->index == 4 && parser->method == HTTP_PROPFIND && ch == 'P') { - parser->method = HTTP_PROPPATCH; + } else if (ch == '-' && + parser->index == 1 && + parser->method == HTTP_MKCOL) { + parser->method = HTTP_MSEARCH; } else { SET_ERRNO(HPE_INVALID_METHOD); goto error; @@ -1838,6 +1812,9 @@ size_t http_parser_execute (http_parser *parser, case 0: break; + case 2: + parser->upgrade = 1; + case 1: parser->flags |= F_SKIPBODY; break; @@ -1857,11 +1834,12 @@ size_t http_parser_execute (http_parser *parser, case s_headers_done: { + int hasBody; STRICT_CHECK(ch != LF); parser->nread = 0; - int hasBody = parser->flags & F_CHUNKED || + hasBody = parser->flags & F_CHUNKED || (parser->content_length > 0 && parser->content_length != ULLONG_MAX); if (parser->upgrade && (parser->method == HTTP_CONNECT || (parser->flags & F_SKIPBODY) || !hasBody)) { @@ -1886,8 +1864,7 @@ size_t http_parser_execute (http_parser *parser, /* Content-Length header given and non-zero */ UPDATE_STATE(s_body_identity); } else { - if (parser->type == HTTP_REQUEST || - !http_message_needs_eof(parser)) { + if (!http_message_needs_eof(parser)) { /* Assume content-length 0 - read the next */ UPDATE_STATE(NEW_MESSAGE()); CALLBACK_NOTIFY(message_complete); @@ -2182,15 +2159,13 @@ http_parser_settings_init(http_parser_settings *settings) const char * http_errno_name(enum http_errno err) { - assert(((size_t) err) < - (sizeof(http_strerror_tab) / sizeof(http_strerror_tab[0]))); + assert(((size_t) err) < ARRAY_SIZE(http_strerror_tab)); return http_strerror_tab[err].name; } const char * http_errno_description(enum http_errno err) { - assert(((size_t) err) < - (sizeof(http_strerror_tab) / sizeof(http_strerror_tab[0]))); + assert(((size_t) err) < ARRAY_SIZE(http_strerror_tab)); return http_strerror_tab[err].description; } @@ -2243,6 +2218,23 @@ http_parse_host_char(enum http_host_state s, const char ch) { return s_http_host_v6; } + if (s == s_http_host_v6 && ch == '%') { + return s_http_host_v6_zone_start; + } + break; + + case s_http_host_v6_zone: + if (ch == ']') { + return s_http_host_v6_end; + } + + /* FALLTHROUGH */ + case s_http_host_v6_zone_start: + /* RFC 6874 Zone ID consists of 1*( unreserved / pct-encoded) */ + if (IS_ALPHANUM(ch) || ch == '%' || ch == '.' || ch == '-' || ch == '_' || + ch == '~') { + return s_http_host_v6_zone; + } break; case s_http_host_port: @@ -2266,6 +2258,8 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { const char *p; size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len; + assert(u->field_set & (1 << UF_HOST)); + u->field_data[UF_HOST].len = 0; s = found_at ? s_http_userinfo_start : s_http_host_start; @@ -2292,6 +2286,11 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { u->field_data[UF_HOST].len++; break; + case s_http_host_v6_zone_start: + case s_http_host_v6_zone: + u->field_data[UF_HOST].len++; + break; + case s_http_host_port: if (s != s_http_host_port) { u->field_data[UF_PORT].off = p - buf; @@ -2321,6 +2320,8 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { case s_http_host_start: case s_http_host_v6_start: case s_http_host_v6: + case s_http_host_v6_zone_start: + case s_http_host_v6_zone: case s_http_host_port_start: case s_http_userinfo: case s_http_userinfo_start: @@ -2332,6 +2333,11 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) { return 0; } +void +http_parser_url_init(struct http_parser_url *u) { + memset(u, 0, sizeof(*u)); +} + int http_parser_parse_url(const char *buf, size_t buflen, int is_connect, struct http_parser_url *u) @@ -2405,7 +2411,12 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect, /* host must be present if there is a schema */ /* parsing http:///toto will fail */ - if ((u->field_set & ((1 << UF_SCHEMA) | (1 << UF_HOST))) != 0) { + if ((u->field_set & (1 << UF_SCHEMA)) && + (u->field_set & (1 << UF_HOST)) == 0) { + return 1; + } + + if (u->field_set & (1 << UF_HOST)) { if (http_parse_host(buf, u, found_at) != 0) { return 1; } diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h index 39b3f23c5a13f5..105ae510a8ab57 100644 --- a/deps/http_parser/http_parser.h +++ b/deps/http_parser/http_parser.h @@ -26,11 +26,12 @@ extern "C" { /* Also update SONAME in the Makefile whenever you change these. */ #define HTTP_PARSER_VERSION_MAJOR 2 -#define HTTP_PARSER_VERSION_MINOR 5 -#define HTTP_PARSER_VERSION_PATCH 2 +#define HTTP_PARSER_VERSION_MINOR 7 +#define HTTP_PARSER_VERSION_PATCH 0 #include -#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600) +#if defined(_WIN32) && !defined(__MINGW32__) && \ + (!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__) #include #include typedef __int8 int8_t; @@ -76,6 +77,11 @@ typedef struct http_parser_settings http_parser_settings; * HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: * chunked' headers that indicate the presence of a body. * + * Returning `2` from on_headers_complete will tell parser that it should not + * expect neither a body nor any futher responses on this connection. This is + * useful for handling responses to a CONNECT request which may not contain + * `Upgrade` or `Connection: upgrade` headers. + * * http_data_cb does not return data chunks. It will be called arbitrarily * many times for each string. E.G. you might get 10 callbacks for "on_url" * each providing just a few characters more data. @@ -95,7 +101,7 @@ typedef int (*http_cb) (http_parser*); XX(5, CONNECT, CONNECT) \ XX(6, OPTIONS, OPTIONS) \ XX(7, TRACE, TRACE) \ - /* webdav */ \ + /* WebDAV */ \ XX(8, COPY, COPY) \ XX(9, LOCK, LOCK) \ XX(10, MKCOL, MKCOL) \ @@ -104,21 +110,28 @@ typedef int (*http_cb) (http_parser*); XX(13, PROPPATCH, PROPPATCH) \ XX(14, SEARCH, SEARCH) \ XX(15, UNLOCK, UNLOCK) \ + XX(16, BIND, BIND) \ + XX(17, REBIND, REBIND) \ + XX(18, UNBIND, UNBIND) \ + XX(19, ACL, ACL) \ /* subversion */ \ - XX(16, REPORT, REPORT) \ - XX(17, MKACTIVITY, MKACTIVITY) \ - XX(18, CHECKOUT, CHECKOUT) \ - XX(19, MERGE, MERGE) \ + XX(20, REPORT, REPORT) \ + XX(21, MKACTIVITY, MKACTIVITY) \ + XX(22, CHECKOUT, CHECKOUT) \ + XX(23, MERGE, MERGE) \ /* upnp */ \ - XX(20, MSEARCH, M-SEARCH) \ - XX(21, NOTIFY, NOTIFY) \ - XX(22, SUBSCRIBE, SUBSCRIBE) \ - XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ + XX(24, MSEARCH, M-SEARCH) \ + XX(25, NOTIFY, NOTIFY) \ + XX(26, SUBSCRIBE, SUBSCRIBE) \ + XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \ /* RFC-5789 */ \ - XX(24, PATCH, PATCH) \ - XX(25, PURGE, PURGE) \ + XX(28, PATCH, PATCH) \ + XX(29, PURGE, PURGE) \ /* CalDAV */ \ - XX(26, MKCALENDAR, MKCALENDAR) \ + XX(30, MKCALENDAR, MKCALENDAR) \ + /* RFC-2068, section 19.6.1.2 */ \ + XX(31, LINK, LINK) \ + XX(32, UNLINK, UNLINK) \ enum http_method { @@ -145,7 +158,7 @@ enum flags /* Map for errno-related constants - * + * * The provided argument should be a macro that takes 2 arguments. */ #define HTTP_ERRNO_MAP(XX) \ @@ -329,6 +342,9 @@ const char *http_errno_name(enum http_errno err); /* Return a string description of the given error */ const char *http_errno_description(enum http_errno err); +/* Initialize all http_parser_url members to 0 */ +void http_parser_url_init(struct http_parser_url *u); + /* Parse a URL; return nonzero on failure */ int http_parser_parse_url(const char *buf, size_t buflen, int is_connect, diff --git a/deps/http_parser/test.c b/deps/http_parser/test.c index 5f754d83c6ac6a..456a78add05e68 100644 --- a/deps/http_parser/test.c +++ b/deps/http_parser/test.c @@ -1101,6 +1101,58 @@ const struct message requests[] = ,.body= "" } +/* Examples from the Internet draft for LINK/UNLINK methods: + * https://tools.ietf.org/id/draft-snell-link-method-01.html#rfc.section.5 + */ + +#define LINK_REQUEST 40 +, {.name = "link request" + ,.type= HTTP_REQUEST + ,.raw= "LINK /images/my_dog.jpg HTTP/1.1\r\n" + "Host: example.com\r\n" + "Link: ; rel=\"tag\"\r\n" + "Link: ; rel=\"tag\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_LINK + ,.request_path= "/images/my_dog.jpg" + ,.request_url= "/images/my_dog.jpg" + ,.query_string= "" + ,.fragment= "" + ,.num_headers= 3 + ,.headers= { { "Host", "example.com" } + , { "Link", "; rel=\"tag\"" } + , { "Link", "; rel=\"tag\"" } + } + ,.body= "" + } + +#define UNLINK_REQUEST 41 +, {.name = "link request" + ,.type= HTTP_REQUEST + ,.raw= "UNLINK /images/my_dog.jpg HTTP/1.1\r\n" + "Host: example.com\r\n" + "Link: ; rel=\"tag\"\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_UNLINK + ,.request_path= "/images/my_dog.jpg" + ,.request_url= "/images/my_dog.jpg" + ,.query_string= "" + ,.fragment= "" + ,.num_headers= 2 + ,.headers= { { "Host", "example.com" } + , { "Link", "; rel=\"tag\"" } + } + ,.body= "" + } + , {.name= NULL } /* sentinel */ }; @@ -2121,6 +2173,20 @@ pause_chunk_complete_cb (http_parser *p) return chunk_complete_cb(p); } +int +connect_headers_complete_cb (http_parser *p) +{ + headers_complete_cb(p); + return 1; +} + +int +connect_message_complete_cb (http_parser *p) +{ + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); + return message_complete_cb(p); +} + static http_parser_settings settings_pause = {.on_message_begin = pause_message_begin_cb ,.on_header_field = pause_header_field_cb @@ -2160,6 +2226,19 @@ static http_parser_settings settings_count_body = ,.on_chunk_complete = chunk_complete_cb }; +static http_parser_settings settings_connect = + {.on_message_begin = message_begin_cb + ,.on_header_field = header_field_cb + ,.on_header_value = header_value_cb + ,.on_url = request_url_cb + ,.on_status = response_status_cb + ,.on_body = dontcall_body_cb + ,.on_headers_complete = connect_headers_complete_cb + ,.on_message_complete = connect_message_complete_cb + ,.on_chunk_header = chunk_header_cb + ,.on_chunk_complete = chunk_complete_cb + }; + static http_parser_settings settings_null = {.on_message_begin = 0 ,.on_header_field = 0 @@ -2223,6 +2302,14 @@ size_t parse_pause (const char *buf, size_t len) return nparsed; } +size_t parse_connect (const char *buf, size_t len) +{ + size_t nparsed; + currently_parsing_eof = (len == 0); + nparsed = http_parser_execute(parser, &settings_connect, buf, len); + return nparsed; +} + static inline int check_str_eq (const struct message *m, const char *prop, @@ -2279,7 +2366,7 @@ do { \ } while(0) int -message_eq (int index, const struct message *expected) +message_eq (int index, int connect, const struct message *expected) { int i; struct message *m = &messages[index]; @@ -2294,8 +2381,10 @@ message_eq (int index, const struct message *expected) MESSAGE_CHECK_STR_EQ(expected, m, response_status); } - MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); - MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); + if (!connect) { + MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); + MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); + } assert(m->message_begin_cb_called); assert(m->headers_complete_cb_called); @@ -2333,16 +2422,22 @@ message_eq (int index, const struct message *expected) MESSAGE_CHECK_NUM_EQ(expected, m, port); } - if (expected->body_size) { + if (connect) { + check_num_eq(m, "body_size", 0, m->body_size); + } else if (expected->body_size) { MESSAGE_CHECK_NUM_EQ(expected, m, body_size); } else { MESSAGE_CHECK_STR_EQ(expected, m, body); } - assert(m->num_chunks == m->num_chunks_complete); - MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete); - for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) { - MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]); + if (connect) { + check_num_eq(m, "num_chunks_complete", 0, m->num_chunks_complete); + } else { + assert(m->num_chunks == m->num_chunks_complete); + MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete); + for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) { + MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]); + } } MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); @@ -2392,7 +2487,7 @@ upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { va_list ap; size_t i; size_t off = 0; - + va_start(ap, nmsgs); for (i = 0; i < nmsgs; i++) { @@ -2918,6 +3013,59 @@ const struct url_test url_tests[] = ,.rv=1 /* s_dead */ } +, {.name="ipv6 address with Zone ID" + ,.url="http://[fe80::a%25eth0]/" + ,.is_connect=0 + ,.u= + {.field_set= (1< 1 && !message_eq(1, r2)) abort(); - if (message_count > 2 && !message_eq(2, r3)) abort(); + if (!message_eq(0, 0, r1)) abort(); + if (message_count > 1 && !message_eq(1, 0, r2)) abort(); + if (message_count > 2 && !message_eq(2, 0, r3)) abort(); parser_free(); } @@ -3582,17 +3730,17 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess goto error; } - if (!message_eq(0, r1)) { + if (!message_eq(0, 0, r1)) { fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); goto error; } - if (message_count > 1 && !message_eq(1, r2)) { + if (message_count > 1 && !message_eq(1, 0, r2)) { fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); goto error; } - if (message_count > 2 && !message_eq(2, r3)) { + if (message_count > 2 && !message_eq(2, 0, r3)) { fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); goto error; } @@ -3691,7 +3839,29 @@ test_message_pause (const struct message *msg) abort(); } - if(!message_eq(0, msg)) abort(); + if(!message_eq(0, 0, msg)) abort(); + + parser_free(); +} + +/* Verify that body and next message won't be parsed in responses to CONNECT */ +void +test_message_connect (const struct message *msg) +{ + char *buf = (char*) msg->raw; + size_t buflen = strlen(msg->raw); + size_t nread; + + parser_init(msg->type); + + nread = parse_connect(buf, buflen); + + if (num_messages != 1) { + printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); + abort(); + } + + if(!message_eq(0, 1, msg)) abort(); parser_free(); } @@ -3762,6 +3932,10 @@ main (void) test_message_pause(&responses[i]); } + for (i = 0; i < response_count; i++) { + test_message_connect(&responses[i]); + } + for (i = 0; i < response_count; i++) { if (!responses[i].should_keep_alive) continue; for (j = 0; j < response_count; j++) { @@ -3828,6 +4002,11 @@ main (void) test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); + // Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js + test_simple("GET / HTTP/1.1\r\n" + "Test: Düsseldorf\r\n", + HPE_OK); + // Well-formed but incomplete test_simple("GET / HTTP/1.1\r\n" "Content-Type: text/plain\r\n" @@ -3851,7 +4030,12 @@ main (void) "MOVE", "PROPFIND", "PROPPATCH", + "SEARCH", "UNLOCK", + "BIND", + "REBIND", + "UNBIND", + "ACL", "REPORT", "MKACTIVITY", "CHECKOUT", @@ -3861,6 +4045,10 @@ main (void) "SUBSCRIBE", "UNSUBSCRIBE", "PATCH", + "PURGE", + "MKCALENDAR", + "LINK", + "UNLINK", 0 }; const char **this_method; for (this_method = all_methods; *this_method; this_method++) { From 07fd52e5aafccd3417ce978cc86b3a457cdb5bab Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 19 Apr 2016 10:51:05 -0400 Subject: [PATCH 042/261] http: skip body and next message of CONNECT res When handling a response to `CONNECT` request - skip message body and do not attempt to parse the next message. `CONNECT` requests are used in similar sense to HTTP Upgrade. Fix: https://github.com/nodejs/node/pull/6198 PR-URL: https://github.com/nodejs/node/pull/6279 Reviewed-By: Brian White Reviewed-By: James M Snell --- lib/_http_client.js | 2 +- lib/_http_common.js | 7 +++++-- src/node_http_parser.cc | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index 371da638f9b98a..3e3b9966c275bf 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -393,7 +393,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) { // Responses to CONNECT request is handled as Upgrade. if (req.method === 'CONNECT') { res.upgrade = true; - return true; // skip body + return 2; // skip body, and the rest } // Responses to HEAD requests are crazy. diff --git a/lib/_http_common.js b/lib/_http_common.js index 08f93d8c4d04a2..1e6490eaffb6ce 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -94,7 +94,7 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, parser.incoming.upgrade = upgrade; - var skipBody = false; // response to HEAD or CONNECT + var skipBody = 0; // response to HEAD or CONNECT if (!upgrade) { // For upgraded connections and CONNECT method request, we'll emit this @@ -103,7 +103,10 @@ function parserOnHeadersComplete(versionMajor, versionMinor, headers, method, skipBody = parser.onIncoming(parser.incoming, shouldKeepAlive); } - return skipBody; + if (typeof skipBody !== 'number') + return skipBody ? 1 : 0; + else + return skipBody; } // XXX This is a mess. diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 6b15aa8c72d531..c062feea535604 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -301,7 +301,7 @@ class Parser : public AsyncWrap { return -1; } - return head_response->IsTrue() ? 1 : 0; + return head_response->IntegerValue(); } From 55f8689711f9c6bb19ce7148bde3c15dc4ee686d Mon Sep 17 00:00:00 2001 From: Josh Leder Date: Tue, 19 Apr 2016 10:50:20 -0400 Subject: [PATCH 043/261] test: add test for responses to HTTP CONNECT req See: https://github.com/nodejs/node/pull/6198 PR-URL: https://github.com/nodejs/node/pull/6279 Reviewed-By: Brian White Reviewed-By: James M Snell --- test/parallel/test-http-connect-req-res.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 test/parallel/test-http-connect-req-res.js diff --git a/test/parallel/test-http-connect-req-res.js b/test/parallel/test-http-connect-req-res.js new file mode 100644 index 00000000000000..bb5056fce49a24 --- /dev/null +++ b/test/parallel/test-http-connect-req-res.js @@ -0,0 +1,72 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +const server = http.createServer(function(req, res) { + assert(false); +}); +server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) { + assert.equal(req.method, 'CONNECT'); + assert.equal(req.url, 'example.com:443'); + console.error('Server got CONNECT request'); + + // It is legal for the server to send some data intended for the client + // along with the CONNECT response + socket.write( + 'HTTP/1.1 200 Connection established\r\n' + + 'Date: Tue, 15 Nov 1994 08:12:31 GMT\r\n' + + '\r\n' + + 'Head' + ); + + var data = firstBodyChunk.toString(); + socket.on('data', function(buf) { + data += buf.toString(); + }); + socket.on('end', function() { + socket.end(data); + }); +})); +server.listen(common.PORT, common.mustCall(function() { + const req = http.request({ + port: common.PORT, + method: 'CONNECT', + path: 'example.com:443' + }, function(res) { + assert(false); + }); + + req.on('close', common.mustCall(function() { })); + + req.on('connect', common.mustCall(function(res, socket, firstBodyChunk) { + console.error('Client got CONNECT request'); + + // Make sure this request got removed from the pool. + const name = 'localhost:' + common.PORT; + assert(!http.globalAgent.sockets.hasOwnProperty(name)); + assert(!http.globalAgent.requests.hasOwnProperty(name)); + + // Make sure this socket has detached. + assert(!socket.ondata); + assert(!socket.onend); + assert.equal(socket.listeners('connect').length, 0); + assert.equal(socket.listeners('data').length, 0); + + var data = firstBodyChunk.toString(); + + // test that the firstBodyChunk was not parsed as HTTP + assert.equal(data, 'Head'); + + socket.on('data', function(buf) { + data += buf.toString(); + }); + socket.on('end', function() { + assert.equal(data, 'HeadRequestEnd'); + server.close(); + }); + socket.end('End'); + })); + + req.end('Request'); +})); From fb03e57de20e48e201609f9f9594bc574462bccb Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 16 Mar 2016 14:19:08 -0700 Subject: [PATCH 044/261] buffer: backport --zero-fill-buffers cli option This backports the --zero-fill-buffers command line flag introduced in master. When used, all Buffer and SlowBuffer instances will zero fill by default. This does *not* backport any of the other Buffer API or behavior changes. PR-URL: https://github.com/nodejs/node/pull/5745 Reviewed-By: Trevor Norris --- doc/api/buffer.markdown | 17 ++++++++++++ doc/node.1 | 4 +++ src/node.cc | 8 +++++- src/node_buffer.cc | 11 ++++++-- src/node_buffer.h | 3 +++ test/parallel/test-buffer-zero-fill-cli.js | 30 ++++++++++++++++++++++ 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-buffer-zero-fill-cli.js diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 2a0b45d0e46a03..ca6e76623b938f 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -145,6 +145,23 @@ for (var b of buf) Additionally, the [`buf.values()`][], [`buf.keys()`][], and [`buf.entries()`][] methods can be used to create iterators. +## The `--zero-fill-buffers` command line option + +Node.js can be started using the `--zero-fill-buffers` command line option to +force all newly allocated `Buffer` and `SlowBuffer` instances created using +either `new Buffer(size)` and `new SlowBuffer(size)` to be *automatically +zero-filled* upon creation. Use of this flag *changes the default behavior* of +these methods and *can have a significant impact* on performance. Use of the +`--zero-fill-buffers` option is recommended only when absolutely necessary to +enforce that newly allocated `Buffer` instances cannot contain potentially +sensitive data. + +``` +$ node --zero-fill-buffers +> Buffer(5); + +``` + ## Class: Buffer The Buffer class is a global type for dealing with binary data directly. diff --git a/doc/node.1 b/doc/node.1 index 0382a095db6d77..aeaf8911619028 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -95,6 +95,10 @@ Process v8 profiler output generated using the v8 option \fB\-\-prof\fR .BR \-\-v8\-options Print v8 command line options. +.TP +.BR \-\-zero\-fill\-buffers +Automatically zero-fills all newly allocated Buffer and SlowBuffer instances. + .TP .BR \-\-tls\-cipher\-list =\fIlist\fR Specify an alternative default TLS cipher list. (Requires Node.js to be built with crypto support. (Default)) diff --git a/src/node.cc b/src/node.cc index 2f08a1da378eaf..3ef56b2dd3726f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -947,7 +947,9 @@ Local WinapiErrnoException(Isolate* isolate, void* ArrayBufferAllocator::Allocate(size_t size) { - if (env_ == nullptr || !env_->array_buffer_allocator_info()->no_zero_fill()) + if (env_ == nullptr || + !env_->array_buffer_allocator_info()->no_zero_fill() || + zero_fill_all_buffers) return calloc(size, 1); env_->array_buffer_allocator_info()->reset_fill_flag(); return malloc(size); @@ -3283,6 +3285,8 @@ static void PrintHelp() { "snapshots\n" " --prof-process process v8 profiler output generated\n" " using --prof\n" + " --zero-fill-buffers automatically zero-fill all newly allocated\n" + " Buffer and SlowBuffer instances\n" " --v8-options print v8 command line options\n" #if HAVE_OPENSSL " --tls-cipher-list=val use an alternative default TLS cipher list\n" @@ -3422,6 +3426,8 @@ static void ParseArgs(int* argc, } else if (strcmp(arg, "--prof-process") == 0) { prof_process = true; short_circuit = true; + } else if (strcmp(arg, "--zero-fill-buffers") == 0) { + zero_fill_all_buffers = true; } else if (strcmp(arg, "--v8-options") == 0) { new_v8_argv[new_v8_argc] = "--help"; new_v8_argc += 1; diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 83efaab210ea6f..d07632a101d491 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -48,7 +48,14 @@ CHECK_NOT_OOB(end <= end_max); \ size_t length = end - start; +#define BUFFER_MALLOC(length) \ + zero_fill_all_buffers ? calloc(length, 1) : malloc(length) + namespace node { + +// if true, all Buffer and SlowBuffer instances will automatically zero-fill +bool zero_fill_all_buffers = false; + namespace Buffer { using v8::ArrayBuffer; @@ -220,7 +227,7 @@ MaybeLocal New(Isolate* isolate, // nullptr for zero-sized allocation requests. Normalize by always using // a nullptr. if (length > 0) { - data = static_cast(malloc(length)); + data = static_cast(BUFFER_MALLOC(length)); if (data == nullptr) return Local(); @@ -266,7 +273,7 @@ MaybeLocal New(Environment* env, size_t length) { void* data; if (length > 0) { - data = malloc(length); + data = BUFFER_MALLOC(length); if (data == nullptr) return Local(); } else { diff --git a/src/node_buffer.h b/src/node_buffer.h index 503cbb167547a5..686450d984e6f9 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -5,6 +5,9 @@ #include "v8.h" namespace node { + +extern bool zero_fill_all_buffers; + namespace Buffer { static const unsigned int kMaxLength = diff --git a/test/parallel/test-buffer-zero-fill-cli.js b/test/parallel/test-buffer-zero-fill-cli.js new file mode 100644 index 00000000000000..2f6c011c5c4ff0 --- /dev/null +++ b/test/parallel/test-buffer-zero-fill-cli.js @@ -0,0 +1,30 @@ +'use strict'; +// Flags: --zero-fill-buffers + +// when using --zero-fill-buffers, every Buffer and SlowBuffer +// instance must be zero filled upon creation + +require('../common'); +const SlowBuffer = require('buffer').SlowBuffer; +const assert = require('assert'); + +function isZeroFilled(buf) { + for (let n = 0; n < buf.length; n++) + if (buf[n] > 0) return false; + return true; +} + +// This can be somewhat unreliable because the +// allocated memory might just already happen to +// contain all zeroes. The test is run multiple +// times to improve the reliability. +for (let i = 0; i < 50; i++) { + const bufs = [ + SlowBuffer(20), + Buffer(20), + new SlowBuffer(20) + ]; + for (const buf of bufs) { + assert(isZeroFilled(buf)); + } +} From c237ac3d68c18c071097886981fdb4fd90ab01b3 Mon Sep 17 00:00:00 2001 From: Robert Jefe Lindstaedt Date: Fri, 1 Jul 2016 12:00:46 +0200 Subject: [PATCH 045/261] doc: git mv to .md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit: https://github.com/nodejs/node/commit/0800c0aa7275bf389b157e1568fa61b59285ad86 doc: git mv to .md * doc: rename .markdown references in content * doc: rename to .md in tools * doc: rename to .md in CONTRIBUTING.md PR-URL: #4747 Reviewed-By: Myles Borins Reviewed-By: techjeffharris Reviewed-By: Johan Bergström Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- CONTRIBUTING.md | 2 +- Makefile | 12 ++++++------ doc/api/{_toc.markdown => _toc.md} | 0 doc/api/{addons.markdown => addons.md} | 0 doc/api/{all.markdown => all.md} | 0 doc/api/{assert.markdown => assert.md} | 0 doc/api/{buffer.markdown => buffer.md} | 0 doc/api/{child_process.markdown => child_process.md} | 0 doc/api/{cli.markdown => cli.md} | 0 doc/api/{cluster.markdown => cluster.md} | 0 doc/api/{console.markdown => console.md} | 0 doc/api/{crypto.markdown => crypto.md} | 0 doc/api/{debugger.markdown => debugger.md} | 0 doc/api/{dgram.markdown => dgram.md} | 0 doc/api/{dns.markdown => dns.md} | 0 doc/api/{documentation.markdown => documentation.md} | 2 +- doc/api/{domain.markdown => domain.md} | 0 doc/api/{errors.markdown => errors.md} | 0 doc/api/{events.markdown => events.md} | 0 doc/api/{fs.markdown => fs.md} | 0 doc/api/{globals.markdown => globals.md} | 0 doc/api/{http.markdown => http.md} | 0 doc/api/{https.markdown => https.md} | 0 doc/api/index.markdown | 1 - doc/api/index.md | 1 + doc/api/{modules.markdown => modules.md} | 0 doc/api/{net.markdown => net.md} | 0 doc/api/{os.markdown => os.md} | 0 doc/api/{path.markdown => path.md} | 0 doc/api/{process.markdown => process.md} | 0 doc/api/{punycode.markdown => punycode.md} | 0 doc/api/{querystring.markdown => querystring.md} | 0 doc/api/{readline.markdown => readline.md} | 0 doc/api/{repl.markdown => repl.md} | 0 doc/api/{stream.markdown => stream.md} | 0 .../{string_decoder.markdown => string_decoder.md} | 0 doc/api/{synopsis.markdown => synopsis.md} | 0 doc/api/{timers.markdown => timers.md} | 0 doc/api/{tls.markdown => tls.md} | 0 doc/api/{tty.markdown => tty.md} | 0 doc/api/{url.markdown => url.md} | 0 doc/api/{util.markdown => util.md} | 0 doc/api/{v8.markdown => v8.md} | 0 doc/api/{vm.markdown => vm.md} | 0 doc/api/{zlib.markdown => zlib.md} | 0 src/node.cc | 2 +- tools/doc/README.md | 2 +- tools/doc/addon-verify.js | 2 +- tools/doc/html.js | 4 ++-- tools/doc/preprocess.js | 2 +- 50 files changed, 15 insertions(+), 15 deletions(-) rename doc/api/{_toc.markdown => _toc.md} (100%) rename doc/api/{addons.markdown => addons.md} (100%) rename doc/api/{all.markdown => all.md} (100%) rename doc/api/{assert.markdown => assert.md} (100%) rename doc/api/{buffer.markdown => buffer.md} (100%) rename doc/api/{child_process.markdown => child_process.md} (100%) rename doc/api/{cli.markdown => cli.md} (100%) rename doc/api/{cluster.markdown => cluster.md} (100%) rename doc/api/{console.markdown => console.md} (100%) rename doc/api/{crypto.markdown => crypto.md} (100%) rename doc/api/{debugger.markdown => debugger.md} (100%) rename doc/api/{dgram.markdown => dgram.md} (100%) rename doc/api/{dns.markdown => dns.md} (100%) rename doc/api/{documentation.markdown => documentation.md} (97%) rename doc/api/{domain.markdown => domain.md} (100%) rename doc/api/{errors.markdown => errors.md} (100%) rename doc/api/{events.markdown => events.md} (100%) rename doc/api/{fs.markdown => fs.md} (100%) rename doc/api/{globals.markdown => globals.md} (100%) rename doc/api/{http.markdown => http.md} (100%) rename doc/api/{https.markdown => https.md} (100%) delete mode 100644 doc/api/index.markdown create mode 100644 doc/api/index.md rename doc/api/{modules.markdown => modules.md} (100%) rename doc/api/{net.markdown => net.md} (100%) rename doc/api/{os.markdown => os.md} (100%) rename doc/api/{path.markdown => path.md} (100%) rename doc/api/{process.markdown => process.md} (100%) rename doc/api/{punycode.markdown => punycode.md} (100%) rename doc/api/{querystring.markdown => querystring.md} (100%) rename doc/api/{readline.markdown => readline.md} (100%) rename doc/api/{repl.markdown => repl.md} (100%) rename doc/api/{stream.markdown => stream.md} (100%) rename doc/api/{string_decoder.markdown => string_decoder.md} (100%) rename doc/api/{synopsis.markdown => synopsis.md} (100%) rename doc/api/{timers.markdown => timers.md} (100%) rename doc/api/{tls.markdown => tls.md} (100%) rename doc/api/{tty.markdown => tty.md} (100%) rename doc/api/{url.markdown => url.md} (100%) rename doc/api/{util.markdown => util.md} (100%) rename doc/api/{v8.markdown => v8.md} (100%) rename doc/api/{vm.markdown => vm.md} (100%) rename doc/api/{zlib.markdown => zlib.md} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 362846556ac52f..6b761c79858225 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,7 +49,7 @@ and built upon. #### Respect the stability index The rules for the master branch are less strict; consult the -[stability index](./doc/api/documentation.markdown#stability-index) for details. +[stability index](./doc/api/documentation.md#stability-index) for details. In a nutshell, modules are at varying levels of API stability. Bug fixes are always welcome but API or behavioral changes to modules at stability level 3 diff --git a/Makefile b/Makefile index 86fe1da1ee29ee..55107392d35f11 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE) --nodedir="$(shell pwd)" # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale. -test/addons/.docbuildstamp: doc/api/addons.markdown +test/addons/.docbuildstamp: doc/api/addons.md $(RM) -r test/addons/??_*/ $(NODE) tools/doc/addon-verify.js touch $@ @@ -249,9 +249,9 @@ test-v8-benchmarks: test-v8-all: test-v8 test-v8-intl test-v8-benchmarks # runs all v8 tests -apidoc_sources = $(wildcard doc/api/*.markdown) -apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \ - $(addprefix out/,$(apidoc_sources:.markdown=.json)) +apidoc_sources = $(wildcard doc/api/*.md) +apidocs = $(addprefix out/,$(apidoc_sources:.md=.html)) \ + $(addprefix out/,$(apidoc_sources:.md=.json)) apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets @@ -268,10 +268,10 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/ out/doc/%: doc/% cp -r $< $@ -out/doc/api/%.json: doc/api/%.markdown $(NODE_EXE) +out/doc/api/%.json: doc/api/%.md $(NODE_EXE) $(NODE) tools/doc/generate.js --format=json $< > $@ -out/doc/api/%.html: doc/api/%.markdown $(NODE_EXE) +out/doc/api/%.html: doc/api/%.md $(NODE_EXE) $(NODE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@ docopen: out/doc/api/all.html diff --git a/doc/api/_toc.markdown b/doc/api/_toc.md similarity index 100% rename from doc/api/_toc.markdown rename to doc/api/_toc.md diff --git a/doc/api/addons.markdown b/doc/api/addons.md similarity index 100% rename from doc/api/addons.markdown rename to doc/api/addons.md diff --git a/doc/api/all.markdown b/doc/api/all.md similarity index 100% rename from doc/api/all.markdown rename to doc/api/all.md diff --git a/doc/api/assert.markdown b/doc/api/assert.md similarity index 100% rename from doc/api/assert.markdown rename to doc/api/assert.md diff --git a/doc/api/buffer.markdown b/doc/api/buffer.md similarity index 100% rename from doc/api/buffer.markdown rename to doc/api/buffer.md diff --git a/doc/api/child_process.markdown b/doc/api/child_process.md similarity index 100% rename from doc/api/child_process.markdown rename to doc/api/child_process.md diff --git a/doc/api/cli.markdown b/doc/api/cli.md similarity index 100% rename from doc/api/cli.markdown rename to doc/api/cli.md diff --git a/doc/api/cluster.markdown b/doc/api/cluster.md similarity index 100% rename from doc/api/cluster.markdown rename to doc/api/cluster.md diff --git a/doc/api/console.markdown b/doc/api/console.md similarity index 100% rename from doc/api/console.markdown rename to doc/api/console.md diff --git a/doc/api/crypto.markdown b/doc/api/crypto.md similarity index 100% rename from doc/api/crypto.markdown rename to doc/api/crypto.md diff --git a/doc/api/debugger.markdown b/doc/api/debugger.md similarity index 100% rename from doc/api/debugger.markdown rename to doc/api/debugger.md diff --git a/doc/api/dgram.markdown b/doc/api/dgram.md similarity index 100% rename from doc/api/dgram.markdown rename to doc/api/dgram.md diff --git a/doc/api/dns.markdown b/doc/api/dns.md similarity index 100% rename from doc/api/dns.markdown rename to doc/api/dns.md diff --git a/doc/api/documentation.markdown b/doc/api/documentation.md similarity index 97% rename from doc/api/documentation.markdown rename to doc/api/documentation.md index 2922c011f5845c..61d623fe3e054a 100644 --- a/doc/api/documentation.markdown +++ b/doc/api/documentation.md @@ -16,7 +16,7 @@ experimental, and added for the benefit of IDEs and other utilities that wish to do programmatic things with the documentation. Every `.html` and `.json` file is generated based on the corresponding -`.markdown` file in the `doc/api/` folder in Node.js's source tree. The +`.md` file in the `doc/api/` folder in Node.js's source tree. The documentation is generated using the `tools/doc/generate.js` program. The HTML template is located at `doc/template.html`. diff --git a/doc/api/domain.markdown b/doc/api/domain.md similarity index 100% rename from doc/api/domain.markdown rename to doc/api/domain.md diff --git a/doc/api/errors.markdown b/doc/api/errors.md similarity index 100% rename from doc/api/errors.markdown rename to doc/api/errors.md diff --git a/doc/api/events.markdown b/doc/api/events.md similarity index 100% rename from doc/api/events.markdown rename to doc/api/events.md diff --git a/doc/api/fs.markdown b/doc/api/fs.md similarity index 100% rename from doc/api/fs.markdown rename to doc/api/fs.md diff --git a/doc/api/globals.markdown b/doc/api/globals.md similarity index 100% rename from doc/api/globals.markdown rename to doc/api/globals.md diff --git a/doc/api/http.markdown b/doc/api/http.md similarity index 100% rename from doc/api/http.markdown rename to doc/api/http.md diff --git a/doc/api/https.markdown b/doc/api/https.md similarity index 100% rename from doc/api/https.markdown rename to doc/api/https.md diff --git a/doc/api/index.markdown b/doc/api/index.markdown deleted file mode 100644 index 1a774507aef098..00000000000000 --- a/doc/api/index.markdown +++ /dev/null @@ -1 +0,0 @@ -@include _toc.markdown diff --git a/doc/api/index.md b/doc/api/index.md new file mode 100644 index 00000000000000..400faf6e5ed34a --- /dev/null +++ b/doc/api/index.md @@ -0,0 +1 @@ +@include _toc.md diff --git a/doc/api/modules.markdown b/doc/api/modules.md similarity index 100% rename from doc/api/modules.markdown rename to doc/api/modules.md diff --git a/doc/api/net.markdown b/doc/api/net.md similarity index 100% rename from doc/api/net.markdown rename to doc/api/net.md diff --git a/doc/api/os.markdown b/doc/api/os.md similarity index 100% rename from doc/api/os.markdown rename to doc/api/os.md diff --git a/doc/api/path.markdown b/doc/api/path.md similarity index 100% rename from doc/api/path.markdown rename to doc/api/path.md diff --git a/doc/api/process.markdown b/doc/api/process.md similarity index 100% rename from doc/api/process.markdown rename to doc/api/process.md diff --git a/doc/api/punycode.markdown b/doc/api/punycode.md similarity index 100% rename from doc/api/punycode.markdown rename to doc/api/punycode.md diff --git a/doc/api/querystring.markdown b/doc/api/querystring.md similarity index 100% rename from doc/api/querystring.markdown rename to doc/api/querystring.md diff --git a/doc/api/readline.markdown b/doc/api/readline.md similarity index 100% rename from doc/api/readline.markdown rename to doc/api/readline.md diff --git a/doc/api/repl.markdown b/doc/api/repl.md similarity index 100% rename from doc/api/repl.markdown rename to doc/api/repl.md diff --git a/doc/api/stream.markdown b/doc/api/stream.md similarity index 100% rename from doc/api/stream.markdown rename to doc/api/stream.md diff --git a/doc/api/string_decoder.markdown b/doc/api/string_decoder.md similarity index 100% rename from doc/api/string_decoder.markdown rename to doc/api/string_decoder.md diff --git a/doc/api/synopsis.markdown b/doc/api/synopsis.md similarity index 100% rename from doc/api/synopsis.markdown rename to doc/api/synopsis.md diff --git a/doc/api/timers.markdown b/doc/api/timers.md similarity index 100% rename from doc/api/timers.markdown rename to doc/api/timers.md diff --git a/doc/api/tls.markdown b/doc/api/tls.md similarity index 100% rename from doc/api/tls.markdown rename to doc/api/tls.md diff --git a/doc/api/tty.markdown b/doc/api/tty.md similarity index 100% rename from doc/api/tty.markdown rename to doc/api/tty.md diff --git a/doc/api/url.markdown b/doc/api/url.md similarity index 100% rename from doc/api/url.markdown rename to doc/api/url.md diff --git a/doc/api/util.markdown b/doc/api/util.md similarity index 100% rename from doc/api/util.markdown rename to doc/api/util.md diff --git a/doc/api/v8.markdown b/doc/api/v8.md similarity index 100% rename from doc/api/v8.markdown rename to doc/api/v8.md diff --git a/doc/api/vm.markdown b/doc/api/vm.md similarity index 100% rename from doc/api/vm.markdown rename to doc/api/vm.md diff --git a/doc/api/zlib.markdown b/doc/api/zlib.md similarity index 100% rename from doc/api/zlib.markdown rename to doc/api/zlib.md diff --git a/src/node.cc b/src/node.cc index 3ef56b2dd3726f..2068488b9ea7b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3263,7 +3263,7 @@ static bool ParseDebugOpt(const char* arg) { static void PrintHelp() { // XXX: If you add an option here, please also add it to doc/node.1 and - // doc/api/cli.markdown + // doc/api/cli.md printf("Usage: node [options] [ -e script | script.js ] [arguments] \n" " node debug script.js [arguments] \n" "\n" diff --git a/tools/doc/README.md b/tools/doc/README.md index 0e8d48fbcb5544..fd041f001e6931 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -1,6 +1,6 @@ Here's how the node docs work. -1:1 relationship from `lib/.js` to `doc/api/.markdown` +1:1 relationship from `lib/.js` to `doc/api/.md` Each type of heading has a description block. diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.js index 5ff12d342c78b0..a6dca436383231 100644 --- a/tools/doc/addon-verify.js +++ b/tools/doc/addon-verify.js @@ -5,7 +5,7 @@ const path = require('path'); const marked = require('marked'); const rootDir = path.resolve(__dirname, '..', '..'); -const doc = path.resolve(rootDir, 'doc', 'api', 'addons.markdown'); +const doc = path.resolve(rootDir, 'doc', 'api', 'addons.md'); const verifyDir = path.resolve(rootDir, 'test', 'addons'); const contents = fs.readFileSync(doc).toString(); diff --git a/tools/doc/html.js b/tools/doc/html.js index a232117439bbc7..68ccf976b6c1f8 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -15,7 +15,7 @@ var gtocPath = path.resolve(path.join( '..', 'doc', 'api', - '_toc.markdown' + '_toc.md' )); var gtocLoading = null; var gtocData = null; @@ -75,7 +75,7 @@ function render(lexed, filename, template, cb) { // get the section var section = getSection(lexed); - filename = path.basename(filename, '.markdown'); + filename = path.basename(filename, '.md'); parseText(lexed); lexed = parseLists(lexed); diff --git a/tools/doc/preprocess.js b/tools/doc/preprocess.js index 8f802714bcb126..295737a2a53aee 100644 --- a/tools/doc/preprocess.js +++ b/tools/doc/preprocess.js @@ -30,7 +30,7 @@ function processIncludes(inputFile, input, cb) { if (incCount === 0) cb(null, input); includes.forEach(function(include) { var fname = include.replace(/^@include\s+/, ''); - if (!fname.match(/\.markdown$/)) fname += '.markdown'; + if (!fname.match(/\.md$/)) fname += '.md'; if (includeData.hasOwnProperty(fname)) { input = input.split(include).join(includeData[fname]); From 0bfedd13a916b24e0b8d69e045aded62cc1595c6 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 24 Mar 2016 10:53:42 -0700 Subject: [PATCH 046/261] win,build: add creation of zip and 7z package Add a step in vcbuild.bat to create a minimal package including node and npm that can be used as an alternative to the MSI. Compress the node.pdb file as zip and 7z. All files are uploaded as part of build-release. Reviewed-By: Joao Reis Reviewed-By: Rod Vagg Reviewed-By: Alexis Campailla PR-URL: https://github.com/nodejs/node/pull/5995 Fixes: https://github.com/nodejs/build/issues/299 Fixes: https://github.com/nodejs/node/issues/5696 --- vcbuild.bat | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/vcbuild.bat b/vcbuild.bat index 14c65fdcdb3bf5..b5844c817fe8c7 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -21,6 +21,7 @@ set nobuild= set nosign= set nosnapshot= set test_args= +set package= set msi= set upload= set licensertf= @@ -66,6 +67,7 @@ if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok if /i "%1"=="test-all" set test_args=%test_args% sequential parallel message gc internet pummel&set buildnodeweak=1&set jslint=1&goto arg-ok if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues --expect-fail&goto arg-ok if /i "%1"=="jslint" set jslint=1&goto arg-ok +if /i "%1"=="package" set package=1&goto arg-ok if /i "%1"=="msi" set msi=1&set licensertf=1&set download_arg="--download=all"&set i18n_arg=small-icu&goto arg-ok if /i "%1"=="build-release" set build_release=1&goto arg-ok if /i "%1"=="upload" set upload=1&goto arg-ok @@ -87,6 +89,7 @@ goto next-arg if defined build_release ( set config=Release + set package=1 set msi=1 set licensertf=1 set download_arg="--download=all" @@ -206,11 +209,59 @@ if errorlevel 1 echo Failed to sign exe&goto exit :licensertf @rem Skip license.rtf generation if not requested. -if not defined licensertf goto msi +if not defined licensertf goto package %config%\node tools\license2rtf.js < LICENSE > %config%\license.rtf if errorlevel 1 echo Failed to generate license.rtf&goto exit +:package +if not defined package goto msi +echo Creating package... +cd Release +mkdir node-v%FULLVERSION%-win-%target_arch% > nul 2> nul +mkdir node-v%FULLVERSION%-win-%target_arch%\node_modules > nul 2>nul + +copy /Y node.exe node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy node.exe && goto package_error +copy /Y ..\LICENSE node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy LICENSE && goto package_error +copy /Y ..\README.md node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy README.md && goto package_error +copy /Y ..\CHANGELOG.md node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy CHANGELOG.md && goto package_error +robocopy /e ..\deps\npm node-v%FULLVERSION%-win-%target_arch%\node_modules\npm > nul +if errorlevel 8 echo Cannot copy npm package && goto package_error +copy /Y ..\deps\npm\bin\npm node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy npm && goto package_error +copy /Y ..\deps\npm\bin\npm.cmd node-v%FULLVERSION%-win-%target_arch%\ > nul +if errorlevel 1 echo Cannot copy npm.cmd && goto package_error + +echo Creating node-v%FULLVERSION%-win-%target_arch%.7z +del node-v%FULLVERSION%-win-%target_arch%.7z > nul 2> nul +7z a -r -mx9 -t7z node-v%FULLVERSION%-win-%target_arch%.7z node-v%FULLVERSION%-win-%target_arch% > nul +if errorlevel 1 echo Cannot create node-v%FULLVERSION%-win-%target_arch%.7z && goto package_error + +echo Creating node-v%FULLVERSION%-win-%target_arch%.zip +del node-v%FULLVERSION%-win-%target_arch%.zip > nul 2> nul +7z a -r -mx9 -tzip node-v%FULLVERSION%-win-%target_arch%.zip node-v%FULLVERSION%-win-%target_arch% > nul +if errorlevel 1 echo Cannot create node-v%FULLVERSION%-win-%target_arch%.zip && goto package_error + +echo Creating node_pdb.7z +del node_pdb.7z > nul 2> nul +7z a -mx9 -t7z node_pdb.7z node.pdb > nul + +echo Creating node_pdb.zip +del node_pdb.zip > nul 2> nul +7z a -mx9 -tzip node_pdb.zip node.pdb > nul + +cd .. +echo Package created! +goto package_done +:package_error +cd .. +exit /b 1 +:package_done + :msi @rem Skip msi generation if not requested if not defined msi goto run @@ -236,8 +287,12 @@ if not defined STAGINGSERVER set STAGINGSERVER=node-www ssh -F %SSHCONFIG% %STAGINGSERVER% "mkdir -p nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%" scp -F %SSHCONFIG% Release\node.exe %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.exe scp -F %SSHCONFIG% Release\node.lib %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node.lib +scp -F %SSHCONFIG% Release\node_pdb.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.zip +scp -F %SSHCONFIG% Release\node_pdb.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%/node_pdb.7z +scp -F %SSHCONFIG% Release\node-v%FULLVERSION%-win-%target_arch%.7z %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-win-%target_arch%.7z +scp -F %SSHCONFIG% Release\node-v%FULLVERSION%-win-%target_arch%.zip %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-win-%target_arch%.zip scp -F %SSHCONFIG% node-v%FULLVERSION%-%target_arch%.msi %STAGINGSERVER%:nodejs/%DISTTYPEDIR%/v%FULLVERSION%/ -ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.msi.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%.done && chmod -R ug=rw-x+X,o=r+X nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.msi* nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%*" +ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.msi.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-win-%target_arch%.zip.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-win-%target_arch%.7z.done nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%.done && chmod -R ug=rw-x+X,o=r+X nodejs/%DISTTYPEDIR%/v%FULLVERSION%/node-v%FULLVERSION%-%target_arch%.* nodejs/%DISTTYPEDIR%/v%FULLVERSION%/win-%target_arch%*" :run @rem Run tests if requested. From e544b1c40c19192514dc7c0eff33536f0f778d8b Mon Sep 17 00:00:00 2001 From: Alexis Campailla Date: Fri, 8 Jul 2016 14:00:57 +0200 Subject: [PATCH 047/261] test,win: skip addons/load-long-path on WOW64 This test fails on WOW64 because of a bug in the OS, and there is no acceptable workaround. Ref: https://github.com/nodejs/node/issues/3667 PR-URL: https://github.com/nodejs/node/pull/6675 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: cjihrig - Colin Ihrig --- test/addons/load-long-path/test.js | 5 +++++ test/common.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js index 1de2b85fe94aa6..a4f3cb12dc0480 100644 --- a/test/addons/load-long-path/test.js +++ b/test/addons/load-long-path/test.js @@ -4,6 +4,11 @@ const fs = require('fs'); const path = require('path'); const assert = require('assert'); +if (common.isWOW64) { + common.skip('doesn\'t work on WOW64'); + return; +} + common.refreshTmpDir(); // make a path that is more than 260 chars long. diff --git a/test/common.js b/test/common.js index 801e356b749255..7a054fc167c9ab 100644 --- a/test/common.js +++ b/test/common.js @@ -17,6 +17,8 @@ exports.libDir = path.join(exports.testDir, '../lib'); exports.tmpDirName = 'tmp'; exports.PORT = +process.env.NODE_COMMON_PORT || 12346; exports.isWindows = process.platform === 'win32'; +exports.isWOW64 = exports.isWindows && + (process.env['PROCESSOR_ARCHITEW6432'] !== undefined); exports.isAix = process.platform === 'aix'; exports.isLinuxPPCBE = (process.platform === 'linux') && (process.arch === 'ppc64') && From 200429e9e1951991cd33d0909a714489b2203652 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 29 May 2016 20:03:32 +0200 Subject: [PATCH 048/261] buffer: ignore negative allocation lengths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Treat negative length arguments to `Buffer()`/`allocUnsafe()` as if they were zero so the allocation does not affect the pool’s offset. Fixes: https://github.com/nodejs/node/issues/7047 Refs: https://github.com/nodejs/node/pull/7051 Refs: https://github.com/nodejs/node/pull/7221 Refs: https://github.com/nodejs/node/pull/7475 PR-URL: https://github.com/nodejs/node/pull/7562 Reviewed-By: Trevor Norris Reviewed-By: James M Snell Reviewed-By: Nikolai Vavilov --- lib/buffer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 3fe08c81b91ebf..23771b15bfca0e 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -79,8 +79,8 @@ Object.setPrototypeOf(SlowBuffer, Uint8Array); function allocate(size) { - if (size === 0) { - return createBuffer(size); + if (size <= 0) { + return createBuffer(0); } if (size < (Buffer.poolSize >>> 1)) { if (size > (poolSize - poolOffset)) From 709048134c828f63577f70670f5d80c41748e3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sun, 19 Jun 2016 18:50:27 +0300 Subject: [PATCH 049/261] buffer: backport new buffer constructor APIs to v4.x This backports the new `Buffer.alloc()`, `Buffer.allocUnsafe()`, `Buffer.from()`, and `Buffer.allocUnsafeSlow()` APIs for v4. Some backported tests are disabled, but those are not related to the new API. Note that `Buffer.from(arrayBuffer[, byteOffset [, length]])` is not supported in v4.x, only `Buffer.from(arrayBuffer)` is. Refs: https://github.com/nodejs/node/pull/4682 Refs: https://github.com/nodejs/node/pull/5833 Refs: https://github.com/nodejs/node/pull/7475 PR-URL: https://github.com/nodejs/node/pull/7562 Reviewed-By: Trevor Norris Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Nikolai Vavilov --- doc/api/buffer.md | 359 ++++++ lib/buffer.js | 68 +- test/parallel/test-buffer-alloc.js | 1451 ++++++++++++++++++++++ test/parallel/test-buffer-safe-unsafe.js | 14 + test/parallel/test-buffer.js | 11 + 5 files changed, 1902 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-buffer-alloc.js create mode 100644 test/parallel/test-buffer-safe-unsafe.js diff --git a/doc/api/buffer.md b/doc/api/buffer.md index ca6e76623b938f..ad8c0113b191ca 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -23,17 +23,112 @@ would need to ever use `require('buffer').Buffer`. ```js const buf1 = new Buffer(10); // creates a buffer of length 10 + // This is the same as Buffer.allocUnsafe(10), and the returned + // Buffer instance might contain old data that needs to be + // overwritten using either fill() or write(). const buf2 = new Buffer([1,2,3]); // creates a buffer containing [01, 02, 03] + // This is the same as Buffer.from([1,2,3]). const buf3 = new Buffer('test'); // creates a buffer containing ASCII bytes [74, 65, 73, 74] + // This is the same as Buffer.from('test'). const buf4 = new Buffer('tést', 'utf8'); // creates a buffer containing UTF8 bytes [74, c3, a9, 73, 74] + // This is the same as Buffer.from('tést', 'utf8'). + +const buf5 = Buffer.alloc(10); + // Creates a zero-filled Buffer of length 10. + +const buf6 = Buffer.alloc(10, 1); + // Creates a Buffer of length 10, filled with 0x01. + +const buf7 = Buffer.allocUnsafe(10); + // Creates an uninitialized buffer of length 10. + // This is faster than calling Buffer.alloc() but the returned + // Buffer instance might contain old data that needs to be + // overwritten using either fill() or write(). + +const buf8 = Buffer.from([1,2,3]); + // Creates a Buffer containing [01, 02, 03]. + +const buf9 = Buffer.from('test'); + // Creates a Buffer containing ASCII bytes [74, 65, 73, 74]. + +const buf8 = Buffer.from('tést', 'utf8'); + // Creates a Buffer containing UTF8 bytes [74, c3, a9, 73, 74]. ``` +## `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` + +Historically, `Buffer` instances have been created using the `Buffer` +constructor function, which allocates the returned `Buffer` +differently based on what arguments are provided: + +* Passing a number as the first argument to `Buffer()` (e.g. `new Buffer(10)`), + allocates a new `Buffer` object of the specified size. The memory allocated + for such `Buffer` instances is *not* initialized and *can contain sensitive + data*. Such `Buffer` objects *must* be initialized *manually* by using either + [`buf.fill(0)`][] or by writing to the `Buffer` completely. While this + behavior is *intentional* to improve performance, development experience has + demonstrated that a more explicit distinction is required between creating a + fast-but-uninitialized `Buffer` versus creating a slower-but-safer `Buffer`. +* Passing a string, array, or `Buffer` as the first argument copies the + passed object's data into the `Buffer`. +* Passing an `ArrayBuffer` returns a `Buffer` that shares allocated memory with + the given `ArrayBuffer`. + +Because the behavior of `new Buffer()` changes significantly based on the type +of value passed as the first argument, applications that do not properly +validate the input arguments passed to `new Buffer()`, or that fail to +appropriately initialize newly allocated `Buffer` content, can inadvertently +introduce security and reliability issues into their code. + +To make the creation of `Buffer` objects more reliable and less error prone, +new `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` methods have +been introduced as an alternative means of creating `Buffer` instances. + +*Developers should migrate all existing uses of the `new Buffer()` constructors +to one of these new APIs.* + +* [`Buffer.from(array)`][buffer_from_array] returns a new `Buffer` containing + a *copy* of the provided octets. +* [`Buffer.from(arrayBuffer)`][buffer_from_arraybuf] returns a new `Buffer` + that *shares* the same allocated memory as the given `ArrayBuffer`. +* [`Buffer.from(buffer)`][buffer_from_buffer] returns a new `Buffer` + containing a *copy* of the contents of the given `Buffer`. +* [`Buffer.from(str[, encoding])`][buffer_from_string] returns a new `Buffer` + containing a *copy* of the provided string. +* [`Buffer.alloc(size[, fill[, encoding]])`][buffer_alloc] returns a "filled" + `Buffer` instance of the specified size. This method can be significantly + slower than [`Buffer.allocUnsafe(size)`][buffer_allocunsafe] but ensures + that newly created `Buffer` instances never contain old and potentially + sensitive data. +* [`Buffer.allocUnsafe(size)`][buffer_allocunsafe] and + [`Buffer.allocUnsafeSlow(size)`][buffer_allocunsafeslow] each return a + new `Buffer` of the specified `size` whose content *must* be initialized + using either [`buf.fill(0)`][] or written to completely. + +`Buffer` instances returned by `Buffer.allocUnsafe(size)` *may* be allocated +off a shared internal memory pool if `size` is less than or equal to half +`Buffer.poolSize`. Instances returned by `Buffer.allocUnsafeSlow(size)` *never* +use the shared internal memory pool. + +### What makes `Buffer.allocUnsafe(size)` and `Buffer.allocUnsafeSlow(size)` "unsafe"? + +When calling `Buffer.allocUnsafe()` (and `Buffer.allocUnsafeSlow()`), the +segment of allocated memory is *uninitialized* (it is not zeroed-out). While +this design makes the allocation of memory quite fast, the allocated segment of +memory might contain old data that is potentially sensitive. Using a `Buffer` +created by `Buffer.allocUnsafe()` without *completely* overwriting the memory +can allow this old data to be leaked when the `Buffer` memory is read. + +While there are clear performance advantages to using `Buffer.allocUnsafe()`, +extra care *must* be taken in order to avoid introducing security +vulnerabilities into an application. + ## Buffers and Character Encodings Buffers are commonly used to represent sequences of encoded characters @@ -126,6 +221,21 @@ console.log(buf.length); // Prints: 16 ``` +The `Buffer.from()` and [`TypedArray.from()`][] (e.g.`Uint8Array.from()`) have +different signatures and implementations. Specifically, the TypedArray variants +accept a second argument that is a mapping function that is invoked on every +element of the typed array: + +* `TypedArray.from(source[, mapFn[, thisArg]])` + +The `Buffer.from()` method, however, does not support the use of a mapping +function: + +* [`Buffer.from(array)`][buffer_from_array] +* [`Buffer.from(buffer)`][buffer_from_buffer] +* [`Buffer.from(arrayBuffer)`][buffer_from_arraybuf] +* [`Buffer.from(str[, encoding])`][buffer_from_string] + ## Buffers and ES6 iteration Buffers can be iterated over using the ECMAScript 2015 (ES6) `for..of` syntax: @@ -267,6 +377,138 @@ console.log(buf2.toString()); // prints: this is a tést ``` +### Class Method: Buffer.alloc(size[, fill[, encoding]]) + +* `size` {Number} +* `fill` {Value} Default: `undefined` +* `encoding` {String} Default: `utf8` + +Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the +`Buffer` will be *zero-filled*. + +```js +const buf = Buffer.alloc(5); +console.log(buf); + // +``` + +The `size` must be less than or equal to the value of +`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is +`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. If a `size` less than 0 +is specified, a zero-length `Buffer` will be created. + +If `fill` is specified, the allocated `Buffer` will be initialized by calling +`buf.fill(fill)`. See [`buf.fill()`][] for more information. + +```js +const buf = Buffer.alloc(5, 'a'); +console.log(buf); + // +``` + +If both `fill` and `encoding` are specified, the allocated `Buffer` will be +initialized by calling `buf.fill(fill, encoding)`. For example: + +```js +const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64'); +console.log(buf); + // +``` + +Calling `Buffer.alloc(size)` can be significantly slower than the alternative +`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance +contents will *never contain sensitive data*. + +A `TypeError` will be thrown if `size` is not a number. + +### Class Method: Buffer.allocUnsafe(size) + +* `size` {Number} + +Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must +be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit +architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is +thrown. If a `size` less than 0 is specified, a zero-length `Buffer` will be +created. + +The underlying memory for `Buffer` instances created in this way is *not +initialized*. The contents of the newly created `Buffer` are unknown and +*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such +`Buffer` instances to zeroes. + +```js +const buf = Buffer.allocUnsafe(5); +console.log(buf); + // + // (octets will be different, every time) +buf.fill(0); +console.log(buf); + // +``` + +A `TypeError` will be thrown if `size` is not a number. + +Note that the `Buffer` module pre-allocates an internal `Buffer` instance of +size `Buffer.poolSize` that is used as a pool for the fast allocation of new +`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the +`new Buffer(size)` constructor) only when `size` is less than or equal to +`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default +value of `Buffer.poolSize` is `8192` but can be modified. + +Use of this pre-allocated internal memory pool is a key difference between +calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. +Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer +pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal +Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The +difference is subtle but can be important when an application requires the +additional performance that `Buffer.allocUnsafe(size)` provides. + +### Class Method: Buffer.allocUnsafeSlow(size) + +* `size` {Number} + +Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The +`size` must be less than or equal to the value of +`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is +`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. If a `size` less than 0 +is specified, a zero-length `Buffer` will be created. + +The underlying memory for `Buffer` instances created in this way is *not +initialized*. The contents of the newly created `Buffer` are unknown and +*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such +`Buffer` instances to zeroes. + +When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances, +allocations under 4KB are, by default, sliced from a single pre-allocated +`Buffer`. This allows applications to avoid the garbage collection overhead of +creating many individually allocated Buffers. This approach improves both +performance and memory usage by eliminating the need to track and cleanup as +many `Persistent` objects. + +However, in the case where a developer may need to retain a small chunk of +memory from a pool for an indeterminate amount of time, it may be appropriate +to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then +copy out the relevant bits. + +```js +// need to keep around a few small chunks of memory +const store = []; + +socket.on('readable', () => { + const data = socket.read(); + // allocate for retained data + const sb = Buffer.allocUnsafeSlow(10); + // copy the data into the new allocation + data.copy(sb, 0, 0, 10); + store.push(sb); +}); +``` + +Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after* +a developer has observed undue memory retention in their applications. + +A `TypeError` will be thrown if `size` is not a number. + ### Class Method: Buffer.byteLength(string[, encoding]) * `string` {String} @@ -336,6 +578,90 @@ console.log(bufA.length); // 42 ``` +### Class Method: Buffer.from(array) + +* `array` {Array} + +Allocates a new `Buffer` using an `array` of octets. + +```js +const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]); + // creates a new Buffer containing ASCII bytes + // ['b','u','f','f','e','r'] +``` + +A `TypeError` will be thrown if `array` is not an `Array`. + +### Class Method: Buffer.from(arrayBuffer) + +* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or + a `new ArrayBuffer()` + +When passed a reference to the `.buffer` property of a `TypedArray` instance, +the newly created `Buffer` will share the same allocated memory as the +TypedArray. + +```js +const arr = new Uint16Array(2); +arr[0] = 5000; +arr[1] = 4000; + +const buf = Buffer.from(arr.buffer); // shares the memory with arr; + +console.log(buf); + // Prints: + +// changing the TypedArray changes the Buffer also +arr[1] = 6000; + +console.log(buf); + // Prints: +``` + +A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`. + +### Class Method: Buffer.from(buffer) + +* `buffer` {Buffer} + +Copies the passed `buffer` data onto a new `Buffer` instance. + +```js +const buf1 = Buffer.from('buffer'); +const buf2 = Buffer.from(buf1); + +buf1[0] = 0x61; +console.log(buf1.toString()); + // 'auffer' +console.log(buf2.toString()); + // 'buffer' (copy is not changed) +``` + +A `TypeError` will be thrown if `buffer` is not a `Buffer`. + +### Class Method: Buffer.from(str[, encoding]) + +* `str` {String} String to encode. +* `encoding` {String} Encoding to use, Default: `'utf8'` + +Creates a new `Buffer` containing the given JavaScript string `str`. If +provided, the `encoding` parameter identifies the character encoding. +If not provided, `encoding` defaults to `'utf8'`. + +```js +const buf1 = Buffer.from('this is a tést'); +console.log(buf1.toString()); + // prints: this is a tést +console.log(buf1.toString('ascii')); + // prints: this is a tC)st + +const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex'); +console.log(buf2.toString()); + // prints: this is a tést +``` + +A `TypeError` will be thrown if `str` is not a string. + ### Class Method: Buffer.isBuffer(obj) * `obj` {Object} @@ -1383,6 +1709,31 @@ socket.on('readable', () => { Use of `SlowBuffer` should be used only as a last resort *after* a developer has observed undue memory retention in their applications. +### new SlowBuffer(size) + +* `size` Number + +Allocates a new `SlowBuffer` of `size` bytes. The `size` must be less than +or equal to the value of `require('buffer').kMaxLength` (on 64-bit +architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is +thrown. If a `size` less than 0 is specified, a zero-length `SlowBuffer` will be +created. + +The underlying memory for `SlowBuffer` instances is *not initialized*. The +contents of a newly created `SlowBuffer` are unknown and could contain +sensitive data. Use [`buf.fill(0)`][] to initialize a `SlowBuffer` to zeroes. + +```js +const SlowBuffer = require('buffer').SlowBuffer; +const buf = new SlowBuffer(5); +console.log(buf); + // + // (octets will be different, every time) +buf.fill(0); +console.log(buf); + // +``` + [`Array#includes()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes [`Array#indexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf [`buf.entries()`]: #buffer_buf_entries @@ -1397,3 +1748,11 @@ has observed undue memory retention in their applications. [`util.inspect()`]: util.html#util_util_inspect_object_options [iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5 +[buffer_from_array]: #buffer_class_method_buffer_from_array +[buffer_from_buffer]: #buffer_class_method_buffer_from_buffer +[buffer_from_arraybuf]: #buffer_class_method_buffer_from_arraybuffer +[buffer_from_string]: #buffer_class_method_buffer_from_str_encoding +[buffer_allocunsafe]: #buffer_class_method_buffer_allocunsafe_size +[buffer_allocunsafeslow]: #buffer_class_method_buffer_allocunsafeslow_size +[buffer_alloc]: #buffer_class_method_buffer_alloc_size_fill_encoding +[`TypedArray.from()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from diff --git a/lib/buffer.js b/lib/buffer.js index 23771b15bfca0e..a78ada9f8e72aa 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -65,9 +65,71 @@ function Buffer(arg, encoding) { return fromObject(arg); } +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer) + **/ +Buffer.from = function(value, encoding) { + if (typeof value === 'number') + throw new TypeError('"value" argument must not be a number'); + + if (typeof value === 'string') { + return fromString(value, encoding); + } + + // Unusual. + return fromObject(value); +}; + Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); Object.setPrototypeOf(Buffer, Uint8Array); +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function(size, fill, encoding) { + if (typeof size !== 'number') + throw new TypeError('"size" argument must be a number'); + if (size <= 0) + return createBuffer(size); + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + // Also, don't apply encoding if fill is a number. + if (typeof fill !== 'number' && typeof encoding === 'string') + fill = Buffer.from(fill, encoding); + + return createBuffer(size, true).fill(fill); + } + return createBuffer(size); +}; + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer + * instance. + **/ +Buffer.allocUnsafe = function(size) { + if (typeof size !== 'number') + throw new TypeError('"size" argument must be a number'); + return allocate(size); +}; + +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled + * Buffer instance that is not allocated off the pre-initialized pool. + **/ +Buffer.allocUnsafeSlow = function(size) { + if (typeof size !== 'number') + throw new TypeError('"size" argument must be a number'); + return createBuffer(size, true); +}; + function SlowBuffer(length) { if (+length != length) length = 0; @@ -431,7 +493,7 @@ function slowIndexOf(buffer, val, byteOffset, encoding) { case 'ascii': case 'hex': return binding.indexOfBuffer( - buffer, Buffer(val, encoding), byteOffset, encoding); + buffer, Buffer.from(val, encoding), byteOffset, encoding); default: if (loweredCase) { @@ -485,6 +547,10 @@ Buffer.prototype.fill = function fill(val, start, end) { var code = val.charCodeAt(0); if (code < 256) val = code; + } else if (val.length === 0) { + // Previously, if val === '', the Buffer would not fill, + // which is rather surprising. + val = 0; } binding.fill(this, val, start, end); diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js new file mode 100644 index 00000000000000..a90625e163c5cc --- /dev/null +++ b/test/parallel/test-buffer-alloc.js @@ -0,0 +1,1451 @@ +'use strict'; +var common = require('../common'); +var assert = require('assert'); + +var Buffer = require('buffer').Buffer; +var SlowBuffer = require('buffer').SlowBuffer; + +// counter to ensure unique value is always copied +var cntr = 0; + +var b = Buffer.alloc(1024); + +console.log('b.length == %d', b.length); +assert.strictEqual(1024, b.length); + +b[0] = -1; +assert.strictEqual(b[0], 255); + +for (let i = 0; i < 1024; i++) { + b[i] = i % 256; +} + +for (let i = 0; i < 1024; i++) { + assert.strictEqual(i % 256, b[i]); +} + +var c = Buffer.alloc(512); +console.log('c.length == %d', c.length); +assert.strictEqual(512, c.length); + +var d = Buffer.from([]); +assert.strictEqual(0, d.length); + +var ui32 = new Uint32Array(4).fill(42); +var e = Buffer.from(ui32); +assert.deepEqual(ui32, e); + +// First check Buffer#fill() works as expected. + +assert.throws(function() { + Buffer.allocUnsafe(8).fill('a', -1); +}); + +assert.throws(function() { + Buffer.allocUnsafe(8).fill('a', 0, 9); +}); + +// Make sure this doesn't hang indefinitely. +Buffer.allocUnsafe(8).fill(''); + +{ + const buf = Buffer.allocUnsafe(64); + buf.fill(10); + for (let i = 0; i < buf.length; i++) + assert.equal(buf[i], 10); + + buf.fill(11, 0, buf.length >> 1); + for (let i = 0; i < buf.length >> 1; i++) + assert.equal(buf[i], 11); + for (let i = (buf.length >> 1) + 1; i < buf.length; i++) + assert.equal(buf[i], 10); + + buf.fill('h'); + for (let i = 0; i < buf.length; i++) + assert.equal('h'.charCodeAt(0), buf[i]); + + buf.fill(0); + for (let i = 0; i < buf.length; i++) + assert.equal(0, buf[i]); + + buf.fill(null); + for (let i = 0; i < buf.length; i++) + assert.equal(0, buf[i]); + + buf.fill(1, 16, 32); + for (let i = 0; i < 16; i++) + assert.equal(0, buf[i]); + for (let i = 16; i < 32; i++) + assert.equal(1, buf[i]); + for (let i = 32; i < buf.length; i++) + assert.equal(0, buf[i]); +} + +{ + const buf = Buffer.allocUnsafe(10); + buf.fill('abc'); + assert.equal(buf.toString(), 'abcabcabca'); + buf.fill('է'); + assert.equal(buf.toString(), 'էէէէէ'); +} + +{ + // copy 512 bytes, from 0 to 512. + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 512); + console.log('copied %d bytes from b into c', copied); + assert.strictEqual(512, copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // copy c into b, without specifying sourceEnd + b.fill(++cntr); + c.fill(++cntr); + const copied = c.copy(b, 0, 0); + console.log('copied %d bytes from c into b w/o sourceEnd', copied); + assert.strictEqual(c.length, copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // copy c into b, without specifying sourceStart + b.fill(++cntr); + c.fill(++cntr); + const copied = c.copy(b, 0); + console.log('copied %d bytes from c into b w/o sourceStart', copied); + assert.strictEqual(c.length, copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // copy longer buffer b to shorter c without targetStart + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c); + console.log('copied %d bytes from b into c w/o targetStart', copied); + assert.strictEqual(c.length, copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // copy starting near end of b to c + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, b.length - Math.floor(c.length / 2)); + console.log('copied %d bytes from end of b into beginning of c', copied); + assert.strictEqual(Math.floor(c.length / 2), copied); + for (let i = 0; i < Math.floor(c.length / 2); i++) { + assert.strictEqual(b[b.length - Math.floor(c.length / 2) + i], c[i]); + } + for (let i = Math.floor(c.length / 2) + 1; i < c.length; i++) { + assert.strictEqual(c[c.length - 1], c[i]); + } +} + +{ + // try to copy 513 bytes, and check we don't overrun c + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 513); + console.log('copied %d bytes from b trying to overrun c', copied); + assert.strictEqual(c.length, copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // copy 768 bytes from b into b + b.fill(++cntr); + b.fill(++cntr, 256); + const copied = b.copy(b, 0, 256, 1024); + console.log('copied %d bytes from b into b', copied); + assert.strictEqual(768, copied); + for (let i = 0; i < b.length; i++) { + assert.strictEqual(cntr, b[i]); + } +} + +// copy string longer than buffer length (failure will segfault) +var bb = Buffer.allocUnsafe(10); +bb.fill('hello crazy world'); + + +// try to copy from before the beginning of b +assert.doesNotThrow(() => { b.copy(c, 0, 100, 10); }); + +// copy throws at negative sourceStart +assert.throws(function() { + Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, -1); +}, RangeError); + +{ + // check sourceEnd resets to targetEnd if former is greater than the latter + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 1025); + console.log('copied %d bytes from b into c', copied); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +// throw with negative sourceEnd +console.log('test copy at negative sourceEnd'); +assert.throws(function() { + b.copy(c, 0, 0, -1); +}, RangeError); + +// when sourceStart is greater than sourceEnd, zero copied +assert.equal(b.copy(c, 0, 100, 10), 0); + +// when targetStart > targetLength, zero copied +assert.equal(b.copy(c, 512, 0, 10), 0); + +var caught_error; + +// invalid encoding for Buffer.toString +caught_error = null; +try { + b.toString('invalid'); +} catch (err) { + caught_error = err; +} +assert.strictEqual('Unknown encoding: invalid', caught_error.message); + +// invalid encoding for Buffer.write +caught_error = null; +try { + b.write('test string', 0, 5, 'invalid'); +} catch (err) { + caught_error = err; +} +assert.strictEqual('Unknown encoding: invalid', caught_error.message); + +// try to create 0-length buffers +Buffer.from(''); +Buffer.from('', 'ascii'); +Buffer.from('', 'binary'); +Buffer.alloc(0); + +// try to write a 0-length string beyond the end of b +assert.throws(function() { + b.write('', 2048); +}, RangeError); + +// throw when writing to negative offset +assert.throws(function() { + b.write('a', -1); +}, RangeError); + +// throw when writing past bounds from the pool +assert.throws(function() { + b.write('a', 2048); +}, RangeError); + +// throw when writing to negative offset +assert.throws(function() { + b.write('a', -1); +}, RangeError); + +// try to copy 0 bytes worth of data into an empty buffer +b.copy(Buffer.alloc(0), 0, 0, 0); + +// try to copy 0 bytes past the end of the target buffer +b.copy(Buffer.alloc(0), 1, 1, 1); +b.copy(Buffer.allocUnsafe(1), 1, 1, 1); + +// try to copy 0 bytes from past the end of the source buffer +b.copy(Buffer.allocUnsafe(1), 0, 2048, 2048); + +const rangeBuffer = Buffer.from('abc'); + +// if start >= buffer's length, empty string will be returned +assert.equal(rangeBuffer.toString('ascii', 3), ''); +//assert.equal(rangeBuffer.toString('ascii', +Infinity), ''); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', 3.14, 3), ''); +//assert.equal(rangeBuffer.toString('ascii', 'Infinity', 3), '');// fails on 4.x + +// if end <= 0, empty string will be returned +assert.equal(rangeBuffer.toString('ascii', 1, 0), ''); +//assert.equal(rangeBuffer.toString('ascii', 1, -1.2), ''); // fails on 4.x +//assert.equal(rangeBuffer.toString('ascii', 1, -100), ''); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', 1, -Infinity), ''); + +// if start < 0, start will be taken as zero +//assert.equal(rangeBuffer.toString('ascii', -1, 3), 'abc'); // fails on 4.x +//assert.equal(rangeBuffer.toString('ascii', -1.99, 3), 'abc'); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', -Infinity, 3), 'abc'); +//assert.equal(rangeBuffer.toString('ascii', '-1', 3), 'abc'); // fails on 4.x +//assert.equal(rangeBuffer.toString('ascii', '-1.99', 3), 'abc');// fails on 4.x +assert.equal(rangeBuffer.toString('ascii', '-Infinity', 3), 'abc'); + +// if start is an invalid integer, start will be taken as zero +assert.equal(rangeBuffer.toString('ascii', 'node.js', 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', {}, 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', [], 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', NaN, 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', null, 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', undefined, 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', false, 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', '', 3), 'abc'); + +// but, if start is an integer when coerced, then it will be coerced and used. +//assert.equal(rangeBuffer.toString('ascii', '-1', 3), 'abc'); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', '1', 3), 'bc'); +assert.equal(rangeBuffer.toString('ascii', '-Infinity', 3), 'abc'); +assert.equal(rangeBuffer.toString('ascii', '3', 3), ''); +assert.equal(rangeBuffer.toString('ascii', Number(3), 3), ''); +assert.equal(rangeBuffer.toString('ascii', '3.14', 3), ''); +assert.equal(rangeBuffer.toString('ascii', '1.99', 3), 'bc'); +//assert.equal(rangeBuffer.toString('ascii', '-1.99', 3), 'abc');// fails on 4.x +assert.equal(rangeBuffer.toString('ascii', 1.99, 3), 'bc'); +assert.equal(rangeBuffer.toString('ascii', true, 3), 'bc'); + +// if end > buffer's length, end will be taken as buffer's length +assert.equal(rangeBuffer.toString('ascii', 0, 5), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, 6.99), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, Infinity), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, '5'), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, '6.99'), 'abc'); + +// fails on v4.x +//assert.equal(rangeBuffer.toString('ascii', 0, 'Infinity'), 'abc'); + +// if end is an invalid integer, end will be taken as buffer's length +assert.equal(rangeBuffer.toString('ascii', 0, 'node.js'), ''); +assert.equal(rangeBuffer.toString('ascii', 0, {}), ''); +assert.equal(rangeBuffer.toString('ascii', 0, NaN), ''); +assert.equal(rangeBuffer.toString('ascii', 0, undefined), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, null), ''); +assert.equal(rangeBuffer.toString('ascii', 0, []), ''); +assert.equal(rangeBuffer.toString('ascii', 0, false), ''); +assert.equal(rangeBuffer.toString('ascii', 0, ''), ''); + +// but, if end is an integer when coerced, then it will be coerced and used. +//assert.equal(rangeBuffer.toString('ascii', 0, '-1'), ''); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', 0, '1'), 'a'); +assert.equal(rangeBuffer.toString('ascii', 0, '-Infinity'), ''); +assert.equal(rangeBuffer.toString('ascii', 0, '3'), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, Number(3)), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, '3.14'), 'abc'); +assert.equal(rangeBuffer.toString('ascii', 0, '1.99'), 'a'); +//assert.equal(rangeBuffer.toString('ascii', 0, '-1.99'), ''); // fails on 4.x +assert.equal(rangeBuffer.toString('ascii', 0, 1.99), 'a'); +assert.equal(rangeBuffer.toString('ascii', 0, true), 'a'); + +// try toString() with a object as a encoding +assert.equal(rangeBuffer.toString({toString: function() { + return 'ascii'; +}}), 'abc'); + +// testing for smart defaults and ability to pass string values as offset +var writeTest = Buffer.from('abcdes'); +writeTest.write('n', 'ascii'); +writeTest.write('o', 'ascii', '1'); +writeTest.write('d', '2', 'ascii'); +writeTest.write('e', 3, 'ascii'); +writeTest.write('j', 'ascii', 4); +assert.equal(writeTest.toString(), 'nodejs'); + +// ASCII slice test +{ + const asciiString = 'hello world'; + + for (let i = 0; i < asciiString.length; i++) { + b[i] = asciiString.charCodeAt(i); + } + const asciiSlice = b.toString('ascii', 0, asciiString.length); + assert.equal(asciiString, asciiSlice); +} + +{ + const asciiString = 'hello world'; + const offset = 100; + + const written = b.write(asciiString, offset, 'ascii'); + assert.equal(asciiString.length, written); + const asciiSlice = b.toString('ascii', offset, offset + asciiString.length); + assert.equal(asciiString, asciiSlice); +} + +{ + const asciiString = 'hello world'; + const offset = 100; + + const sliceA = b.slice(offset, offset + asciiString.length); + const sliceB = b.slice(offset, offset + asciiString.length); + for (let i = 0; i < asciiString.length; i++) { + assert.equal(sliceA[i], sliceB[i]); + } +} + +// UTF-8 slice test + +var utf8String = '¡hέlló wôrld!'; +var offset = 100; + +b.write(utf8String, 0, Buffer.byteLength(utf8String), 'utf8'); +var utf8Slice = b.toString('utf8', 0, Buffer.byteLength(utf8String)); +assert.equal(utf8String, utf8Slice); + +var written = b.write(utf8String, offset, 'utf8'); +assert.equal(Buffer.byteLength(utf8String), written); +utf8Slice = b.toString('utf8', offset, offset + Buffer.byteLength(utf8String)); +assert.equal(utf8String, utf8Slice); + +var sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String)); +var sliceB = b.slice(offset, offset + Buffer.byteLength(utf8String)); +for (let i = 0; i < Buffer.byteLength(utf8String); i++) { + assert.equal(sliceA[i], sliceB[i]); +} + +{ + const slice = b.slice(100, 150); + assert.equal(50, slice.length); + for (let i = 0; i < 50; i++) { + assert.equal(b[100 + i], slice[i]); + } +} + +{ + // make sure only top level parent propagates from allocPool + const b = Buffer.allocUnsafe(5); + const c = b.slice(0, 4); + const d = c.slice(0, 2); + assert.equal(b.parent, c.parent); + assert.equal(b.parent, d.parent); +} + +{ + // also from a non-pooled instance + const b = new SlowBuffer(5); + const c = b.slice(0, 4); + const d = c.slice(0, 2); + assert.equal(c.parent, d.parent); +} + +{ + // Bug regression test + const testValue = '\u00F6\u65E5\u672C\u8A9E'; // ö日本語 + const buffer = Buffer.allocUnsafe(32); + const size = buffer.write(testValue, 0, 'utf8'); + console.log('bytes written to buffer: ' + size); + const slice = buffer.toString('utf8', 0, size); + assert.equal(slice, testValue); +} + +{ + // Test triple slice + const a = Buffer.allocUnsafe(8); + for (let i = 0; i < 8; i++) a[i] = i; + const b = a.slice(4, 8); + assert.equal(4, b[0]); + assert.equal(5, b[1]); + assert.equal(6, b[2]); + assert.equal(7, b[3]); + const c = b.slice(2, 4); + assert.equal(6, c[0]); + assert.equal(7, c[1]); +} + +{ + const d = Buffer.from([23, 42, 255]); + assert.equal(d.length, 3); + assert.equal(d[0], 23); + assert.equal(d[1], 42); + assert.equal(d[2], 255); + assert.deepEqual(d, Buffer.from(d)); +} + +{ + const e = Buffer.from('über'); + console.error('uber: \'%s\'', e.toString()); + assert.deepEqual(e, Buffer.from([195, 188, 98, 101, 114])); +} + +{ + const f = Buffer.from('über', 'ascii'); + console.error('f.length: %d (should be 4)', f.length); + assert.deepEqual(f, Buffer.from([252, 98, 101, 114])); +} + +['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { + { + const f = Buffer.from('über', encoding); + console.error('f.length: %d (should be 8)', f.length); + assert.deepEqual(f, Buffer.from([252, 0, 98, 0, 101, 0, 114, 0])); + } + + { + const f = Buffer.from('привет', encoding); + console.error('f.length: %d (should be 12)', f.length); + assert.deepEqual(f, + Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); + assert.equal(f.toString(encoding), 'привет'); + } + + { + const f = Buffer.from([0, 0, 0, 0, 0]); + assert.equal(f.length, 5); + const size = f.write('あいうえお', encoding); + console.error('bytes written to buffer: %d (should be 4)', size); + assert.equal(size, 4); + assert.deepEqual(f, Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00])); + } +}); + +{ + const f = Buffer.from('\uD83D\uDC4D', 'utf-16le'); // THUMBS UP SIGN (U+1F44D) + assert.equal(f.length, 4); + assert.deepEqual(f, Buffer.from('3DD84DDC', 'hex')); +} + + +var arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4}; +var g = Buffer.from(arrayIsh); +assert.deepEqual(g, Buffer.from([0, 1, 2, 3])); +var strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4}; +g = Buffer.from(strArrayIsh); +assert.deepEqual(g, Buffer.from([0, 1, 2, 3])); + + +// +// Test toString('base64') +// +assert.equal('TWFu', (Buffer.from('Man')).toString('base64')); + +{ + // test that regular and URL-safe base64 both work + const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]; + assert.deepEqual(Buffer.from('//++/++/++//', 'base64'), + Buffer.from(expected)); + assert.deepEqual(Buffer.from('__--_--_--__', 'base64'), + Buffer.from(expected)); +} + +{ + // big example + const quote = 'Man is distinguished, not only by his reason, but by this ' + + 'singular passion from other animals, which is a lust ' + + 'of the mind, that by a perseverance of delight in the ' + + 'continued and indefatigable generation of knowledge, ' + + 'exceeds the short vehemence of any carnal pleasure.'; + const expected = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb' + + '24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci' + + 'BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ' + + 'gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu' + + 'dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ' + + 'GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm' + + '5hbCBwbGVhc3VyZS4='; + assert.equal(expected, (Buffer.from(quote)).toString('base64')); + + let b = Buffer.allocUnsafe(1024); + let bytesWritten = b.write(expected, 0, 'base64'); + assert.equal(quote.length, bytesWritten); + assert.equal(quote, b.toString('ascii', 0, quote.length)); + + // check that the base64 decoder ignores whitespace + const expectedWhite = expected.slice(0, 60) + ' \n' + + expected.slice(60, 120) + ' \n' + + expected.slice(120, 180) + ' \n' + + expected.slice(180, 240) + ' \n' + + expected.slice(240, 300) + '\n' + + expected.slice(300, 360) + '\n'; + b = Buffer.allocUnsafe(1024); + bytesWritten = b.write(expectedWhite, 0, 'base64'); + assert.equal(quote.length, bytesWritten); + assert.equal(quote, b.toString('ascii', 0, quote.length)); + + // check that the base64 decoder on the constructor works + // even in the presence of whitespace. + b = Buffer.from(expectedWhite, 'base64'); + assert.equal(quote.length, b.length); + assert.equal(quote, b.toString('ascii', 0, quote.length)); + + // check that the base64 decoder ignores illegal chars + const expectedIllegal = expected.slice(0, 60) + ' \x80' + + expected.slice(60, 120) + ' \xff' + + expected.slice(120, 180) + ' \x00' + + expected.slice(180, 240) + ' \x98' + + expected.slice(240, 300) + '\x03' + + expected.slice(300, 360); + b = Buffer.from(expectedIllegal, 'base64'); + assert.equal(quote.length, b.length); + assert.equal(quote, b.toString('ascii', 0, quote.length)); +} + +assert.equal(Buffer.from('', 'base64').toString(), ''); +assert.equal(Buffer.from('K', 'base64').toString(), ''); + +// multiple-of-4 with padding +assert.equal(Buffer.from('Kg==', 'base64').toString(), '*'); +assert.equal(Buffer.from('Kio=', 'base64').toString(), '**'); +assert.equal(Buffer.from('Kioq', 'base64').toString(), '***'); +assert.equal(Buffer.from('KioqKg==', 'base64').toString(), '****'); +assert.equal(Buffer.from('KioqKio=', 'base64').toString(), '*****'); +assert.equal(Buffer.from('KioqKioq', 'base64').toString(), '******'); +assert.equal(Buffer.from('KioqKioqKg==', 'base64').toString(), '*******'); +assert.equal(Buffer.from('KioqKioqKio=', 'base64').toString(), '********'); +assert.equal(Buffer.from('KioqKioqKioq', 'base64').toString(), '*********'); +assert.equal(Buffer.from('KioqKioqKioqKg==', 'base64').toString(), + '**********'); +assert.equal(Buffer.from('KioqKioqKioqKio=', 'base64').toString(), + '***********'); +assert.equal(Buffer.from('KioqKioqKioqKioq', 'base64').toString(), + '************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKg==', 'base64').toString(), + '*************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKio=', 'base64').toString(), + '**************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioq', 'base64').toString(), + '***************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKg==', 'base64').toString(), + '****************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKio=', 'base64').toString(), + '*****************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioq', 'base64').toString(), + '******************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKg==', 'base64').toString(), + '*******************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKio=', 'base64').toString(), + '********************'); + +// no padding, not a multiple of 4 +assert.equal(Buffer.from('Kg', 'base64').toString(), '*'); +assert.equal(Buffer.from('Kio', 'base64').toString(), '**'); +assert.equal(Buffer.from('KioqKg', 'base64').toString(), '****'); +assert.equal(Buffer.from('KioqKio', 'base64').toString(), '*****'); +assert.equal(Buffer.from('KioqKioqKg', 'base64').toString(), '*******'); +assert.equal(Buffer.from('KioqKioqKio', 'base64').toString(), '********'); +assert.equal(Buffer.from('KioqKioqKioqKg', 'base64').toString(), '**********'); +assert.equal(Buffer.from('KioqKioqKioqKio', 'base64').toString(), + '***********'); +assert.equal(Buffer.from('KioqKioqKioqKioqKg', 'base64').toString(), + '*************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKio', 'base64').toString(), + '**************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKg', 'base64').toString(), + '****************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKio', 'base64').toString(), + '*****************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKg', 'base64').toString(), + '*******************'); +assert.equal(Buffer.from('KioqKioqKioqKioqKioqKioqKio', 'base64').toString(), + '********************'); + +// handle padding graciously, multiple-of-4 or not +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==', 'base64').length, + 32 +); +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=', 'base64').length, + 32 +); +assert.equal( + Buffer.from('72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw', 'base64').length, + 32 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==', 'base64').length, + 31 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=', 'base64').length, + 31 +); +assert.equal( + Buffer.from('w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg', 'base64').length, + 31 +); + +// This string encodes single '.' character in UTF-16 +var dot = Buffer.from('//4uAA==', 'base64'); +assert.equal(dot[0], 0xff); +assert.equal(dot[1], 0xfe); +assert.equal(dot[2], 0x2e); +assert.equal(dot[3], 0x00); +assert.equal(dot.toString('base64'), '//4uAA=='); + +{ + // Writing base64 at a position > 0 should not mangle the result. + // + // https://github.com/joyent/node/issues/402 + const segments = ['TWFkbmVzcz8h', 'IFRoaXM=', 'IGlz', 'IG5vZGUuanMh']; + const b = Buffer.allocUnsafe(64); + let pos = 0; + + for (let i = 0; i < segments.length; ++i) { + pos += b.write(segments[i], pos, 'base64'); + } + assert.equal(b.toString('binary', 0, pos), 'Madness?! This is node.js!'); +} + +// Regression test for https://github.com/nodejs/node/issues/3496. +assert.equal(Buffer.from('=bad'.repeat(1e4), 'base64').length, 0); + +{ + // Creating buffers larger than pool size. + const l = Buffer.poolSize + 5; + let s = ''; + for (let i = 0; i < l; i++) { + s += 'h'; + } + + const b = Buffer.from(s); + + for (let i = 0; i < l; i++) { + assert.equal('h'.charCodeAt(0), b[i]); + } + + const sb = b.toString(); + assert.equal(sb.length, s.length); + assert.equal(sb, s); +} + +{ + // Single argument slice + const b = Buffer.from('abcde'); + assert.equal('bcde', b.slice(1).toString()); +} + +// slice(0,0).length === 0 +assert.equal(0, Buffer.from('hello').slice(0, 0).length); + +// test hex toString +console.log('Create hex string from buffer'); +var hexb = Buffer.allocUnsafe(256); +for (let i = 0; i < 256; i++) { + hexb[i] = i; +} +var hexStr = hexb.toString('hex'); +assert.equal(hexStr, + '000102030405060708090a0b0c0d0e0f' + + '101112131415161718191a1b1c1d1e1f' + + '202122232425262728292a2b2c2d2e2f' + + '303132333435363738393a3b3c3d3e3f' + + '404142434445464748494a4b4c4d4e4f' + + '505152535455565758595a5b5c5d5e5f' + + '606162636465666768696a6b6c6d6e6f' + + '707172737475767778797a7b7c7d7e7f' + + '808182838485868788898a8b8c8d8e8f' + + '909192939495969798999a9b9c9d9e9f' + + 'a0a1a2a3a4a5a6a7a8a9aaabacadaeaf' + + 'b0b1b2b3b4b5b6b7b8b9babbbcbdbebf' + + 'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf' + + 'd0d1d2d3d4d5d6d7d8d9dadbdcdddedf' + + 'e0e1e2e3e4e5e6e7e8e9eaebecedeeef' + + 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'); + +console.log('Create buffer from hex string'); +var hexb2 = Buffer.from(hexStr, 'hex'); +for (let i = 0; i < 256; i++) { + assert.equal(hexb2[i], hexb[i]); +} + +{ + // test an invalid slice end. + console.log('Try to slice off the end of the buffer'); + const b = Buffer.from([1, 2, 3, 4, 5]); + const b2 = b.toString('hex', 1, 10000); + const b3 = b.toString('hex', 1, 5); + const b4 = b.toString('hex', 1); + assert.equal(b2, b3); + assert.equal(b2, b4); +} + +function buildBuffer(data) { + if (Array.isArray(data)) { + var buffer = Buffer.allocUnsafe(data.length); + data.forEach(function(v, k) { + buffer[k] = v; + }); + return buffer; + } + return null; +} + +var x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]); + +console.log(x.inspect()); +assert.equal('', x.inspect()); + +{ + const z = x.slice(4); + console.log(z.inspect()); + console.log(z.length); + assert.equal(5, z.length); + assert.equal(0x6f, z[0]); + assert.equal(0xa3, z[1]); + assert.equal(0x62, z[2]); + assert.equal(0x61, z[3]); + assert.equal(0x72, z[4]); +} + +{ + const z = x.slice(0); + console.log(z.inspect()); + console.log(z.length); + assert.equal(z.length, x.length); +} + +{ + const z = x.slice(0, 4); + console.log(z.inspect()); + console.log(z.length); + assert.equal(4, z.length); + assert.equal(0x81, z[0]); + assert.equal(0xa3, z[1]); +} + +{ + const z = x.slice(0, 9); + console.log(z.inspect()); + console.log(z.length); + assert.equal(9, z.length); +} + +{ + const z = x.slice(1, 4); + console.log(z.inspect()); + console.log(z.length); + assert.equal(3, z.length); + assert.equal(0xa3, z[0]); +} + +{ + const z = x.slice(2, 4); + console.log(z.inspect()); + console.log(z.length); + assert.equal(2, z.length); + assert.equal(0x66, z[0]); + assert.equal(0x6f, z[1]); +} + +assert.equal(0, Buffer.from('hello').slice(0, 0).length); + +['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { + const b = Buffer.allocUnsafe(10); + b.write('あいうえお', encoding); + assert.equal(b.toString(encoding), 'あいうえお'); +}); + +{ + // Binary encoding should write only one byte per character. + const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); + let s = String.fromCharCode(0xffff); + b.write(s, 0, 'binary'); + assert.equal(0xff, b[0]); + assert.equal(0xad, b[1]); + assert.equal(0xbe, b[2]); + assert.equal(0xef, b[3]); + s = String.fromCharCode(0xaaee); + b.write(s, 0, 'binary'); + assert.equal(0xee, b[0]); + assert.equal(0xad, b[1]); + assert.equal(0xbe, b[2]); + assert.equal(0xef, b[3]); +} + +{ + // #1210 Test UTF-8 string includes null character + let buf = Buffer.from('\0'); + assert.equal(buf.length, 1); + buf = Buffer.from('\0\0'); + assert.equal(buf.length, 2); +} + +{ + const buf = Buffer.allocUnsafe(2); + let written = buf.write(''); // 0byte + assert.equal(written, 0); + written = buf.write('\0'); // 1byte (v8 adds null terminator) + assert.equal(written, 1); + written = buf.write('a\0'); // 1byte * 2 + assert.equal(written, 2); + written = buf.write('あ'); // 3bytes + assert.equal(written, 0); + written = buf.write('\0あ'); // 1byte + 3bytes + assert.equal(written, 1); + written = buf.write('\0\0あ'); // 1byte * 2 + 3bytes + assert.equal(written, 2); +} + +{ + const buf = Buffer.allocUnsafe(10); + written = buf.write('あいう'); // 3bytes * 3 (v8 adds null terminator) + assert.equal(written, 9); + written = buf.write('あいう\0'); // 3bytes * 3 + 1byte + assert.equal(written, 10); +} + +{ + // #243 Test write() with maxLength + const buf = Buffer.allocUnsafe(4); + buf.fill(0xFF); + let written = buf.write('abcd', 1, 2, 'utf8'); + console.log(buf); + assert.equal(written, 2); + assert.equal(buf[0], 0xFF); + assert.equal(buf[1], 0x61); + assert.equal(buf[2], 0x62); + assert.equal(buf[3], 0xFF); + + buf.fill(0xFF); + written = buf.write('abcd', 1, 4); + console.log(buf); + assert.equal(written, 3); + assert.equal(buf[0], 0xFF); + assert.equal(buf[1], 0x61); + assert.equal(buf[2], 0x62); + assert.equal(buf[3], 0x63); + + buf.fill(0xFF); + written = buf.write('abcd', 'utf8', 1, 2); // legacy style + console.log(buf); + assert.equal(written, 2); + assert.equal(buf[0], 0xFF); + assert.equal(buf[1], 0x61); + assert.equal(buf[2], 0x62); + assert.equal(buf[3], 0xFF); + + buf.fill(0xFF); + written = buf.write('abcdef', 1, 2, 'hex'); + console.log(buf); + assert.equal(written, 2); + assert.equal(buf[0], 0xFF); + assert.equal(buf[1], 0xAB); + assert.equal(buf[2], 0xCD); + assert.equal(buf[3], 0xFF); + + ['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) { + buf.fill(0xFF); + written = buf.write('abcd', 0, 2, encoding); + console.log(buf); + assert.equal(written, 2); + assert.equal(buf[0], 0x61); + assert.equal(buf[1], 0x00); + assert.equal(buf[2], 0xFF); + assert.equal(buf[3], 0xFF); + }); +} + +{ + // test offset returns are correct + const b = Buffer.allocUnsafe(16); + assert.equal(4, b.writeUInt32LE(0, 0)); + assert.equal(6, b.writeUInt16LE(0, 4)); + assert.equal(7, b.writeUInt8(0, 6)); + assert.equal(8, b.writeInt8(0, 7)); + assert.equal(16, b.writeDoubleLE(0, 8)); +} + +{ + // test unmatched surrogates not producing invalid utf8 output + // ef bf bd = utf-8 representation of unicode replacement character + // see https://codereview.chromium.org/121173009/ + const buf = Buffer.from('ab\ud800cd', 'utf8'); + assert.equal(buf[0], 0x61); + assert.equal(buf[1], 0x62); + assert.equal(buf[2], 0xef); + assert.equal(buf[3], 0xbf); + assert.equal(buf[4], 0xbd); + assert.equal(buf[5], 0x63); + assert.equal(buf[6], 0x64); +} + +{ + // test for buffer overrun + const buf = Buffer.from([0, 0, 0, 0, 0]); // length: 5 + var sub = buf.slice(0, 4); // length: 4 + written = sub.write('12345', 'binary'); + assert.equal(written, 4); + assert.equal(buf[4], 0); +} + +// Check for fractional length args, junk length args, etc. +// https://github.com/joyent/node/issues/1758 + +// Call .fill() first, stops valgrind warning about uninitialized memory reads. +Buffer.allocUnsafe(3.3).fill().toString(); +// throws bad argument error in commit 43cb4ec +assert.equal(Buffer.allocUnsafe(-1).length, 0); +assert.equal(Buffer.allocUnsafe(NaN).length, 0); +assert.equal(Buffer.allocUnsafe(3.3).length, 3); +assert.equal(Buffer.from({length: 3.3}).length, 3); +assert.equal(Buffer.from({length: 'BAM'}).length, 0); + +// Make sure that strings are not coerced to numbers. +assert.equal(Buffer.from('99').length, 2); +assert.equal(Buffer.from('13.37').length, 5); + +// Ensure that the length argument is respected. +'ascii utf8 hex base64 binary'.split(' ').forEach(function(enc) { + assert.equal(Buffer.allocUnsafe(1).write('aaaaaa', 0, 1, enc), 1); +}); + +{ + // Regression test, guard against buffer overrun in the base64 decoder. + const a = Buffer.allocUnsafe(3); + const b = Buffer.from('xxx'); + a.write('aaaaaaaa', 'base64'); + assert.equal(b.toString(), 'xxx'); +} + +// issue GH-3416 +Buffer.from(Buffer.alloc(0), 0, 0); + +[ 'hex', + 'utf8', + 'utf-8', + 'ascii', + 'binary', + 'base64', + 'ucs2', + 'ucs-2', + 'utf16le', + 'utf-16le' ].forEach(function(enc) { + assert.equal(Buffer.isEncoding(enc), true); + }); + +[ 'utf9', + 'utf-7', + 'Unicode-FTW', + 'new gnu gun' ].forEach(function(enc) { + assert.equal(Buffer.isEncoding(enc), false); + }); + + +// GH-5110 +(function() { + const buffer = Buffer.from('test'); + const string = JSON.stringify(buffer); + + assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}'); + + assert.deepEqual(buffer, JSON.parse(string, function(key, value) { + return value && value.type === 'Buffer' + ? Buffer.from(value.data) + : value; + })); +})(); + +// issue GH-7849 +(function() { + var buf = Buffer.from('test'); + var json = JSON.stringify(buf); + var obj = JSON.parse(json); + var copy = Buffer.from(obj); + + assert(buf.equals(copy)); +})(); + +// issue GH-4331 +assert.throws(function() { + Buffer.allocUnsafe(0xFFFFFFFF); +}, RangeError); +assert.throws(function() { + Buffer.allocUnsafe(0xFFFFFFFFF); +}, RangeError); + + +// attempt to overflow buffers, similar to previous bug in array buffers +assert.throws(function() { + var buf = Buffer(8); + buf.readFloatLE(0xffffffff); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.writeFloatLE(0.0, 0xffffffff); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.readFloatLE(0xffffffff); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.writeFloatLE(0.0, 0xffffffff); +}, RangeError); + + +// ensure negative values can't get past offset +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.readFloatLE(-1); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.writeFloatLE(0.0, -1); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.readFloatLE(-1); +}, RangeError); + +assert.throws(function() { + var buf = Buffer.allocUnsafe(8); + buf.writeFloatLE(0.0, -1); +}, RangeError); + +// offset checks +{ + const buf = Buffer.alloc(0); + + assert.throws(function() { buf.readUInt8(0); }, RangeError); + assert.throws(function() { buf.readInt8(0); }, RangeError); +} + +{ + const buf = Buffer.from([0xFF]); + + assert.equal(buf.readUInt8(0), 255); + assert.equal(buf.readInt8(0), -1); +} + +[16, 32].forEach(function(bits) { + var buf = Buffer.allocUnsafe(bits / 8 - 1); + + assert.throws(function() { buf['readUInt' + bits + 'BE'](0); }, + RangeError, + 'readUInt' + bits + 'BE'); + + assert.throws(function() { buf['readUInt' + bits + 'LE'](0); }, + RangeError, + 'readUInt' + bits + 'LE'); + + assert.throws(function() { buf['readInt' + bits + 'BE'](0); }, + RangeError, + 'readInt' + bits + 'BE()'); + + assert.throws(function() { buf['readInt' + bits + 'LE'](0); }, + RangeError, + 'readInt' + bits + 'LE()'); +}); + +[16, 32].forEach(function(bits) { + var buf = Buffer.from([0xFF, 0xFF, 0xFF, 0xFF]); + + assert.equal(buf['readUInt' + bits + 'BE'](0), + (0xFFFFFFFF >>> (32 - bits))); + + assert.equal(buf['readUInt' + bits + 'LE'](0), + (0xFFFFFFFF >>> (32 - bits))); + + assert.equal(buf['readInt' + bits + 'BE'](0), + (0xFFFFFFFF >> (32 - bits))); + + assert.equal(buf['readInt' + bits + 'LE'](0), + (0xFFFFFFFF >> (32 - bits))); +}); + +// test for common read(U)IntLE/BE +(function() { + var buf = Buffer.from([0x01, 0x02, 0x03, 0x04, 0x05, 0x06]); + + assert.equal(buf.readUIntLE(0, 1), 0x01); + assert.equal(buf.readUIntBE(0, 1), 0x01); + assert.equal(buf.readUIntLE(0, 3), 0x030201); + assert.equal(buf.readUIntBE(0, 3), 0x010203); + assert.equal(buf.readUIntLE(0, 5), 0x0504030201); + assert.equal(buf.readUIntBE(0, 5), 0x0102030405); + assert.equal(buf.readUIntLE(0, 6), 0x060504030201); + assert.equal(buf.readUIntBE(0, 6), 0x010203040506); + assert.equal(buf.readIntLE(0, 1), 0x01); + assert.equal(buf.readIntBE(0, 1), 0x01); + assert.equal(buf.readIntLE(0, 3), 0x030201); + assert.equal(buf.readIntBE(0, 3), 0x010203); + assert.equal(buf.readIntLE(0, 5), 0x0504030201); + assert.equal(buf.readIntBE(0, 5), 0x0102030405); + assert.equal(buf.readIntLE(0, 6), 0x060504030201); + assert.equal(buf.readIntBE(0, 6), 0x010203040506); +})(); + +// test for common write(U)IntLE/BE +(function() { + var buf = Buffer.allocUnsafe(3); + buf.writeUIntLE(0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.equal(buf.readUIntLE(0, 3), 0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeUIntBE(0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.equal(buf.readUIntBE(0, 3), 0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeIntLE(0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]); + assert.equal(buf.readIntLE(0, 3), 0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeIntBE(0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]); + assert.equal(buf.readIntBE(0, 3), 0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeIntLE(-0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]); + assert.equal(buf.readIntLE(0, 3), -0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeIntBE(-0x123456, 0, 3); + assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]); + assert.equal(buf.readIntBE(0, 3), -0x123456); + + buf = Buffer.allocUnsafe(3); + buf.writeIntLE(-0x123400, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]); + assert.equal(buf.readIntLE(0, 3), -0x123400); + + buf = Buffer.allocUnsafe(3); + buf.writeIntBE(-0x123400, 0, 3); + assert.deepEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]); + assert.equal(buf.readIntBE(0, 3), -0x123400); + + buf = Buffer.allocUnsafe(3); + buf.writeIntLE(-0x120000, 0, 3); + assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0xee]); + assert.equal(buf.readIntLE(0, 3), -0x120000); + + buf = Buffer.allocUnsafe(3); + buf.writeIntBE(-0x120000, 0, 3); + assert.deepEqual(buf.toJSON().data, [0xee, 0x00, 0x00]); + assert.equal(buf.readIntBE(0, 3), -0x120000); + + buf = Buffer.allocUnsafe(5); + buf.writeUIntLE(0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.equal(buf.readUIntLE(0, 5), 0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeUIntBE(0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.equal(buf.readUIntBE(0, 5), 0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeIntLE(0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]); + assert.equal(buf.readIntLE(0, 5), 0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeIntBE(0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]); + assert.equal(buf.readIntBE(0, 5), 0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeIntLE(-0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]); + assert.equal(buf.readIntLE(0, 5), -0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeIntBE(-0x1234567890, 0, 5); + assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]); + assert.equal(buf.readIntBE(0, 5), -0x1234567890); + + buf = Buffer.allocUnsafe(5); + buf.writeIntLE(-0x0012000000, 0, 5); + assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]); + assert.equal(buf.readIntLE(0, 5), -0x0012000000); + + buf = Buffer.allocUnsafe(5); + buf.writeIntBE(-0x0012000000, 0, 5); + assert.deepEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]); + assert.equal(buf.readIntBE(0, 5), -0x0012000000); +})(); + +// test Buffer slice +(function() { + var buf = Buffer.from('0123456789'); + assert.equal(buf.slice(-10, 10), '0123456789'); + assert.equal(buf.slice(-20, 10), '0123456789'); + assert.equal(buf.slice(-20, -10), ''); + assert.equal(buf.slice(), '0123456789'); + assert.equal(buf.slice(0), '0123456789'); + assert.equal(buf.slice(0, 0), ''); + assert.equal(buf.slice(undefined), '0123456789'); + assert.equal(buf.slice('foobar'), '0123456789'); + assert.equal(buf.slice(undefined, undefined), '0123456789'); + + assert.equal(buf.slice(2), '23456789'); + assert.equal(buf.slice(5), '56789'); + assert.equal(buf.slice(10), ''); + assert.equal(buf.slice(5, 8), '567'); + assert.equal(buf.slice(8, -1), '8'); + assert.equal(buf.slice(-10), '0123456789'); + assert.equal(buf.slice(0, -9), '0'); + assert.equal(buf.slice(0, -10), ''); + assert.equal(buf.slice(0, -1), '012345678'); + assert.equal(buf.slice(2, -2), '234567'); + assert.equal(buf.slice(0, 65536), '0123456789'); + assert.equal(buf.slice(65536, 0), ''); + assert.equal(buf.slice(-5, -8), ''); + assert.equal(buf.slice(-5, -3), '56'); + assert.equal(buf.slice(-10, 10), '0123456789'); + for (let i = 0, s = buf.toString(); i < buf.length; ++i) { + assert.equal(buf.slice(i), s.slice(i)); + assert.equal(buf.slice(0, i), s.slice(0, i)); + assert.equal(buf.slice(-i), s.slice(-i)); + assert.equal(buf.slice(0, -i), s.slice(0, -i)); + } + + var utf16Buf = Buffer.from('0123456789', 'utf16le'); + assert.deepEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le')); + + assert.equal(buf.slice('0', '1'), '0'); + assert.equal(buf.slice('-5', '10'), '56789'); + assert.equal(buf.slice('-10', '10'), '0123456789'); + assert.equal(buf.slice('-10', '-5'), '01234'); + assert.equal(buf.slice('-10', '-0'), ''); + assert.equal(buf.slice('111'), ''); + assert.equal(buf.slice('0', '-111'), ''); + + // try to slice a zero length Buffer + // see https://github.com/joyent/node/issues/5881 + SlowBuffer(0).slice(0, 1); +})(); + +// Regression test for #5482: should throw but not assert in C++ land. +assert.throws(function() { + Buffer.from('', 'buffer'); +}, TypeError); + +// Regression test for #6111. Constructing a buffer from another buffer +// should a) work, and b) not corrupt the source buffer. +(function() { + var a = [0]; + for (let i = 0; i < 7; ++i) a = a.concat(a); + a = a.map(function(_, i) { return i; }); + const b = Buffer.from(a); + const c = Buffer.from(b); + assert.equal(b.length, a.length); + assert.equal(c.length, a.length); + for (let i = 0, k = a.length; i < k; ++i) { + assert.equal(a[i], i); + assert.equal(b[i], i); + assert.equal(c[i], i); + } +})(); + + +assert.throws(function() { + Buffer.allocUnsafe((-1 >>> 0) + 1); +}, RangeError); + +assert.throws(function() { + new SlowBuffer((-1 >>> 0) + 1); +}, RangeError); + +if (common.hasCrypto) { + // Test truncation after decode + var crypto = require('crypto'); + + var b1 = Buffer.from('YW55=======', 'base64'); + var b2 = Buffer.from('YW55', 'base64'); + + assert.equal( + crypto.createHash('sha1').update(b1).digest('hex'), + crypto.createHash('sha1').update(b2).digest('hex') + ); +} else { + console.log('1..0 # Skipped: missing crypto'); +} + +// Test Compare +{ + const b = Buffer.alloc(1, 'a'); + const c = Buffer.alloc(1, 'c'); + const d = Buffer.alloc(2, 'aa'); + + assert.equal(b.compare(c), -1); + assert.equal(c.compare(d), 1); + assert.equal(d.compare(b), 1); + assert.equal(b.compare(d), -1); + assert.equal(b.compare(b), 0); + + assert.equal(Buffer.compare(b, c), -1); + assert.equal(Buffer.compare(c, d), 1); + assert.equal(Buffer.compare(d, b), 1); + assert.equal(Buffer.compare(b, d), -1); + assert.equal(Buffer.compare(c, c), 0); + + assert.equal(Buffer.compare(Buffer.alloc(0), Buffer.alloc(0)), 0); + assert.equal(Buffer.compare(Buffer.alloc(0), Buffer.alloc(1)), -1); + assert.equal(Buffer.compare(Buffer.alloc(1), Buffer.alloc(0)), 1); +} + +assert.throws(function() { + var b = Buffer.allocUnsafe(1); + Buffer.compare(b, 'abc'); +}); + +assert.throws(function() { + var b = Buffer.allocUnsafe(1); + Buffer.compare('abc', b); +}); + +assert.throws(function() { + var b = Buffer.allocUnsafe(1); + b.compare('abc'); +}); + +// Test Equals +{ + const b = Buffer.alloc(5, 'abcdf'); + const c = Buffer.alloc(5, 'abcdf'); + const d = Buffer.alloc(5, 'abcde'); + const e = Buffer.alloc(6, 'abcdef'); + + assert.ok(b.equals(c)); + assert.ok(!c.equals(d)); + assert.ok(!d.equals(e)); + assert.ok(d.equals(d)); +} + +assert.throws(function() { + var b = Buffer.allocUnsafe(1); + b.equals('abc'); +}); + +// Regression test for https://github.com/nodejs/node/issues/649. +assert.throws(function() { + Buffer.allocUnsafe(1422561062959).toString('utf8'); +}); + +var ps = Buffer.poolSize; +Buffer.poolSize = 0; +assert.equal(Buffer.allocUnsafe(1).parent, undefined); +Buffer.poolSize = ps; + +// Test Buffer.copy() segfault +assert.throws(function() { + Buffer.allocUnsafe(10).copy(); +}); + +// Test prototype getters don't throw +assert.equal(Buffer.prototype.parent, undefined); +assert.equal(Buffer.prototype.offset, undefined); +assert.equal(SlowBuffer.prototype.parent, undefined); +assert.equal(SlowBuffer.prototype.offset, undefined); + +// Unpooled buffer (replaces SlowBuffer) +const ubuf = Buffer.allocUnsafeSlow(10); +assert(ubuf); +assert(ubuf.buffer); +assert.equal(ubuf.buffer.byteLength, 10); diff --git a/test/parallel/test-buffer-safe-unsafe.js b/test/parallel/test-buffer-safe-unsafe.js new file mode 100644 index 00000000000000..6646f760564432 --- /dev/null +++ b/test/parallel/test-buffer-safe-unsafe.js @@ -0,0 +1,14 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const safe = Buffer.alloc(10); + +function isZeroFilled(buf) { + for (let n = 0; n < buf.length; n++) + if (buf[n] > 0) return false; + return true; +} + +assert(isZeroFilled(safe)); diff --git a/test/parallel/test-buffer.js b/test/parallel/test-buffer.js index d0ebe64db9453a..8833070102dc48 100644 --- a/test/parallel/test-buffer.js +++ b/test/parallel/test-buffer.js @@ -1371,3 +1371,14 @@ assert.equal(Buffer.prototype.parent, undefined); assert.equal(Buffer.prototype.offset, undefined); assert.equal(SlowBuffer.prototype.parent, undefined); assert.equal(SlowBuffer.prototype.offset, undefined); + +{ + // Test that large negative Buffer length inputs don't affect the pool offset. + assert.deepStrictEqual(Buffer(-Buffer.poolSize), Buffer.from('')); + assert.deepStrictEqual(Buffer(-100), Buffer.from('')); + assert.deepStrictEqual(Buffer.allocUnsafe(-Buffer.poolSize), Buffer.from('')); + assert.deepStrictEqual(Buffer.allocUnsafe(-100), Buffer.from('')); + + // Check pool offset after that by trying to write string into the pool. + assert.doesNotThrow(() => Buffer.from('abc')); +} From 4107b5d20004bdf26f6ebc886ad99fa57ad3a2f5 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Wed, 6 Jul 2016 15:20:58 -0700 Subject: [PATCH 050/261] deps: backport 22c5e46 from V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the diagnostic code for the issue described in https://bugs.chromium.org/p/chromium/issues/detail?id=454297. That issue is private, probably due to the fact that it contains information about a security vulnerability. The original issue was fixed in V8 by https://codereview.chromium.org/1286343004, which was integrated into node v4.x with c43172578e3e10c2de84fc2ce0d6a7fb02a440d8, so there's no need for the corresponding diagnostic code anymore. Original commit message: [heap] Remove debugging code of crbug/454297. BUG= Review URL: https://codereview.chromium.org/1420253002 Cr-Commit-Position: refs/heads/master@{#31523} PR-URL: https://github.com/nodejs/node/pull/7584 Reviewed-By: Myles Borins Reviewed-By: Michaël Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Ali Ijaz Sheikh --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/heap/mark-compact.cc | 100 ------------------------------- 2 files changed, 1 insertion(+), 101 deletions(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 4a4a51238e6c93..f4cdb94b28850f 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 4 #define V8_MINOR_VERSION 5 #define V8_BUILD_NUMBER 103 -#define V8_PATCH_LEVEL 36 +#define V8_PATCH_LEVEL 37 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/heap/mark-compact.cc b/deps/v8/src/heap/mark-compact.cc index 45f5af3f4dcb03..cb08ab4e331f40 100644 --- a/deps/v8/src/heap/mark-compact.cc +++ b/deps/v8/src/heap/mark-compact.cc @@ -2908,16 +2908,6 @@ class PointersUpdatingVisitor : public ObjectVisitor { HeapObject* heap_obj = HeapObject::cast(obj); -// TODO(ishell): remove, once crbug/454297 is caught. -#if V8_TARGET_ARCH_64_BIT -#ifndef V8_OS_AIX // no point checking on AIX as full 64 range is supported - const uintptr_t kBoundary = V8_UINT64_C(1) << 48; - STATIC_ASSERT(kBoundary > 0); - if (reinterpret_cast(heap_obj->address()) >= kBoundary) { - CheckLayoutDescriptorAndDie(heap, slot); - } -#endif -#endif MapWord map_word = heap_obj->map_word(); if (map_word.IsForwardingAddress()) { DCHECK(heap->InFromSpace(heap_obj) || @@ -2935,100 +2925,10 @@ class PointersUpdatingVisitor : public ObjectVisitor { private: inline void UpdatePointer(Object** p) { UpdateSlot(heap_, p); } - static void CheckLayoutDescriptorAndDie(Heap* heap, Object** slot); - Heap* heap_; }; -#if V8_TARGET_ARCH_64_BIT -// TODO(ishell): remove, once crbug/454297 is caught. -void PointersUpdatingVisitor::CheckLayoutDescriptorAndDie(Heap* heap, - Object** slot) { - const int kDataBufferSize = 128; - uintptr_t data[kDataBufferSize] = {0}; - int index = 0; - data[index++] = 0x10aaaaaaaaUL; // begin marker - - data[index++] = reinterpret_cast(slot); - data[index++] = 0x15aaaaaaaaUL; - - Address slot_address = reinterpret_cast
(slot); - - uintptr_t space_owner_id = 0xb001; - if (heap->new_space()->ToSpaceContains(slot_address)) { - space_owner_id = 1; - } else if (heap->new_space()->FromSpaceContains(slot_address)) { - space_owner_id = 2; - } else if (heap->old_space()->ContainsSafe(slot_address)) { - space_owner_id = 3; - } else if (heap->code_space()->ContainsSafe(slot_address)) { - space_owner_id = 4; - } else if (heap->map_space()->ContainsSafe(slot_address)) { - space_owner_id = 5; - } else { - // Lo space or other. - space_owner_id = 6; - } - data[index++] = space_owner_id; - data[index++] = 0x20aaaaaaaaUL; - - // Find map word lying near before the slot address (usually the map word is - // at -3 words from the slot but just in case we look up further. - Object** map_slot = slot; - bool found = false; - const int kMaxDistanceToMap = 64; - for (int i = 0; i < kMaxDistanceToMap; i++, map_slot--) { - Address map_address = reinterpret_cast
(*map_slot); - if (heap->map_space()->ContainsSafe(map_address)) { - found = true; - break; - } - } - data[index++] = found; - data[index++] = 0x30aaaaaaaaUL; - data[index++] = reinterpret_cast(map_slot); - data[index++] = 0x35aaaaaaaaUL; - - if (found) { - Address obj_address = reinterpret_cast
(map_slot); - Address end_of_page = - reinterpret_cast
(Page::FromAddress(obj_address)) + - Page::kPageSize; - Address end_address = - Min(obj_address + kPointerSize * kMaxDistanceToMap, end_of_page); - int size = static_cast(end_address - obj_address); - data[index++] = size / kPointerSize; - data[index++] = 0x40aaaaaaaaUL; - memcpy(&data[index], reinterpret_cast(map_slot), size); - index += size / kPointerSize; - data[index++] = 0x50aaaaaaaaUL; - - HeapObject* object = HeapObject::FromAddress(obj_address); - data[index++] = reinterpret_cast(object); - data[index++] = 0x60aaaaaaaaUL; - - Map* map = object->map(); - data[index++] = reinterpret_cast(map); - data[index++] = 0x70aaaaaaaaUL; - - LayoutDescriptor* layout_descriptor = map->layout_descriptor(); - data[index++] = reinterpret_cast(layout_descriptor); - data[index++] = 0x80aaaaaaaaUL; - - memcpy(&data[index], reinterpret_cast(map->address()), Map::kSize); - index += Map::kSize / kPointerSize; - data[index++] = 0x90aaaaaaaaUL; - } - - data[index++] = 0xeeeeeeeeeeUL; - DCHECK(index < kDataBufferSize); - base::OS::PrintError("Data: %p\n", static_cast(data)); - base::OS::Abort(); -} -#endif - - static void UpdatePointer(HeapObject** address, HeapObject* object) { MapWord map_word = object->map_word(); // The store buffer can still contain stale pointers in dead large objects. From 9121e94e62c6f77af5c0eb1a0c7e98520d0709f3 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 18 Apr 2016 21:26:30 -0700 Subject: [PATCH 051/261] doc: note that process.config can and will be changed PR-URL: https://github.com/nodejs/node/pull/6266 Reviewed-By: Ben Noordhuis --- doc/api/process.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/process.md b/doc/api/process.md index c7f2567ccf5aff..494a57ffe6be33 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -375,6 +375,10 @@ An example of the possible output looks like: } ``` +*Note: the `process.config` property is **not** read-only and there are existing +modules in the ecosystem that are known to extend, modify, or entirely replace +the value of `process.config`.* + ## process.connected * {Boolean} Set to false after `process.disconnect()` is called From b9136c0c036a1058b6c9ed860f93aec2f871af2e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 18 Apr 2016 21:02:18 -0700 Subject: [PATCH 052/261] src: add process.binding('config') It turns out that userland likes to override process.config with their own stuff. If we want to be able to depend on it in any way, we need our own internal mechanism. This adds a new private process.binding('config') that is intended to serve as a container for internal flags and compile time configs that need to be passed on to the JS layer. PR-URL: https://github.com/nodejs/node/pull/6266 Reviewed-By: Ben Noordhuis --- node.gyp | 1 + src/node_config.cc | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/node_config.cc diff --git a/node.gyp b/node.gyp index 240922d619337f..5058682bff8f8e 100644 --- a/node.gyp +++ b/node.gyp @@ -124,6 +124,7 @@ 'src/js_stream.cc', 'src/node.cc', 'src/node_buffer.cc', + 'src/node_config.cc', 'src/node_constants.cc', 'src/node_contextify.cc', 'src/node_file.cc', diff --git a/src/node_config.cc b/src/node_config.cc new file mode 100644 index 00000000000000..e50002bc64c202 --- /dev/null +++ b/src/node_config.cc @@ -0,0 +1,36 @@ +#include "node.h" +#include "env.h" +#include "env-inl.h" +#include "util.h" +#include "util-inl.h" + + +namespace node { + +using v8::Context; +using v8::Local; +using v8::Object; +using v8::Value; +using v8::ReadOnly; + +// The config binding is used to provide an internal view of compile or runtime +// config options that are required internally by lib/*.js code. This is an +// alternative to dropping additional properties onto the process object as +// has been the practice previously in node.cc. + +#define READONLY_BOOLEAN_PROPERTY(str) \ + do { \ + target->DefineOwnProperty(env->context(), \ + OneByteString(env->isolate(), str), \ + True(env->isolate()), ReadOnly).FromJust(); \ + } while (0) + +void InitConfig(Local target, + Local unused, + Local context) { + // Environment* env = Environment::GetCurrent(context); +} + +} // namespace node + +NODE_MODULE_CONTEXT_AWARE_BUILTIN(config, node::InitConfig) From 06327e5eed03e2f69c9d5d80cc16e5e2334d5c9e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 5 Jul 2016 16:24:35 -0700 Subject: [PATCH 053/261] tls: use process.binding('config') to detect fips mode When the fips mode check was added sometime in v4 it caused a regression in some edge cases (see https://github.com/nodejs/node/issues/6114) because `process.config` can be overwritten by userland modules. This switches to using the backported process.binding('config') to fix the regression. Fixes: https://github.com/nodejs/node/issues/6114 PR-URL: https://github.com/nodejs/node/pull/7551 Reviewed-By: Myles Borins --- lib/_tls_wrap.js | 2 +- src/node_config.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index c115555ce7a7ff..5c5370e09c19e0 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -19,7 +19,7 @@ const defaultSessionIdContext = getDefaultSessionIdContext(); function getDefaultSessionIdContext() { var defaultText = process.argv.join(' '); /* SSL_MAX_SID_CTX_LENGTH is 128 bits */ - if (process.config.variables.openssl_fips) { + if (process.binding('config').fipsMode) { return crypto.createHash('sha1') .update(defaultText) .digest('hex').slice(0, 32); diff --git a/src/node_config.cc b/src/node_config.cc index e50002bc64c202..6fe22a4f985dab 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -28,7 +28,10 @@ using v8::ReadOnly; void InitConfig(Local target, Local unused, Local context) { - // Environment* env = Environment::GetCurrent(context); +#ifdef NODE_FIPS_MODE + Environment* env = Environment::GetCurrent(context); + READONLY_BOOLEAN_PROPERTY("fipsMode"); +#endif } } // namespace node From 94eb980ca5e2646fbc07b70b802be5c9ef1bafe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 1 Apr 2016 11:19:19 +0200 Subject: [PATCH 054/261] deps: upgrade libuv to 1.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/5737 Fixes: https://github.com/nodejs/node/issues/4643 Fixes: https://github.com/nodejs/node/issues/4291 Fixes: https://github.com/nodejs/node-v0.x-archive/issues/8960 Refs: https://github.com/nodejs/node/pull/3594 PR-URL: https://github.com/nodejs/node/pull/5994 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Johan Bergström --- deps/uv/.gitignore | 3 + deps/uv/.mailmap | 6 + deps/uv/AUTHORS | 13 + deps/uv/CONTRIBUTING.md | 9 +- deps/uv/ChangeLog | 139 ++++++++++ deps/uv/MAINTAINERS.md | 1 + deps/uv/Makefile.am | 13 +- deps/uv/Makefile.mingw | 1 - deps/uv/README.md | 8 +- deps/uv/appveyor.yml | 2 +- deps/uv/autogen.sh | 2 +- deps/uv/checksparse.sh | 2 + deps/uv/configure.ac | 2 +- deps/uv/docs/src/loop.rst | 7 +- deps/uv/docs/src/misc.rst | 54 +++- deps/uv/docs/src/poll.rst | 17 +- deps/uv/docs/src/stream.rst | 8 +- deps/uv/docs/src/tty.rst | 16 +- deps/uv/gyp_uv.py | 5 +- deps/uv/include/uv-version.h | 2 +- deps/uv/include/uv-win.h | 5 - deps/uv/include/uv.h | 15 +- deps/uv/src/fs-poll.c | 5 +- deps/uv/src/unix/aix.c | 63 ++--- deps/uv/src/unix/core.c | 194 +++++++++++-- deps/uv/src/unix/fs.c | 17 +- deps/uv/src/unix/internal.h | 31 ++- deps/uv/src/unix/kqueue.c | 21 ++ deps/uv/src/unix/linux-core.c | 77 ++++-- deps/uv/src/unix/linux-syscalls.h | 1 + deps/uv/src/unix/pipe.c | 11 +- deps/uv/src/unix/poll.c | 16 +- deps/uv/src/unix/process.c | 6 +- deps/uv/src/unix/stream.c | 22 +- deps/uv/src/unix/sunos.c | 11 + deps/uv/src/unix/thread.c | 33 ++- deps/uv/src/unix/tty.c | 36 ++- deps/uv/src/uv-common.c | 5 +- deps/uv/src/win/core.c | 130 +++++---- deps/uv/src/win/dl.c | 7 +- deps/uv/src/win/fs-event.c | 108 ++++---- deps/uv/src/win/fs.c | 25 +- deps/uv/src/win/getaddrinfo.c | 61 +++-- deps/uv/src/win/internal.h | 3 +- deps/uv/src/win/pipe.c | 23 +- deps/uv/src/win/poll.c | 15 +- deps/uv/src/win/timer.c | 9 +- deps/uv/src/win/tty.c | 9 +- deps/uv/src/win/util.c | 254 ++++++++++++++---- deps/uv/test/runner-unix.c | 2 +- deps/uv/test/task.h | 10 +- deps/uv/test/test-condvar.c | 100 ++++--- deps/uv/test/test-eintr-handling.c | 94 +++++++ deps/uv/test/test-fs-event.c | 28 ++ deps/uv/test/test-fs-poll.c | 1 + deps/uv/test/test-get-passwd.c | 80 ++++++ deps/uv/test/test-homedir.c | 21 ++ deps/uv/test/test-list.h | 29 ++ .../test/test-pipe-close-stdout-read-stdin.c | 3 + deps/uv/test/test-pipe-getsockname.c | 1 + deps/uv/test/test-platform-output.c | 11 + deps/uv/test/test-poll.c | 52 +++- .../uv/test/test-tcp-close-while-connecting.c | 2 +- deps/uv/test/test-thread.c | 21 ++ deps/uv/test/test-timer.c | 27 ++ deps/uv/test/test-tmpdir.c | 71 +++++ deps/uv/test/test-tty.c | 39 +++ deps/uv/uv.gyp | 21 +- deps/uv/vcbuild.bat | 5 + 69 files changed, 1746 insertions(+), 395 deletions(-) create mode 100644 deps/uv/test/test-eintr-handling.c create mode 100644 deps/uv/test/test-get-passwd.c create mode 100644 deps/uv/test/test-tmpdir.c diff --git a/deps/uv/.gitignore b/deps/uv/.gitignore index 1eaaca8406e957..86a8a5b7b8584d 100644 --- a/deps/uv/.gitignore +++ b/deps/uv/.gitignore @@ -65,6 +65,9 @@ ipch # sphinx generated files /docs/build/ +# Clion / IntelliJ project files +/.idea/ + *.xcodeproj *.xcworkspace diff --git a/deps/uv/.mailmap b/deps/uv/.mailmap index 0a152ba8dbb0c4..7a51588c0b7188 100644 --- a/deps/uv/.mailmap +++ b/deps/uv/.mailmap @@ -8,9 +8,11 @@ Brian White Brian White Caleb James DeLisle Christoph Iserlohn +Devchandra Meetei Leishangthem Fedor Indutny Frank Denis Isaac Z. Schlueter +Jason Williams Justin Venus Keno Fischer Keno Fischer @@ -18,6 +20,9 @@ Leith Bade Leonard Hecker Maciej Małecki Marc Schlaich +Michael +Michael Neumann +Nicholas Vavilov Rasmus Christian Pedersen Rasmus Christian Pedersen Robert Mustacchi @@ -25,6 +30,7 @@ Ryan Dahl Ryan Emery Sam Roberts San-Tai Hsu +Santiago Gimeno Saúl Ibarra Corretgé Shigeki Ohtsu Timothy J. Fontaine diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 8dc3955cad5bf3..9a9e9c2a2204b8 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -240,3 +240,16 @@ Yuval Brik Joran Dirk Greef Andrey Mazo sztomi +Martin Bark +Dave +Alexis Murzeau +Didiet +Nan Xiang <514580344@qq.com> +Samuel Lorétan +Nándor István Krácser +Katsutoshi Horie +Lukasz Jagiello +Robert Chiras +Kári Tristan Helgason +Krishnaraj Bhat +Enno Boland diff --git a/deps/uv/CONTRIBUTING.md b/deps/uv/CONTRIBUTING.md index b46edd492aab47..ef5c2b2feaae9f 100644 --- a/deps/uv/CONTRIBUTING.md +++ b/deps/uv/CONTRIBUTING.md @@ -23,8 +23,7 @@ The stable branch is effectively frozen; patches that change the libuv API/ABI or affect the run-time behavior of applications get rejected. In case of doubt, open an issue in the [issue tracker][], post your question -to the [libuv mailing list], or contact one of project maintainers -(@bnoordhuis, @piscisaureus, @indutny or @saghul) on [IRC][]. +to the [libuv mailing list], or contact one of [project maintainers][] on [IRC][]. Especially do so if you plan to work on something big. Nothing is more frustrating than seeing your hard work go to waste because your vision @@ -138,7 +137,10 @@ $ git rebase upstream/v1.x # or upstream/master ### TEST Bug fixes and features should come with tests. Add your tests in the -`test/` directory. Tests also need to be registered in `test/test-list.h`. +`test/` directory. Each new test needs to be registered in `test/test-list.h`. If you add a new test file, it needs to be registered in two places: +- `Makefile.am`: add the file's name to the `test_run_tests_SOURCES` list. +- `uv.gyp`: add the file's name to the `sources` list in the `run-tests` target. + Look at other tests to see how they should be structured (license boilerplate, the way entry points are declared, etc.). @@ -164,3 +166,4 @@ not send out notifications when you add commits. [libuv mailing list]: http://groups.google.com/group/libuv [IRC]: http://webchat.freelibuv.net/?channels=libuv [Google C/C++ style guide]: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml +[project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index af0743af72c8db..85d40113e4f052 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,142 @@ +2016.04.08, Version 1.9.0 (Stable), 229b3a4cc150aebd6561e6bd43076eafa7a03756 + +Changes since version 1.8.0: + +* win: wait for full timeout duration (João Reis) + +* unix: fix support for uClibc-ng (Martin Bark) + +* doc: indicate where new test files need to be added (Dave) + +* test,unix: fix logic error in test runner (Ben Noordhuis) + +* fs: don't nullify req->bufs on EINTR (Dave) + +* osx: set the default thread stack size to RLIMIT_STACK (Saúl Ibarra Corretgé) + +* build: invoke libtoolize with --copy (Ben Noordhuis) + +* test: fixup eintr_handling (Saúl Ibarra Corretgé) + +* osx: avoid compilation warning with Clang (Saúl Ibarra Corretgé) + +* test,win: fix compilation with shared lib (Alexis Murzeau) + +* test: fix race condition in pipe-close-stdout (Imran Iqbal) + +* unix,win: add uv_os_tmpdir() (cjihrig) + +* ios: fix undefined PTHREAD_STACK_MIN (Didiet) + +* test: fix threadpool_multiple_event_loops for AIX (Imran Iqbal) + +* unix: report errors for unpollable fds (Ben Noordhuis) + +* win: fix watching root files (Nicholas Vavilov) + +* build,win: print the Visual Studio version in use (Saúl Ibarra Corretgé) + +* build,win: remove unneeded condition from GYP file (Saúl Ibarra Corretgé) + +* test,win: fix compilation warning (Saúl Ibarra Corretgé) + +* test: use uv_loop_close and assert its result (Nan Xiang) + +* build: map 'AMD64' host arch to 'x64' (Ben Noordhuis) + +* osx: protected use of potentially undefined macro (Samuel Lorétan) + +* linux: fix compilation with musl (Saúl Ibarra Corretgé) + +* doc: describe how to make release builds on Unix (Saúl Ibarra Corretgé) + +* doc: add missing link in README (Saúl Ibarra Corretgé) + +* build: python 2.x/3.x consistent print usage (Rasmus Christian Pedersen) + +* test: assume no IPv6 if interfaces cannot be listed (Nan Xiang) + +* darwin: replace F_FULLFSYNC with fdatasync syscall (Saúl Ibarra Corretgé) + +* doc: add missing write callback to example (Nándor István Krácser) + +* build: compile with -D_THREAD_SAFE on AIX (Imran Iqbal) + +* test: fix threadpool_multiple_event_loops on PPC (Imran Iqbal) + +* test: reduce timeout in tcp_close_while_connecting (Imran Iqbal) + +* unix, win: consistently null-terminate buffers (Saúl Ibarra Corretgé) + +* unix, win: count null byte on UV_ENOBUFS (Saúl Ibarra Corretgé) + +* test: fix deadlocks in uv_cond_wait (Katsutoshi Horie) + +* linux: fix cpu count (Lukasz Jagiello) + +* unix: fix uv__handle_type for AIX (Imran Iqbal) + +* linux: call fclose(), fix fdopen() memory leak (Ben Noordhuis) + +* win: remove unneeded condition (Saúl Ibarra Corretgé) + +* unix: fix compile error in Android using bionic (Robert Chiras) + +* linux: add braces to multi-statement if (Kári Tristan Helgason) + +* doc: add @cjihrig as a maintainer (Saúl Ibarra Corretgé) + +* unix: add fork-safe open file function (Kári Tristan Helgason) + +* linux: replace calls to fopen with uv__open_file (Kári Tristan Helgason) + +* linux: remove redundant call to rewind() (Krishnaraj Bhat) + +* win: remove duplicated code when processing fsevents (Saúl Ibarra Corretgé) + +* test: fix poll_bad_fdtype for AIX (Imran Iqbal) + +* linux: fix error checking in uv__open_file (Saúl Ibarra Corretgé) + +* poll: add UV_DISCONNECT event (Santiago Gimeno) + +* fs: realpath: fix string size before converting (Yuval Brik) + +* win: use native APIs for UTF conversions (cjihrig) + +* doc: clarify uv_loop_close() (Ben Noordhuis) + +* unix: retry ioctl(TIOCGWINSZ) on EINTR (Ben Noordhuis) + +* win,build: remove unused build defines (Saúl Ibarra Corretgé) + +* win: fix buffer overflow in fs events (Joran Dirk Greef) + +* win: fix uv_relative_path and remove dead branch (Joran Dirk Greef) + +* unix: use open(2) with O_CLOEXEC on OS X (Kári Tristan Helgason) + +* test: add missing copyright header (cjihrig) + +* aix: fix 'POLLRDHUP undeclared' build error (Ben Noordhuis) + +* unix,win: add uv_get_passwd() (cjihrig) + +* process: fix uv_spawn edge-case (Santiago Gimeno) + +* test: use %ld for printing uid/gid (Ben Noordhuis) + +* aix: fix ahafs implementation (Imran Iqbal) + +* aix: do not store absolute path to ahafs (Imran Iqbal) + +* process: close process pipes safely (Santiago Gimeno) + +* unix: open ttyname instead of /dev/tty (Enno Boland) + +* unix: remove outdated comment (Kári Tristan Helgason) + + 2015.12.15, Version 1.8.0 (Stable), 5467299450ecf61635657557b6e01aaaf6c3fdf4 Changes since version 1.7.5: diff --git a/deps/uv/MAINTAINERS.md b/deps/uv/MAINTAINERS.md index 4db2f5130c060d..2f0e618ca24149 100644 --- a/deps/uv/MAINTAINERS.md +++ b/deps/uv/MAINTAINERS.md @@ -6,6 +6,7 @@ libuv is currently managed by the following individuals: * **Ben Noordhuis** ([@bnoordhuis](https://github.com/bnoordhuis)) - GPG key: D77B 1E34 243F BAF0 5F8E 9CC3 4F55 C8C8 46AB 89B9 (pubkey-bnoordhuis) * **Bert Belder** ([@piscisaureus](https://github.com/piscisaureus)) +* **Colin Ihrig** ([@cjihrig](https://github.com/cjihrig)) * **Fedor Indutny** ([@indutny](https://github.com/indutny)) - GPG key: AF2E EA41 EC34 47BF DD86 FED9 D706 3CCE 19B7 E890 (pubkey-indutny) * **Saúl Ibarra Corretgé** ([@saghul](https://github.com/saghul)) diff --git a/deps/uv/Makefile.am b/deps/uv/Makefile.am index 0ef781ff198804..dfd4353a31b649 100644 --- a/deps/uv/Makefile.am +++ b/deps/uv/Makefile.am @@ -43,7 +43,6 @@ if WINNT include_HEADERS += include/uv-win.h include/tree.h AM_CPPFLAGS += -I$(top_srcdir)/src/win \ - -DWIN32_LEAN_AND_MEAN \ -D_WIN32_WINNT=0x0600 LIBS += -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv libuv_la_SOURCES += src/win/async.c \ @@ -130,6 +129,7 @@ EXTRA_DIST = test/fixtures/empty_file \ TESTS = test/run-tests check_PROGRAMS = test/run-tests test_run_tests_CFLAGS = +test_run_tests_LDFLAGS = test_run_tests_SOURCES = test/blackhole-server.c \ test/dns-server.c \ test/echo-server.c \ @@ -151,6 +151,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \ test/test-default-loop-close.c \ test/test-delayed-accept.c \ test/test-dlerror.c \ + test/test-eintr-handling.c \ test/test-embed.c \ test/test-emfile.c \ test/test-error.c \ @@ -161,6 +162,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \ test/test-get-currentexe.c \ test/test-get-loadavg.c \ test/test-get-memory.c \ + test/test-get-passwd.c \ test/test-getaddrinfo.c \ test/test-getnameinfo.c \ test/test-getsockname.c \ @@ -242,6 +244,7 @@ test_run_tests_SOURCES = test/blackhole-server.c \ test/test-timer-again.c \ test/test-timer-from-check.c \ test/test-timer.c \ + test/test-tmpdir.c \ test/test-tty.c \ test/test-udp-bind.c \ test/test-udp-create-socket-early.c \ @@ -280,7 +283,7 @@ endif if AIX -libuv_la_CFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT +libuv_la_CFLAGS += -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT -D_THREAD_SAFE include_HEADERS += include/uv-aix.h libuv_la_SOURCES += src/unix/aix.c endif @@ -301,15 +304,18 @@ libuv_la_SOURCES += src/unix/darwin.c \ src/unix/fsevents.c \ src/unix/kqueue.c \ src/unix/proctitle.c +test_run_tests_LDFLAGS += -lutil endif if DRAGONFLY include_HEADERS += include/uv-bsd.h +test_run_tests_LDFLAGS += -lutil endif if FREEBSD include_HEADERS += include/uv-bsd.h libuv_la_SOURCES += src/unix/freebsd.c src/unix/kqueue.c +test_run_tests_LDFLAGS += -lutil endif if LINUX @@ -320,16 +326,19 @@ libuv_la_SOURCES += src/unix/linux-core.c \ src/unix/linux-syscalls.c \ src/unix/linux-syscalls.h \ src/unix/proctitle.c +test_run_tests_LDFLAGS += -lutil endif if NETBSD include_HEADERS += include/uv-bsd.h libuv_la_SOURCES += src/unix/kqueue.c src/unix/netbsd.c +test_run_tests_LDFLAGS += -lutil endif if OPENBSD include_HEADERS += include/uv-bsd.h libuv_la_SOURCES += src/unix/kqueue.c src/unix/openbsd.c +test_run_tests_LDFLAGS += -lutil endif if SUNOS diff --git a/deps/uv/Makefile.mingw b/deps/uv/Makefile.mingw index 156f15dab159f1..3130bac473d30c 100644 --- a/deps/uv/Makefile.mingw +++ b/deps/uv/Makefile.mingw @@ -20,7 +20,6 @@ CFLAGS += -Wall \ -Iinclude \ -Isrc \ -Isrc/win \ - -DWIN32_LEAN_AND_MEAN \ -D_WIN32_WINNT=0x0600 INCLUDES = include/stdint-msvc2008.h \ diff --git a/deps/uv/README.md b/deps/uv/README.md index dfd24ba79d1850..17304a7ab57125 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -156,11 +156,16 @@ project tree manually: ### Unix -Run: +For Debug builds (recommended) run: $ ./gyp_uv.py -f make $ make -C out +For Release builds run: + + $ ./gyp_uv.py -f make + $ BUILDTYPE=Release make -C out + Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries. ### OS X @@ -243,3 +248,4 @@ See the [guidelines for contributing][]. [Visual Studio Express 2010]: http://www.microsoft.com/visualstudio/eng/products/visual-studio-2010-express [guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md [libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png +[x32]: https://en.wikipedia.org/wiki/X32_ABI diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml index 9aa63c5a5d2e73..835730b924c8ff 100644 --- a/deps/uv/appveyor.yml +++ b/deps/uv/appveyor.yml @@ -1,4 +1,4 @@ -version: v1.8.0.build{build} +version: v1.9.0.build{build} install: - cinst -y nsis diff --git a/deps/uv/autogen.sh b/deps/uv/autogen.sh index 0574778a4e1040..271c2ee8c33c44 100755 --- a/deps/uv/autogen.sh +++ b/deps/uv/autogen.sh @@ -40,7 +40,7 @@ echo "m4_define([UV_EXTRA_AUTOMAKE_FLAGS], [$UV_EXTRA_AUTOMAKE_FLAGS])" \ > m4/libuv-extra-automake-flags.m4 set -ex -"$LIBTOOLIZE" +"$LIBTOOLIZE" --copy "$ACLOCAL" -I m4 "$AUTOCONF" "$AUTOMAKE" --add-missing --copy diff --git a/deps/uv/checksparse.sh b/deps/uv/checksparse.sh index 619cf6f8b672d8..68e3bde39305da 100755 --- a/deps/uv/checksparse.sh +++ b/deps/uv/checksparse.sh @@ -101,6 +101,7 @@ test/test-fs.c test/test-get-currentexe.c test/test-get-loadavg.c test/test-get-memory.c +test/test-get-passwd.c test/test-getaddrinfo.c test/test-getsockname.c test/test-homedir.c @@ -155,6 +156,7 @@ test/test-threadpool-cancel.c test/test-threadpool.c test/test-timer-again.c test/test-timer.c +test/test-tmpdir.c test/test-tty.c test/test-udp-dgram-too-big.c test/test-udp-ipv6.c diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 011bee2a891e73..2d5a3b9de5eb6d 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.8.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.9.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/loop.rst b/deps/uv/docs/src/loop.rst index 2a01d796375e8e..1f504cb391f169 100644 --- a/deps/uv/docs/src/loop.rst +++ b/deps/uv/docs/src/loop.rst @@ -71,9 +71,10 @@ API .. c:function:: int uv_loop_close(uv_loop_t* loop) - Closes all internal loop resources. This function must only be called once - the loop has finished its execution or it will return UV_EBUSY. After this - function returns the user shall free the memory allocated for the loop. + Releases all internal loop resources. Call this function only when the loop + has finished executing and all open handles and requests have been closed, + or it will return UV_EBUSY. After this function returns, the user can free + the memory allocated for the loop. .. c:function:: uv_loop_t* uv_default_loop(void) diff --git a/deps/uv/docs/src/misc.rst b/deps/uv/docs/src/misc.rst index 2ce0887db0c278..f32af48ff9e92d 100644 --- a/deps/uv/docs/src/misc.rst +++ b/deps/uv/docs/src/misc.rst @@ -122,6 +122,20 @@ Data types } netmask; } uv_interface_address_t; +.. c:type:: uv_passwd_t + + Data type for password file information. + + :: + + typedef struct uv_passwd_s { + char* username; + long uid; + long gid; + char* shell; + char* homedir; + } uv_passwd_t; + API --- @@ -265,14 +279,50 @@ API `uv_os_homedir()` first checks the `HOME` environment variable using :man:`getenv(3)`. If `HOME` is not set, :man:`getpwuid_r(3)` is called. The user's home directory is stored in `buffer`. When `uv_os_homedir()` is - called, `size` indicates the maximum size of `buffer`. On success or - `UV_ENOBUFS` failure, `size` is set to the string length of `buffer`. + called, `size` indicates the maximum size of `buffer`. On success `size` is set + to the string length of `buffer`. On `UV_ENOBUFS` failure `size` is set to the + required length for `buffer`, including the null byte. .. warning:: `uv_os_homedir()` is not thread safe. .. versionadded:: 1.6.0 +.. c:function:: int uv_os_tmpdir(char* buffer, size_t* size) + + Gets the temp directory. On Windows, `uv_os_tmpdir()` uses `GetTempPathW()`. + On all other operating systems, `uv_os_tmpdir()` uses the first environment + variable found in the ordered list `TMPDIR`, `TMP`, `TEMP`, and `TEMPDIR`. + If none of these are found, the path `"/tmp"` is used, or, on Android, + `"/data/local/tmp"` is used. The temp directory is stored in `buffer`. When + `uv_os_tmpdir()` is called, `size` indicates the maximum size of `buffer`. + On success `size` is set to the string length of `buffer` (which does not + include the terminating null). On `UV_ENOBUFS` failure `size` is set to the + required length for `buffer`, including the null byte. + + .. warning:: + `uv_os_tmpdir()` is not thread safe. + + .. versionadded:: 1.9.0 + +.. c:function:: int uv_os_get_passwd(uv_passwd_t* pwd) + + Gets a subset of the password file entry for the current effective uid (not + the real uid). The populated data includes the username, euid, gid, shell, + and home directory. On non-Windows systems, all data comes from + :man:`getpwuid_r(3)`. On Windows, uid and gid are set to -1 and have no + meaning, and shell is `NULL`. After successfully calling this function, the + memory allocated to `pwd` needs to be freed with + :c:func:`uv_os_free_passwd`. + + .. versionadded:: 1.9.0 + +.. c:function:: void uv_os_free_passwd(uv_passwd_t* pwd) + + Frees the `pwd` memory previously allocated with :c:func:`uv_os_get_passwd`. + + .. versionadded:: 1.9.0 + .. uint64_t uv_get_free_memory(void) .. c:function:: uint64_t uv_get_total_memory(void) diff --git a/deps/uv/docs/src/poll.rst b/deps/uv/docs/src/poll.rst index 6dc41839ac1e92..69d45be6d32b29 100644 --- a/deps/uv/docs/src/poll.rst +++ b/deps/uv/docs/src/poll.rst @@ -4,8 +4,8 @@ :c:type:`uv_poll_t` --- Poll handle =================================== -Poll handles are used to watch file descriptors for readability and -writability, similar to the purpose of :man:`poll(2)`. +Poll handles are used to watch file descriptors for readability, +writability and disconnection similar to the purpose of :man:`poll(2)`. The purpose of poll handles is to enable integrating external libraries that rely on the event loop to signal it about the socket status changes, like @@ -51,7 +51,8 @@ Data types enum uv_poll_event { UV_READABLE = 1, - UV_WRITABLE = 2 + UV_WRITABLE = 2, + UV_DISCONNECT = 4 }; @@ -82,10 +83,14 @@ API .. c:function:: int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) Starts polling the file descriptor. `events` is a bitmask consisting made up - of UV_READABLE and UV_WRITABLE. As soon as an event is detected the callback - will be called with `status` set to 0, and the detected events set on the + of UV_READABLE, UV_WRITABLE and UV_DISCONNECT. As soon as an event is detected + the callback will be called with `status` set to 0, and the detected events set on the `events` field. + The UV_DISCONNECT event is optional in the sense that it may not be + reported and the user is free to ignore it, but it can help optimize the shutdown + path because an extra read or write call might be avoided. + If an error happens while polling, `status` will be < 0 and corresponds with one of the UV_E* error codes (see :ref:`errors`). The user should not close the socket while the handle is active. If the user does that @@ -96,6 +101,8 @@ API Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so will update the events mask that is being watched for. + .. versionchanged:: 1.9.0 Added the UV_DISCONNECT event. + .. c:function:: int uv_poll_stop(uv_poll_t* poll) Stop polling the file descriptor, the callback will no longer be called. diff --git a/deps/uv/docs/src/stream.rst b/deps/uv/docs/src/stream.rst index 9f0aacd16435d0..ed0c79d0045616 100644 --- a/deps/uv/docs/src/stream.rst +++ b/deps/uv/docs/src/stream.rst @@ -148,6 +148,10 @@ API :: + void cb(uv_write_t* req, int status) { + /* Logic which handles the write result */ + } + uv_buf_t a[] = { { .base = "1", .len = 1 }, { .base = "2", .len = 1 } @@ -162,8 +166,8 @@ API uv_write_t req2; /* writes "1234" */ - uv_write(&req1, stream, a, 2); - uv_write(&req2, stream, b, 2); + uv_write(&req1, stream, a, 2, cb); + uv_write(&req2, stream, b, 2, cb); .. c:function:: int uv_write2(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, uv_write_cb cb) diff --git a/deps/uv/docs/src/tty.rst b/deps/uv/docs/src/tty.rst index 655dca9ca20641..01a0585287affc 100644 --- a/deps/uv/docs/src/tty.rst +++ b/deps/uv/docs/src/tty.rst @@ -58,14 +58,22 @@ API `readable`, specifies if you plan on calling :c:func:`uv_read_start` with this stream. stdin is readable, stdout is not. - On Unix this function will try to open ``/dev/tty`` and use it if the passed - file descriptor refers to a TTY. This lets libuv put the tty in non-blocking - mode without affecting other processes that share the tty. + On Unix this function will determine the path of the fd of the terminal + using :man:`ttyname_r(3)`, open it, and use it if the passed file descriptor + refers to a TTY. This lets libuv put the tty in non-blocking mode without + affecting other processes that share the tty. + + This function is not thread safe on systems that don't support + ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris. .. note:: - If opening ``/dev/tty`` fails, libuv falls back to blocking writes for + If reopening the TTY fails, libuv falls back to blocking writes for non-readable TTY streams. + .. versionchanged:: 1.9.0: the path of the TTY is determined by + :man:`ttyname_r(3)`. In earlier versions libuv opened + `/dev/tty` instead. + .. versionchanged:: 1.5.0: trying to initialize a TTY stream with a file descriptor that refers to a file returns `UV_EINVAL` on UNIX. diff --git a/deps/uv/gyp_uv.py b/deps/uv/gyp_uv.py index 39933f624d5c40..bd37d95c4713f6 100755 --- a/deps/uv/gyp_uv.py +++ b/deps/uv/gyp_uv.py @@ -27,6 +27,7 @@ def host_arch(): machine = platform.machine() if machine == 'i386': return 'ia32' + if machine == 'AMD64': return 'x64' if machine == 'x86_64': return 'x64' if machine.startswith('arm'): return 'arm' if machine.startswith('mips'): return 'mips' @@ -36,7 +37,7 @@ def host_arch(): def run_gyp(args): rc = gyp.main(args) if rc != 0: - print 'Error running GYP' + print('Error running GYP') sys.exit(rc) @@ -89,5 +90,5 @@ def run_gyp(args): args.append('--no-parallel') gyp_args = list(args) - print gyp_args + print(gyp_args) run_gyp(gyp_args) diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index 6e61f55ed20d85..cb666182892dea 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -31,7 +31,7 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 8 +#define UV_VERSION_MINOR 9 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/include/uv-win.h b/deps/uv/include/uv-win.h index 300be476203ed4..6b537fed0d9019 100644 --- a/deps/uv/include/uv-win.h +++ b/deps/uv/include/uv-win.h @@ -634,11 +634,6 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); struct uv_req_s signal_req; \ unsigned long pending_signum; -int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size, - char* utf8Buffer, size_t utf8Size); -int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer, - size_t utf16Size); - #ifndef F_OK #define F_OK 0 #endif diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index dd3111a960e69b..baa0b28124ba59 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -230,6 +230,7 @@ typedef struct uv_work_s uv_work_t; typedef struct uv_cpu_info_s uv_cpu_info_t; typedef struct uv_interface_address_s uv_interface_address_t; typedef struct uv_dirent_s uv_dirent_t; +typedef struct uv_passwd_s uv_passwd_t; typedef enum { UV_LOOP_BLOCK_SIGNAL @@ -714,7 +715,8 @@ struct uv_poll_s { enum uv_poll_event { UV_READABLE = 1, - UV_WRITABLE = 2 + UV_WRITABLE = 2, + UV_DISCONNECT = 4 }; UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); @@ -1000,6 +1002,14 @@ struct uv_interface_address_s { } netmask; }; +struct uv_passwd_s { + char* username; + long uid; + long gid; + char* shell; + char* homedir; +}; + typedef enum { UV_DIRENT_UNKNOWN, UV_DIRENT_FILE, @@ -1049,6 +1059,9 @@ typedef struct { UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); +UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); +UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); +UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); diff --git a/deps/uv/src/fs-poll.c b/deps/uv/src/fs-poll.c index 44d47b88ed22e7..ee73d5a2e6e949 100644 --- a/deps/uv/src/fs-poll.c +++ b/deps/uv/src/fs-poll.c @@ -138,13 +138,14 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) { assert(ctx != NULL); required_len = strlen(ctx->path); - if (required_len > *size) { - *size = required_len; + if (required_len >= *size) { + *size = required_len + 1; return UV_ENOBUFS; } memcpy(buffer, ctx->path, required_len); *size = required_len; + buffer[required_len] = '\0'; return 0; } diff --git a/deps/uv/src/unix/aix.c b/deps/uv/src/unix/aix.c index c90b7e5cb9ba0c..bcaa5ee50bc203 100644 --- a/deps/uv/src/unix/aix.c +++ b/deps/uv/src/unix/aix.c @@ -91,6 +91,24 @@ void uv__platform_loop_delete(uv_loop_t* loop) { } +int uv__io_check_fd(uv_loop_t* loop, int fd) { + struct poll_ctl pc; + + pc.events = POLLIN; + pc.cmd = PS_MOD; /* Equivalent to PS_ADD if the fd is not in the pollset. */ + pc.fd = fd; + + if (pollset_ctl(loop->backend_fd, &pc, 1)) + return -errno; + + pc.cmd = PS_DELETE; + if (pollset_ctl(loop->backend_fd, &pc, 1)) + abort(); + + return 0; +} + + void uv__io_poll(uv_loop_t* loop, int timeout) { struct pollfd events[1024]; struct pollfd pqry; @@ -506,7 +524,7 @@ static int uv__makedir_p(const char *dir) { if (*p == '/') { *p = 0; err = mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - if(err != 0) + if (err != 0 && errno != EEXIST) return err; *p = '/'; } @@ -707,59 +725,44 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int int bytes, rc = 0; uv_fs_event_t* handle; int events = 0; - int i = 0; char fname[PATH_MAX]; char *p; handle = container_of(event_watch, uv_fs_event_t, event_watcher); - /* Clean all the buffers*/ - for(i = 0; i < PATH_MAX; i++) { - fname[i] = 0; - } - i = 0; - /* At this point, we assume that polling has been done on the * file descriptor, so we can just read the AHAFS event occurrence * data and parse its results without having to block anything */ bytes = pread(event_watch->fd, result_data, RDWR_BUF_SIZE, 0); - assert((bytes <= 0) && "uv__ahafs_event - Error reading monitor file"); + assert((bytes >= 0) && "uv__ahafs_event - Error reading monitor file"); /* Parse the data */ if(bytes > 0) rc = uv__parse_data(result_data, &events, handle); + /* Unrecoverable error */ + if (rc == -1) + return; + /* For directory changes, the name of the files that triggered the change * are never absolute pathnames */ if (uv__path_is_a_directory(handle->path) == 0) { p = handle->dir_filename; - while(*p != NULL){ - fname[i]= *p; - i++; - p++; - } } else { - /* For file changes, figure out whether filename is absolute or not */ - if (handle->path[0] == '/') { - p = strrchr(handle->path, '/'); + p = strrchr(handle->path, '/'); + if (p == NULL) + p = handle->path; + else p++; - - while(*p != NULL) { - fname[i]= *p; - i++; - p++; - } - } } + strncpy(fname, p, sizeof(fname) - 1); + /* Just in case */ + fname[sizeof(fname) - 1] = '\0'; - /* Unrecoverable error */ - if (rc == -1) - return; - else /* Call the actual JavaScript callback function */ - handle->cb(handle, (const char*)&fname, events, 0); + handle->cb(handle, fname, events, 0); } #endif @@ -839,7 +842,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, /* Setup/Initialize all the libuv routines */ uv__handle_start(handle); uv__io_init(&handle->event_watcher, uv__ahafs_event, fd); - handle->path = uv__strdup((const char*)&absolute_path); + handle->path = uv__strdup(filename); handle->cb = cb; uv__io_start(handle->loop, &handle->event_watcher, UV__POLLIN); diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index cedd86ed34a128..9aaca84187001e 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -53,6 +53,9 @@ # include /* _NSGetExecutablePath */ # include # include +# if defined(O_CLOEXEC) +# define UV__O_CLOEXEC O_CLOEXEC +# endif #endif #if defined(__FreeBSD__) || defined(__DragonFly__) @@ -427,6 +430,22 @@ int uv__socket(int domain, int type, int protocol) { return sockfd; } +/* get a file pointer to a file in read-only and close-on-exec mode */ +FILE* uv__open_file(const char* path) { + int fd; + FILE* fp; + + fd = uv__open_cloexec(path, O_RDONLY); + if (fd < 0) + return NULL; + + fp = fdopen(fd, "r"); + if (fp == NULL) + uv__close(fd); + + return fp; +} + int uv__accept(int sockfd) { int peerfd; @@ -435,7 +454,7 @@ int uv__accept(int sockfd) { assert(sockfd >= 0); while (1) { -#if defined(__linux__) || __FreeBSD__ >= 10 +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) static int no_accept4; if (no_accept4) @@ -479,12 +498,11 @@ int uv__accept(int sockfd) { } -int uv__close(int fd) { +int uv__close_nocheckstdio(int fd) { int saved_errno; int rc; assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */ - assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ saved_errno = errno; rc = close(fd); @@ -499,6 +517,12 @@ int uv__close(int fd) { } +int uv__close(int fd) { + assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */ + return uv__close_nocheckstdio(fd); +} + + #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \ defined(_AIX) || defined(__DragonFly__) @@ -809,7 +833,7 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) { void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT))); + assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); assert(0 != events); assert(w->fd >= 0); assert(w->fd < INT_MAX); @@ -842,7 +866,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT))); + assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); assert(0 != events); if (w->fd == -1) @@ -874,7 +898,7 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { void uv__io_close(uv_loop_t* loop, uv__io_t* w) { - uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT); + uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); QUEUE_REMOVE(&w->pending_queue); /* Remove stale events for this file descriptor */ @@ -889,7 +913,7 @@ void uv__io_feed(uv_loop_t* loop, uv__io_t* w) { int uv__io_active(const uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT))); + assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); assert(0 != events); return 0 != (w->pevents & events); } @@ -930,8 +954,7 @@ int uv__open_cloexec(const char* path, int flags) { int err; int fd; -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 9) || \ - defined(__DragonFly__) +#if defined(UV__O_CLOEXEC) static int no_cloexec; if (!no_cloexec) { @@ -1014,17 +1037,10 @@ int uv__dup2_cloexec(int oldfd, int newfd) { int uv_os_homedir(char* buffer, size_t* size) { - struct passwd pw; - struct passwd* result; + uv_passwd_t pwd; char* buf; - uid_t uid; - size_t bufsize; size_t len; - long initsize; int r; -#if defined(__ANDROID_API__) && __ANDROID_API__ < 21 - int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**); -#endif if (buffer == NULL || size == NULL || *size == 0) return -EINVAL; @@ -1036,7 +1052,7 @@ int uv_os_homedir(char* buffer, size_t* size) { len = strlen(buf); if (len >= *size) { - *size = len; + *size = len + 1; return -ENOBUFS; } @@ -1046,13 +1062,102 @@ int uv_os_homedir(char* buffer, size_t* size) { return 0; } + /* HOME is not set, so call uv__getpwuid_r() */ + r = uv__getpwuid_r(&pwd); + + if (r != 0) { + return r; + } + + len = strlen(pwd.homedir); + + if (len >= *size) { + *size = len + 1; + uv_os_free_passwd(&pwd); + return -ENOBUFS; + } + + memcpy(buffer, pwd.homedir, len + 1); + *size = len; + uv_os_free_passwd(&pwd); + + return 0; +} + + +int uv_os_tmpdir(char* buffer, size_t* size) { + const char* buf; + size_t len; + + if (buffer == NULL || size == NULL || *size == 0) + return -EINVAL; + +#define CHECK_ENV_VAR(name) \ + do { \ + buf = getenv(name); \ + if (buf != NULL) \ + goto return_buffer; \ + } \ + while (0) + + /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */ + CHECK_ENV_VAR("TMPDIR"); + CHECK_ENV_VAR("TMP"); + CHECK_ENV_VAR("TEMP"); + CHECK_ENV_VAR("TEMPDIR"); + +#undef CHECK_ENV_VAR + + /* No temp environment variables defined */ + #if defined(__ANDROID__) + buf = "/data/local/tmp"; + #else + buf = "/tmp"; + #endif + +return_buffer: + len = strlen(buf); + + if (len >= *size) { + *size = len + 1; + return -ENOBUFS; + } + + /* The returned directory should not have a trailing slash. */ + if (len > 1 && buf[len - 1] == '/') { + len--; + } + + memcpy(buffer, buf, len + 1); + buffer[len] = '\0'; + *size = len; + + return 0; +} + + +int uv__getpwuid_r(uv_passwd_t* pwd) { + struct passwd pw; + struct passwd* result; + char* buf; + uid_t uid; + size_t bufsize; + size_t name_size; + size_t homedir_size; + size_t shell_size; + long initsize; + int r; #if defined(__ANDROID_API__) && __ANDROID_API__ < 21 + int (*getpwuid_r)(uid_t, struct passwd*, char*, size_t, struct passwd**); + getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r"); if (getpwuid_r == NULL) return -ENOSYS; #endif - /* HOME is not set, so call getpwuid() */ + if (pwd == NULL) + return -EINVAL; + initsize = sysconf(_SC_GETPW_R_SIZE_MAX); if (initsize <= 0) @@ -1060,7 +1165,7 @@ int uv_os_homedir(char* buffer, size_t* size) { else bufsize = (size_t) initsize; - uid = getuid(); + uid = geteuid(); buf = NULL; for (;;) { @@ -1088,17 +1193,54 @@ int uv_os_homedir(char* buffer, size_t* size) { return -ENOENT; } - len = strlen(pw.pw_dir); + /* Allocate memory for the username, shell, and home directory */ + name_size = strlen(pw.pw_name) + 1; + homedir_size = strlen(pw.pw_dir) + 1; + shell_size = strlen(pw.pw_shell) + 1; + pwd->username = uv__malloc(name_size + homedir_size + shell_size); - if (len >= *size) { - *size = len; + if (pwd->username == NULL) { uv__free(buf); - return -ENOBUFS; + return -ENOMEM; } - memcpy(buffer, pw.pw_dir, len + 1); - *size = len; + /* Copy the username */ + memcpy(pwd->username, pw.pw_name, name_size); + + /* Copy the home directory */ + pwd->homedir = pwd->username + name_size; + memcpy(pwd->homedir, pw.pw_dir, homedir_size); + + /* Copy the shell */ + pwd->shell = pwd->homedir + homedir_size; + memcpy(pwd->shell, pw.pw_shell, shell_size); + + /* Copy the uid and gid */ + pwd->uid = pw.pw_uid; + pwd->gid = pw.pw_gid; + uv__free(buf); return 0; } + + +void uv_os_free_passwd(uv_passwd_t* pwd) { + if (pwd == NULL) + return; + + /* + The memory for name, shell, and homedir are allocated in a single + uv__malloc() call. The base of the pointer is stored in pwd->username, so + that is the field that needs to be freed. + */ + uv__free(pwd->username); + pwd->username = NULL; + pwd->shell = NULL; + pwd->homedir = NULL; +} + + +int uv_os_get_passwd(uv_passwd_t* pwd) { + return uv__getpwuid_r(pwd); +} diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 57b65be25a85ea..8936ad9d837095 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -127,8 +127,8 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) { #if defined(__linux__) || defined(__sun) || defined(__NetBSD__) return fdatasync(req->file); -#elif defined(__APPLE__) && defined(F_FULLFSYNC) - return fcntl(req->file, F_FULLFSYNC); +#elif defined(__APPLE__) && defined(SYS_fdatasync) + return syscall(SYS_fdatasync, req->file); #else return fsync(req->file); #endif @@ -749,13 +749,13 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) { dst->st_gen = src->st_gen; #elif defined(__ANDROID__) dst->st_atim.tv_sec = src->st_atime; - dst->st_atim.tv_nsec = src->st_atime_nsec; + dst->st_atim.tv_nsec = src->st_atimensec; dst->st_mtim.tv_sec = src->st_mtime; - dst->st_mtim.tv_nsec = src->st_mtime_nsec; + dst->st_mtim.tv_nsec = src->st_mtimensec; dst->st_ctim.tv_sec = src->st_ctime; - dst->st_ctim.tv_nsec = src->st_ctime_nsec; + dst->st_ctim.tv_nsec = src->st_ctimensec; dst->st_birthtim.tv_sec = src->st_ctime; - dst->st_birthtim.tv_nsec = src->st_ctime_nsec; + dst->st_birthtim.tv_nsec = src->st_ctimensec; dst->st_flags = 0; dst->st_gen = 0; #elif !defined(_AIX) && ( \ @@ -858,9 +858,14 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) total += result; } + if (errno == EINTR && total == -1) + return total; + if (bufs != req->bufsml) uv__free(bufs); + req->bufs = NULL; + req->nbufs = 0; return total; } diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 741fa57d69cad3..938e76f1d18d88 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -28,6 +28,7 @@ #include /* abort */ #include /* strrchr */ #include /* O_CLOEXEC, may be */ +#include #if defined(__STRICT_ANSI__) # define inline __inline @@ -89,17 +90,18 @@ #endif #if defined(__linux__) -# define UV__POLLIN UV__EPOLLIN -# define UV__POLLOUT UV__EPOLLOUT -# define UV__POLLERR UV__EPOLLERR -# define UV__POLLHUP UV__EPOLLHUP +# define UV__POLLIN UV__EPOLLIN +# define UV__POLLOUT UV__EPOLLOUT +# define UV__POLLERR UV__EPOLLERR +# define UV__POLLHUP UV__EPOLLHUP +# define UV__POLLRDHUP UV__EPOLLRDHUP #endif #if defined(__sun) || defined(_AIX) -# define UV__POLLIN POLLIN -# define UV__POLLOUT POLLOUT -# define UV__POLLERR POLLERR -# define UV__POLLHUP POLLHUP +# define UV__POLLIN POLLIN +# define UV__POLLOUT POLLOUT +# define UV__POLLERR POLLERR +# define UV__POLLHUP POLLHUP #endif #ifndef UV__POLLIN @@ -118,6 +120,14 @@ # define UV__POLLHUP 8 #endif +#ifndef UV__POLLRDHUP +# ifdef POLLRDHUP +# define UV__POLLRDHUP POLLRDHUP +# else +# define UV__POLLRDHUP 0x200 +# endif +#endif + #if !defined(O_CLOEXEC) && defined(__FreeBSD__) /* * It may be that we are just missing `__POSIX_VISIBLE >= 200809`. @@ -167,6 +177,7 @@ struct uv__stream_queued_fds_s { /* core */ int uv__nonblock(int fd, int set); int uv__close(int fd); +int uv__close_nocheckstdio(int fd); int uv__cloexec(int fd, int set); int uv__socket(int domain, int type, int protocol); int uv__dup(int fd); @@ -180,6 +191,7 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events); void uv__io_close(uv_loop_t* loop, uv__io_t* w); void uv__io_feed(uv_loop_t* loop, uv__io_t* w); int uv__io_active(const uv__io_t* w, unsigned int events); +int uv__io_check_fd(uv_loop_t* loop, int fd); void uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */ /* async */ @@ -245,6 +257,9 @@ void uv__timer_close(uv_timer_t* handle); void uv__udp_close(uv_udp_t* handle); void uv__udp_finish_close(uv_udp_t* handle); uv_handle_type uv__handle_type(int fd); +FILE* uv__open_file(const char* path); +int uv__getpwuid_r(uv_passwd_t* pwd); + #if defined(__APPLE__) int uv___stream_fd(const uv_stream_t* handle); diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c index 495f20d285fa30..400b4a4b7c6842 100644 --- a/deps/uv/src/unix/kqueue.c +++ b/deps/uv/src/unix/kqueue.c @@ -48,6 +48,24 @@ int uv__kqueue_init(uv_loop_t* loop) { } +int uv__io_check_fd(uv_loop_t* loop, int fd) { + struct kevent ev; + int rc; + + rc = 0; + EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); + if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) + rc = -errno; + + EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0); + if (rc == 0) + if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL)) + abort(); + + return rc; +} + + void uv__io_poll(uv_loop_t* loop, int timeout) { struct kevent events[1024]; struct kevent* ev; @@ -241,6 +259,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (ev->flags & EV_ERROR) revents |= UV__POLLERR; + if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) + revents |= UV__POLLRDHUP; + if (revents == 0) continue; diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index 3ff6fb15e93557..fb8ac3f2379851 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -39,7 +39,7 @@ #define HAVE_IFADDRS_H 1 #ifdef __UCLIBC__ -# if __UCLIBC_MAJOR__ < 0 || __UCLIBC_MINOR__ < 9 || __UCLIBC_SUBLEVEL__ < 32 +# if __UCLIBC_MAJOR__ < 0 && __UCLIBC_MINOR__ < 9 && __UCLIBC_SUBLEVEL__ < 32 # undef HAVE_IFADDRS_H # endif #endif @@ -52,7 +52,7 @@ # endif # include # include -# include +# include #endif /* HAVE_IFADDRS_H */ /* Available from 2.6.32 onwards. */ @@ -69,7 +69,7 @@ #endif static int read_models(unsigned int numcpus, uv_cpu_info_t* ci); -static int read_times(unsigned int numcpus, uv_cpu_info_t* ci); +static int read_times(FILE* statfile_fp, unsigned int numcpus, uv_cpu_info_t* ci); static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci); static unsigned long read_cpufreq(unsigned int cpunum); @@ -140,6 +140,26 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { } +int uv__io_check_fd(uv_loop_t* loop, int fd) { + struct uv__epoll_event e; + int rc; + + e.events = UV__EPOLLIN; + e.data = -1; + + rc = 0; + if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_ADD, fd, &e)) + if (errno != EEXIST) + rc = -errno; + + if (rc == 0) + if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &e)) + abort(); + + return rc; +} + + void uv__io_poll(uv_loop_t* loop, int timeout) { /* A bug in kernels < 2.6.37 makes timeouts larger than ~30 minutes * effectively infinite on 32 bits architectures. To avoid blocking @@ -532,15 +552,42 @@ int uv_uptime(double* uptime) { } +static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { + unsigned int num; + char buf[1024]; + + if (!fgets(buf, sizeof(buf), statfile_fp)) + abort(); + + num = 0; + while (fgets(buf, sizeof(buf), statfile_fp)) { + if (strncmp(buf, "cpu", 3)) + break; + num++; + } + + *numcpus = num; + return 0; +} + + int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { unsigned int numcpus; uv_cpu_info_t* ci; int err; + FILE* statfile_fp; *cpu_infos = NULL; *count = 0; - numcpus = sysconf(_SC_NPROCESSORS_ONLN); + statfile_fp = uv__open_file("/proc/stat"); + if (statfile_fp == NULL) + return -errno; + + err = uv__cpu_num(statfile_fp, &numcpus); + if (err < 0) + return err; + assert(numcpus != (unsigned int) -1); assert(numcpus != 0); @@ -550,7 +597,11 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { err = read_models(numcpus, ci); if (err == 0) - err = read_times(numcpus, ci); + err = read_times(statfile_fp, numcpus, ci); + + if (fclose(statfile_fp)) + if (errno != EINTR && errno != EINPROGRESS) + abort(); if (err) { uv_free_cpu_info(ci, numcpus); @@ -608,7 +659,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) { defined(__i386__) || \ defined(__mips__) || \ defined(__x86_64__) - fp = fopen("/proc/cpuinfo", "r"); + fp = uv__open_file("/proc/cpuinfo"); if (fp == NULL) return -errno; @@ -676,7 +727,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) { } -static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) { +static int read_times(FILE* statfile_fp, unsigned int numcpus, uv_cpu_info_t* ci) { unsigned long clock_ticks; struct uv_cpu_times_s ts; unsigned long user; @@ -688,22 +739,19 @@ static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) { unsigned int num; unsigned int len; char buf[1024]; - FILE* fp; clock_ticks = sysconf(_SC_CLK_TCK); assert(clock_ticks != (unsigned long) -1); assert(clock_ticks != 0); - fp = fopen("/proc/stat", "r"); - if (fp == NULL) - return -errno; + rewind(statfile_fp); - if (!fgets(buf, sizeof(buf), fp)) + if (!fgets(buf, sizeof(buf), statfile_fp)) abort(); num = 0; - while (fgets(buf, sizeof(buf), fp)) { + while (fgets(buf, sizeof(buf), statfile_fp)) { if (num >= numcpus) break; @@ -742,7 +790,6 @@ static int read_times(unsigned int numcpus, uv_cpu_info_t* ci) { ts.irq = clock_ticks * irq; ci[num++].cpu_times = ts; } - fclose(fp); assert(num == numcpus); return 0; @@ -759,7 +806,7 @@ static unsigned long read_cpufreq(unsigned int cpunum) { "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq", cpunum); - fp = fopen(buf, "r"); + fp = uv__open_file(buf); if (fp == NULL) return 0; diff --git a/deps/uv/src/unix/linux-syscalls.h b/deps/uv/src/unix/linux-syscalls.h index 96e79439cf07ab..4260df111f3ae4 100644 --- a/deps/uv/src/unix/linux-syscalls.h +++ b/deps/uv/src/unix/linux-syscalls.h @@ -76,6 +76,7 @@ #define UV__EPOLLOUT 4 #define UV__EPOLLERR 8 #define UV__EPOLLHUP 16 +#define UV__EPOLLRDHUP 0x2000 #define UV__EPOLLONESHOT 0x40000000 #define UV__EPOLLET 0x80000000 diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c index 7f87a713bf40fe..d4fdfa9d5a5480 100644 --- a/deps/uv/src/unix/pipe.c +++ b/deps/uv/src/unix/pipe.c @@ -200,9 +200,6 @@ void uv_pipe_connect(uv_connect_t* req, if (err) uv__io_feed(handle->loop, &handle->io_watcher); - /* Mimic the Windows pipe implementation, always - * return 0 and let the callback handle errors. - */ } @@ -234,14 +231,18 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle, addrlen = strlen(sa.sun_path); - if (addrlen > *size) { - *size = addrlen; + if (addrlen >= *size) { + *size = addrlen + 1; return UV_ENOBUFS; } memcpy(buffer, sa.sun_path, addrlen); *size = addrlen; + /* only null-terminate if it's not an abstract socket */ + if (buffer[0] != '\0') + buffer[addrlen] = '\0'; + return 0; } diff --git a/deps/uv/src/unix/poll.c b/deps/uv/src/unix/poll.c index 37da3b95851b07..e5efb17160ff95 100644 --- a/deps/uv/src/unix/poll.c +++ b/deps/uv/src/unix/poll.c @@ -34,7 +34,7 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { handle = container_of(w, uv_poll_t, io_watcher); if (events & UV__POLLERR) { - uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT); + uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); uv__handle_stop(handle); handle->poll_cb(handle, -EBADF, 0); return; @@ -45,6 +45,8 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { pevents |= UV_READABLE; if (events & UV__POLLOUT) pevents |= UV_WRITABLE; + if (events & UV__POLLRDHUP) + pevents |= UV_DISCONNECT; handle->poll_cb(handle, 0, pevents); } @@ -53,6 +55,10 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { int err; + err = uv__io_check_fd(loop, fd); + if (err) + return err; + err = uv__nonblock(fd, 1); if (err) return err; @@ -71,7 +77,9 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, static void uv__poll_stop(uv_poll_t* handle) { - uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT); + uv__io_stop(handle->loop, + &handle->io_watcher, + UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); uv__handle_stop(handle); } @@ -86,7 +94,7 @@ int uv_poll_stop(uv_poll_t* handle) { int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { int events; - assert((pevents & ~(UV_READABLE | UV_WRITABLE)) == 0); + assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); uv__poll_stop(handle); @@ -99,6 +107,8 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { events |= UV__POLLIN; if (pevents & UV_WRITABLE) events |= UV__POLLOUT; + if (pevents & UV_DISCONNECT) + events |= UV__POLLRDHUP; uv__io_start(handle->loop, &handle->io_watcher, events); uv__handle_start(handle); diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index 571f8cd778c74f..ef10a3422dc518 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -498,7 +498,7 @@ int uv_spawn(uv_loop_t* loop, } else abort(); - uv__close(signal_pipe[0]); + uv__close_nocheckstdio(signal_pipe[0]); for (i = 0; i < options->stdio_count; i++) { err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0); @@ -530,9 +530,9 @@ int uv_spawn(uv_loop_t* loop, if (options->stdio[i].flags & (UV_INHERIT_FD | UV_INHERIT_STREAM)) continue; if (pipes[i][0] != -1) - close(pipes[i][0]); + uv__close_nocheckstdio(pipes[i][0]); if (pipes[i][1] != -1) - close(pipes[i][1]); + uv__close_nocheckstdio(pipes[i][1]); } uv__free(pipes); } diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 7d7ab2633b6f2d..9043664dfcaf9a 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -946,13 +946,14 @@ static void uv__write_callbacks(uv_stream_t* stream) { uv_handle_type uv__handle_type(int fd) { struct sockaddr_storage ss; + socklen_t sslen; socklen_t len; int type; memset(&ss, 0, sizeof(ss)); - len = sizeof(ss); + sslen = sizeof(ss); - if (getsockname(fd, (struct sockaddr*)&ss, &len)) + if (getsockname(fd, (struct sockaddr*)&ss, &sslen)) return UV_UNKNOWN_HANDLE; len = sizeof type; @@ -961,6 +962,14 @@ uv_handle_type uv__handle_type(int fd) { return UV_UNKNOWN_HANDLE; if (type == SOCK_STREAM) { +#if defined(_AIX) + /* on AIX the getsockname call returns an empty sa structure + * for sockets of type AF_UNIX. For all other types it will + * return a properly filled in structure. + */ + if (sslen == 0) + return UV_NAMED_PIPE; +#endif switch (ss.ss_family) { case AF_UNIX: return UV_NAMED_PIPE; @@ -1082,6 +1091,11 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) { } +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wgnu-folding-constant" +#endif + static void uv__read(uv_stream_t* stream) { uv_buf_t buf; ssize_t nread; @@ -1187,6 +1201,10 @@ static void uv__read(uv_stream_t* stream) { } +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + #undef UV__CMSG_FD_COUNT #undef UV__CMSG_FD_SIZE diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index 0c46817b446e61..9a6cc42b5bf3fd 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -116,6 +116,17 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { } +int uv__io_check_fd(uv_loop_t* loop, int fd) { + if (port_associate(loop->backend_fd, PORT_SOURCE_FD, fd, POLLIN, 0)) + return -errno; + + if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd)) + abort(); + + return 0; +} + + void uv__io_poll(uv_loop_t* loop, int timeout) { struct port_event events[1024]; struct port_event* pe; diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index c56a3170259e90..c35bc926bf0fac 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -27,6 +27,9 @@ #include #include +#include /* getrlimit() */ + +#include #undef NANOSEC #define NANOSEC ((uint64_t) 1e9) @@ -55,6 +58,11 @@ static void* uv__thread_start(void *arg) int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { struct thread_ctx* ctx; int err; + pthread_attr_t* attr; +#if defined(__APPLE__) + pthread_attr_t attr_storage; + struct rlimit lim; +#endif ctx = uv__malloc(sizeof(*ctx)); if (ctx == NULL) @@ -63,7 +71,30 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { ctx->entry = entry; ctx->arg = arg; - err = pthread_create(tid, NULL, uv__thread_start, ctx); + /* On OSX threads other than the main thread are created with a reduced stack + * size by default, adjust it to RLIMIT_STACK. + */ +#if defined(__APPLE__) + if (getrlimit(RLIMIT_STACK, &lim)) + abort(); + + attr = &attr_storage; + if (pthread_attr_init(attr)) + abort(); + + if (lim.rlim_cur != RLIM_INFINITY && + lim.rlim_cur >= PTHREAD_STACK_MIN) { + if (pthread_attr_setstacksize(attr, lim.rlim_cur)) + abort(); + } +#else + attr = NULL; +#endif + + err = pthread_create(tid, attr, uv__thread_start, ctx); + + if (attr != NULL) + pthread_attr_destroy(attr); if (err) uv__free(ctx); diff --git a/deps/uv/src/unix/tty.c b/deps/uv/src/unix/tty.c index 7cc5b714ed302c..32fa37eac96307 100644 --- a/deps/uv/src/unix/tty.c +++ b/deps/uv/src/unix/tty.c @@ -23,6 +23,7 @@ #include "internal.h" #include "spinlock.h" +#include #include #include #include @@ -33,12 +34,30 @@ static int orig_termios_fd = -1; static struct termios orig_termios; static uv_spinlock_t termios_spinlock = UV_SPINLOCK_INITIALIZER; +static int uv__tty_is_slave(const int fd) { + int result; +#if defined(__linux__) || defined(__FreeBSD__) + int dummy; + + result = ioctl(fd, TIOCGPTN, &dummy) != 0; +#elif defined(__APPLE__) + char dummy[256]; + + result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0; +#else + /* Fallback to ptsname + */ + result = ptsname(fd) == NULL; +#endif + return result; +} int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { uv_handle_type type; int flags; int newfd; int r; + char path[256]; /* File descriptors that refer to files cannot be monitored with epoll. * That restriction also applies to character devices like /dev/random @@ -62,7 +81,15 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) { * other processes. */ if (type == UV_TTY) { - r = uv__open_cloexec("/dev/tty", O_RDWR); + /* Reopening a pty in master mode won't work either because the reopened + * pty will be in slave mode (*BSD) or reopening will allocate a new + * master/slave pair (Linux). Therefore check if the fd points to a + * slave device. + */ + if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0) + r = uv__open_cloexec(path, O_RDWR); + else + r = -1; if (r < 0) { /* fallback to using blocking writes */ @@ -185,8 +212,13 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) { struct winsize ws; + int err; + + do + err = ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws); + while (err == -1 && errno == EINTR); - if (ioctl(uv__stream_fd(tty), TIOCGWINSZ, &ws)) + if (err == -1) return -errno; *width = ws.ws_col; diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index 40ed28fec5a662..6b8c584fbe75b1 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -451,13 +451,14 @@ int uv_fs_event_getpath(uv_fs_event_t* handle, char* buffer, size_t* size) { } required_len = strlen(handle->path); - if (required_len > *size) { - *size = required_len; + if (required_len >= *size) { + *size = required_len + 1; return UV_ENOBUFS; } memcpy(buffer, handle->path, required_len); *size = required_len; + buffer[required_len] = '\0'; return 0; } diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c index de0483e1023017..ba306ebc083fbb 100644 --- a/deps/uv/src/win/core.c +++ b/deps/uv/src/win/core.c @@ -256,30 +256,48 @@ static void uv_poll(uv_loop_t* loop, DWORD timeout) { ULONG_PTR key; OVERLAPPED* overlapped; uv_req_t* req; + int repeat; + uint64_t timeout_time; - GetQueuedCompletionStatus(loop->iocp, - &bytes, - &key, - &overlapped, - timeout); + timeout_time = loop->time + timeout; - if (overlapped) { - /* Package was dequeued */ - req = uv_overlapped_to_req(overlapped); - uv_insert_pending_req(loop, req); + for (repeat = 0; ; repeat++) { + GetQueuedCompletionStatus(loop->iocp, + &bytes, + &key, + &overlapped, + timeout); - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout is reflected in the loop time. - */ - uv__time_forward(loop, timeout); + if (overlapped) { + /* Package was dequeued */ + req = uv_overlapped_to_req(overlapped); + uv_insert_pending_req(loop, req); + + /* Some time might have passed waiting for I/O, + * so update the loop time here. + */ + uv_update_time(loop); + } else if (GetLastError() != WAIT_TIMEOUT) { + /* Serious error */ + uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus"); + } else if (timeout > 0) { + /* GetQueuedCompletionStatus can occasionally return a little early. + * Make sure that the desired timeout target time is reached. + */ + uv_update_time(loop); + if (timeout_time > loop->time) { + timeout = (DWORD)(timeout_time - loop->time); + /* The first call to GetQueuedCompletionStatus should return very + * close to the target time and the second should reach it, but + * this is not stated in the documentation. To make sure a busy + * loop cannot happen, the timeout is increased exponentially + * starting on the third round. + */ + timeout += repeat ? (1 << (repeat - 1)) : 0; + continue; + } + } + break; } } @@ -290,33 +308,51 @@ static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) { OVERLAPPED_ENTRY overlappeds[128]; ULONG count; ULONG i; - - success = pGetQueuedCompletionStatusEx(loop->iocp, - overlappeds, - ARRAY_SIZE(overlappeds), - &count, - timeout, - FALSE); - - if (success) { - for (i = 0; i < count; i++) { - /* Package was dequeued */ - req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); - uv_insert_pending_req(loop, req); + int repeat; + uint64_t timeout_time; + + timeout_time = loop->time + timeout; + + for (repeat = 0; ; repeat++) { + success = pGetQueuedCompletionStatusEx(loop->iocp, + overlappeds, + ARRAY_SIZE(overlappeds), + &count, + timeout, + FALSE); + + if (success) { + for (i = 0; i < count; i++) { + /* Package was dequeued */ + req = uv_overlapped_to_req(overlappeds[i].lpOverlapped); + uv_insert_pending_req(loop, req); + } + + /* Some time might have passed waiting for I/O, + * so update the loop time here. + */ + uv_update_time(loop); + } else if (GetLastError() != WAIT_TIMEOUT) { + /* Serious error */ + uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); + } else if (timeout > 0) { + /* GetQueuedCompletionStatus can occasionally return a little early. + * Make sure that the desired timeout target time is reached. + */ + uv_update_time(loop); + if (timeout_time > loop->time) { + timeout = (DWORD)(timeout_time - loop->time); + /* The first call to GetQueuedCompletionStatus should return very + * close to the target time and the second should reach it, but + * this is not stated in the documentation. To make sure a busy + * loop cannot happen, the timeout is increased exponentially + * starting on the third round. + */ + timeout += repeat ? (1 << (repeat - 1)) : 0; + continue; + } } - - /* Some time might have passed waiting for I/O, - * so update the loop time here. - */ - uv_update_time(loop); - } else if (GetLastError() != WAIT_TIMEOUT) { - /* Serious error */ - uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx"); - } else if (timeout > 0) { - /* GetQueuedCompletionStatus can occasionally return a little early. - * Make sure that the desired timeout is reflected in the loop time. - */ - uv__time_forward(loop, timeout); + break; } } diff --git a/deps/uv/src/win/dl.c b/deps/uv/src/win/dl.c index e5f3407f8eb27e..39e400ab2dbd19 100644 --- a/deps/uv/src/win/dl.c +++ b/deps/uv/src/win/dl.c @@ -31,7 +31,12 @@ int uv_dlopen(const char* filename, uv_lib_t* lib) { lib->handle = NULL; lib->errmsg = NULL; - if (!uv_utf8_to_utf16(filename, filename_w, ARRAY_SIZE(filename_w))) { + if (!MultiByteToWideChar(CP_UTF8, + 0, + filename, + -1, + filename_w, + ARRAY_SIZE(filename_w))) { return uv__dlerror(lib, GetLastError()); } diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c index 76ecfebaa24c39..77c935a2d8c8fe 100644 --- a/deps/uv/src/win/fs-event.c +++ b/deps/uv/src/win/fs-event.c @@ -63,19 +63,19 @@ static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop, handle->req_pending = 1; } -static int uv_relative_path(const WCHAR* filename, - const WCHAR* dir, - WCHAR** relpath) { - int dirlen = wcslen(dir); - int filelen = wcslen(filename); - if (dir[dirlen - 1] == '\\') +static void uv_relative_path(const WCHAR* filename, + const WCHAR* dir, + WCHAR** relpath) { + size_t dirlen = wcslen(dir); + if (dirlen > 0 && dir[dirlen - 1] == '\\') dirlen--; - *relpath = uv__malloc((MAX_PATH + 1) * sizeof(WCHAR)); + size_t filenamelen = wcslen(filename); + size_t relpathlen = filenamelen - dirlen - 1; + *relpath = uv__malloc((relpathlen + 1) * sizeof(WCHAR)); if (!*relpath) uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - wcsncpy(*relpath, filename + dirlen + 1, filelen - dirlen - 1); - (*relpath)[filelen - dirlen - 1] = L'\0'; - return 0; + wcsncpy(*relpath, filename + dirlen + 1, relpathlen); + (*relpath)[relpathlen] = L'\0'; } static int uv_split_path(const WCHAR* filename, WCHAR** dir, @@ -101,12 +101,12 @@ static int uv_split_path(const WCHAR* filename, WCHAR** dir, *file = wcsdup(filename); } else { if (dir) { - *dir = (WCHAR*)uv__malloc((i + 1) * sizeof(WCHAR)); + *dir = (WCHAR*)uv__malloc((i + 2) * sizeof(WCHAR)); if (!*dir) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - wcsncpy(*dir, filename, i); - (*dir)[i] = L'\0'; + wcsncpy(*dir, filename, i + 1); + (*dir)[i + 1] = L'\0'; } *file = (WCHAR*)uv__malloc((len - i) * sizeof(WCHAR)); @@ -159,14 +159,20 @@ int uv_fs_event_start(uv_fs_event_t* handle, uv__handle_start(handle); /* Convert name to UTF16. */ - name_size = uv_utf8_to_utf16(path, NULL, 0) * sizeof(WCHAR); + + name_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) * + sizeof(WCHAR); pathw = (WCHAR*)uv__malloc(name_size); if (!pathw) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - if (!uv_utf8_to_utf16(path, pathw, - name_size / sizeof(WCHAR))) { + if (!MultiByteToWideChar(CP_UTF8, + 0, + path, + -1, + pathw, + name_size / sizeof(WCHAR))) { return uv_translate_sys_error(GetLastError()); } @@ -340,7 +346,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, uv_fs_event_t* handle) { FILE_NOTIFY_INFORMATION* file_info; - int err, sizew, size, result; + int err, sizew, size; char* filename = NULL; WCHAR* filenamew, *long_filenamew = NULL; DWORD offset = 0; @@ -425,39 +431,23 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, if (long_filenamew) { /* Get the file name out of the long path. */ - result = uv_relative_path(long_filenamew, - handle->dirw, - &filenamew); + uv_relative_path(long_filenamew, + handle->dirw, + &filenamew); uv__free(long_filenamew); - - if (result == 0) { - long_filenamew = filenamew; - sizew = -1; - } else { - long_filenamew = NULL; - } - } - - /* - * We could not resolve the long form explicitly. - * We therefore use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - if (!long_filenamew) { - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); - } - } else { - /* - * Removed or renamed events cannot be resolved to the long form. - * We therefore use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - if (!long_filenamew) { - filenamew = file_info->FileName; - sizew = file_info->FileNameLength / sizeof(WCHAR); + long_filenamew = filenamew; + sizew = -1; } } + /* + * Removed or renamed events cannot be resolved to the long form. + * We therefore use the name given by ReadDirectoryChangesW. + * This may be the long form or the 8.3 short name in some cases. + */ + if (!long_filenamew) { + filenamew = file_info->FileName; + sizew = file_info->FileNameLength / sizeof(WCHAR); + } } else { /* We already have the long name of the file, so just use it. */ filenamew = handle->filew; @@ -466,20 +456,28 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, if (filenamew) { /* Convert the filename to utf8. */ - size = uv_utf16_to_utf8(filenamew, - sizew, - NULL, - 0); + size = WideCharToMultiByte(CP_UTF8, + 0, + filenamew, + sizew, + NULL, + 0, + NULL, + NULL); if (size) { filename = (char*)uv__malloc(size + 1); if (!filename) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - size = uv_utf16_to_utf8(filenamew, - sizew, - filename, - size); + size = WideCharToMultiByte(CP_UTF8, + 0, + filenamew, + sizew, + filename, + size, + NULL, + NULL); if (size) { filename[size] = '\0'; } else { diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index a32b0127f7e1e9..16e3ae7cf1b416 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -1717,25 +1717,26 @@ static void fs__readlink(uv_fs_t* req) { static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { int r; DWORD w_realpath_len; - WCHAR* w_realpath_ptr; - WCHAR* w_finalpath_ptr = NULL; + WCHAR* w_realpath_ptr = NULL; + WCHAR* w_realpath_buf; w_realpath_len = pGetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS); if (w_realpath_len == 0) { return -1; } - w_realpath_ptr = uv__malloc((w_realpath_len + 1) * sizeof(WCHAR)); - if (w_realpath_ptr == NULL) { + w_realpath_buf = uv__malloc((w_realpath_len + 1) * sizeof(WCHAR)); + if (w_realpath_buf == NULL) { SetLastError(ERROR_OUTOFMEMORY); return -1; } + w_realpath_ptr = w_realpath_buf; if (pGetFinalPathNameByHandleW(handle, w_realpath_ptr, w_realpath_len, VOLUME_NAME_DOS) == 0) { - uv__free(w_realpath_ptr); + uv__free(w_realpath_buf); SetLastError(ERROR_INVALID_HANDLE); return -1; } @@ -1744,20 +1745,22 @@ static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) { if (wcsncmp(w_realpath_ptr, UNC_PATH_PREFIX, UNC_PATH_PREFIX_LEN) == 0) { - w_finalpath_ptr = w_realpath_ptr + 6; - *w_finalpath_ptr = L'\\'; + w_realpath_ptr += 6; + *w_realpath_ptr = L'\\'; + w_realpath_len -= 6; } else if (wcsncmp(w_realpath_ptr, LONG_PATH_PREFIX, LONG_PATH_PREFIX_LEN) == 0) { - w_finalpath_ptr = w_realpath_ptr + 4; + w_realpath_ptr += 4; + w_realpath_len -= 4; } else { - uv__free(w_realpath_ptr); + uv__free(w_realpath_buf); SetLastError(ERROR_INVALID_HANDLE); return -1; } - r = fs__wide_to_utf8(w_finalpath_ptr, w_realpath_len, realpath_ptr, NULL); - uv__free(w_realpath_ptr); + r = fs__wide_to_utf8(w_realpath_ptr, w_realpath_len, realpath_ptr, NULL); + uv__free(w_realpath_buf); return r; } diff --git a/deps/uv/src/win/getaddrinfo.c b/deps/uv/src/win/getaddrinfo.c index ceed3b7638b457..744f8e02629ccd 100644 --- a/deps/uv/src/win/getaddrinfo.c +++ b/deps/uv/src/win/getaddrinfo.c @@ -126,7 +126,14 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { addrinfo_len += addrinfo_struct_len + ALIGNED_SIZE(addrinfow_ptr->ai_addrlen); if (addrinfow_ptr->ai_canonname != NULL) { - name_len = uv_utf16_to_utf8(addrinfow_ptr->ai_canonname, -1, NULL, 0); + name_len = WideCharToMultiByte(CP_UTF8, + 0, + addrinfow_ptr->ai_canonname, + -1, + NULL, + 0, + NULL, + NULL); if (name_len == 0) { req->retcode = uv_translate_sys_error(GetLastError()); goto complete; @@ -170,16 +177,24 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) { /* convert canonical name to UTF-8 */ if (addrinfow_ptr->ai_canonname != NULL) { - name_len = uv_utf16_to_utf8(addrinfow_ptr->ai_canonname, - -1, - NULL, - 0); + name_len = WideCharToMultiByte(CP_UTF8, + 0, + addrinfow_ptr->ai_canonname, + -1, + NULL, + 0, + NULL, + NULL); assert(name_len > 0); assert(cur_ptr + name_len <= alloc_ptr + addrinfo_len); - name_len = uv_utf16_to_utf8(addrinfow_ptr->ai_canonname, - -1, - cur_ptr, - name_len); + name_len = WideCharToMultiByte(CP_UTF8, + 0, + addrinfow_ptr->ai_canonname, + -1, + cur_ptr, + name_len, + NULL, + NULL); assert(name_len > 0); addrinfo_ptr->ai_canonname = cur_ptr; cur_ptr += ALIGNED_SIZE(name_len); @@ -261,7 +276,8 @@ int uv_getaddrinfo(uv_loop_t* loop, /* calculate required memory size for all input values */ if (node != NULL) { - nodesize = ALIGNED_SIZE(uv_utf8_to_utf16(node, NULL, 0) * sizeof(WCHAR)); + nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) * + sizeof(WCHAR)); if (nodesize == 0) { err = GetLastError(); goto error; @@ -269,7 +285,12 @@ int uv_getaddrinfo(uv_loop_t* loop, } if (service != NULL) { - servicesize = ALIGNED_SIZE(uv_utf8_to_utf16(service, NULL, 0) * + servicesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, + 0, + service, + -1, + NULL, + 0) * sizeof(WCHAR)); if (servicesize == 0) { err = GetLastError(); @@ -294,9 +315,12 @@ int uv_getaddrinfo(uv_loop_t* loop, /* the request. */ if (node != NULL) { req->node = (WCHAR*)alloc_ptr; - if (uv_utf8_to_utf16(node, - (WCHAR*) alloc_ptr, - nodesize / sizeof(WCHAR)) == 0) { + if (MultiByteToWideChar(CP_UTF8, + 0, + node, + -1, + (WCHAR*) alloc_ptr, + nodesize / sizeof(WCHAR)) == 0) { err = GetLastError(); goto error; } @@ -309,9 +333,12 @@ int uv_getaddrinfo(uv_loop_t* loop, /* in the req. */ if (service != NULL) { req->service = (WCHAR*)alloc_ptr; - if (uv_utf8_to_utf16(service, - (WCHAR*) alloc_ptr, - servicesize / sizeof(WCHAR)) == 0) { + if (MultiByteToWideChar(CP_UTF8, + 0, + service, + -1, + (WCHAR*) alloc_ptr, + servicesize / sizeof(WCHAR)) == 0) { err = GetLastError(); goto error; } diff --git a/deps/uv/src/win/internal.h b/deps/uv/src/win/internal.h index 783f21af0fe9f1..c724793bf05a41 100644 --- a/deps/uv/src/win/internal.h +++ b/deps/uv/src/win/internal.h @@ -246,7 +246,6 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle); void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle); DWORD uv__next_timeout(const uv_loop_t* loop); -void uv__time_forward(uv_loop_t* loop, uint64_t msecs); void uv_process_timers(uv_loop_t* loop); @@ -329,6 +328,8 @@ uint64_t uv__hrtime(double scale); int uv_parent_pid(); int uv_current_pid(); __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); +int uv__getpwuid_r(uv_passwd_t* pwd); +int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8); /* diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c index bcce80c77e5d57..a784325c589474 100644 --- a/deps/uv/src/win/pipe.c +++ b/deps/uv/src/win/pipe.c @@ -513,13 +513,18 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) { } /* Convert name to UTF16. */ - nameSize = uv_utf8_to_utf16(name, NULL, 0) * sizeof(WCHAR); + nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); handle->name = (WCHAR*)uv__malloc(nameSize); if (!handle->name) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(WCHAR))) { + if (!MultiByteToWideChar(CP_UTF8, + 0, + name, + -1, + handle->name, + nameSize / sizeof(WCHAR))) { err = GetLastError(); goto error; } @@ -627,13 +632,18 @@ void uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle, req->cb = cb; /* Convert name to UTF16. */ - nameSize = uv_utf8_to_utf16(name, NULL, 0) * sizeof(WCHAR); + nameSize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0) * sizeof(WCHAR); handle->name = (WCHAR*)uv__malloc(nameSize); if (!handle->name) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(WCHAR))) { + if (!MultiByteToWideChar(CP_UTF8, + 0, + name, + -1, + handle->name, + nameSize / sizeof(WCHAR))) { err = GetLastError(); goto error; } @@ -2038,9 +2048,9 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) *size = 0; err = uv_translate_sys_error(GetLastError()); goto error; - } else if (pipe_prefix_len + addrlen > *size) { + } else if (pipe_prefix_len + addrlen >= *size) { /* "\\\\.\\pipe" + name */ - *size = pipe_prefix_len + addrlen; + *size = pipe_prefix_len + addrlen + 1; err = UV_ENOBUFS; goto error; } @@ -2062,6 +2072,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size) addrlen += pipe_prefix_len; *size = addrlen; + buffer[addrlen] = '\0'; err = 0; goto cleanup; diff --git a/deps/uv/src/win/poll.c b/deps/uv/src/win/poll.c index ce861d6ffc41eb..d479e521efe24f 100644 --- a/deps/uv/src/win/poll.c +++ b/deps/uv/src/win/poll.c @@ -91,7 +91,11 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { handle->mask_events_1 = handle->events; handle->mask_events_2 = 0; } else { - assert(0); + /* Just wait until there's an unsubmitted req. */ + /* This will happen almost immediately as one of the 2 outstanding */ + /* requests is about to return. When this happens, */ + /* uv__fast_poll_process_poll_req will be called, and the pending */ + /* events, if needed, will be processed in a subsequent request. */ return; } @@ -107,6 +111,10 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) { if (handle->events & UV_READABLE) { afd_poll_info->Handles[0].Events |= AFD_POLL_RECEIVE | AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT; + } else { + if (handle->events & UV_DISCONNECT) { + afd_poll_info->Handles[0].Events |= AFD_POLL_DISCONNECT; + } } if (handle->events & UV_WRITABLE) { afd_poll_info->Handles[0].Events |= AFD_POLL_SEND | AFD_POLL_CONNECT_FAIL; @@ -184,6 +192,9 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, if ((afd_poll_info->Handles[0].Events & (AFD_POLL_RECEIVE | AFD_POLL_DISCONNECT | AFD_POLL_ACCEPT | AFD_POLL_ABORT)) != 0) { events |= UV_READABLE; + if ((afd_poll_info->Handles[0].Events & AFD_POLL_DISCONNECT) != 0) { + events |= UV_DISCONNECT; + } } if ((afd_poll_info->Handles[0].Events & (AFD_POLL_SEND | AFD_POLL_CONNECT_FAIL)) != 0) { @@ -218,7 +229,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) { assert(handle->type == UV_POLL); assert(!(handle->flags & UV__HANDLE_CLOSING)); - assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0); + assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0); handle->events = events; diff --git a/deps/uv/src/win/timer.c b/deps/uv/src/win/timer.c index 0da541a2c8685c..27ca7716af6d8a 100644 --- a/deps/uv/src/win/timer.c +++ b/deps/uv/src/win/timer.c @@ -34,13 +34,8 @@ void uv_update_time(uv_loop_t* loop) { uint64_t new_time = uv__hrtime(UV__MILLISEC); - if (new_time > loop->time) { - loop->time = new_time; - } -} - -void uv__time_forward(uv_loop_t* loop, uint64_t msecs) { - loop->time += msecs; + assert(new_time >= loop->time); + loop->time = new_time; } diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index d87cc699097cf7..1b27f60a6f0c9c 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -292,12 +292,9 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) { was_reading = 1; alloc_cb = tty->alloc_cb; read_cb = tty->read_cb; - - if (was_reading) { - err = uv_tty_read_stop(tty); - if (err) { - return uv_translate_sys_error(err); - } + err = uv_tty_read_stop(tty); + if (err) { + return uv_translate_sys_error(err); } } else { was_reading = 0; diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index cb247513046351..1788b1780e9bba 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -87,30 +87,6 @@ void uv__util_init() { } -int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size, - char* utf8Buffer, size_t utf8Size) { - return WideCharToMultiByte(CP_UTF8, - 0, - utf16Buffer, - utf16Size, - utf8Buffer, - utf8Size, - NULL, - NULL); -} - - -int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer, - size_t utf16Size) { - return MultiByteToWideChar(CP_UTF8, - 0, - utf8Buffer, - -1, - utf16Buffer, - utf16Size); -} - - int uv_exepath(char* buffer, size_t* size_ptr) { int utf8_len, utf16_buffer_len, utf16_len; WCHAR* utf16_buffer; @@ -210,7 +186,7 @@ int uv_cwd(char* buffer, size_t* size) { if (r == 0) { return uv_translate_sys_error(GetLastError()); } else if (r > (int) *size) { - *size = r -1; + *size = r; return UV_ENOBUFS; } @@ -384,7 +360,7 @@ int uv_set_process_title(const char* title) { uv__once_init(); /* Find out how big the buffer for the wide-char title must be */ - length = uv_utf8_to_utf16(title, NULL, 0); + length = MultiByteToWideChar(CP_UTF8, 0, title, -1, NULL, 0); if (!length) { err = GetLastError(); goto done; @@ -396,7 +372,7 @@ int uv_set_process_title(const char* title) { uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); } - length = uv_utf8_to_utf16(title, title_w, length); + length = MultiByteToWideChar(CP_UTF8, 0, title, -1, title_w, length); if (!length) { err = GetLastError(); goto done; @@ -434,7 +410,7 @@ static int uv__get_process_title() { } /* Find out what the size of the buffer is that we need */ - length = uv_utf16_to_utf8(title_w, -1, NULL, 0); + length = WideCharToMultiByte(CP_UTF8, 0, title_w, -1, NULL, 0, NULL, NULL); if (!length) { return -1; } @@ -446,7 +422,14 @@ static int uv__get_process_title() { } /* Do utf16 -> utf8 conversion here */ - if (!uv_utf16_to_utf8(title_w, -1, process_title, length)) { + if (!WideCharToMultiByte(CP_UTF8, + 0, + title_w, + -1, + process_title, + length, + NULL, + NULL)) { uv__free(process_title); return -1; } @@ -1169,7 +1152,7 @@ int uv_getrusage(uv_rusage_t *uv_rusage) { int uv_os_homedir(char* buffer, size_t* size) { - HANDLE token; + uv_passwd_t pwd; wchar_t path[MAX_PATH]; DWORD bufsize; size_t len; @@ -1183,6 +1166,7 @@ int uv_os_homedir(char* buffer, size_t* size) { if (len == 0) { r = GetLastError(); + /* Don't return an error if USERPROFILE was not found */ if (r != ERROR_ENVVAR_NOT_FOUND) return uv_translate_sys_error(r); @@ -1190,43 +1174,219 @@ int uv_os_homedir(char* buffer, size_t* size) { /* This should not be possible */ return UV_EIO; } else { - goto convert_buffer; + /* Check how much space we need */ + bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); + + if (bufsize == 0) { + return uv_translate_sys_error(GetLastError()); + } else if (bufsize > *size) { + *size = bufsize; + return UV_ENOBUFS; + } + + /* Convert to UTF-8 */ + bufsize = WideCharToMultiByte(CP_UTF8, + 0, + path, + -1, + buffer, + *size, + NULL, + NULL); + + if (bufsize == 0) + return uv_translate_sys_error(GetLastError()); + + *size = bufsize - 1; + return 0; } - /* USERPROFILE is not set, so call GetUserProfileDirectoryW() */ - if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) - return uv_translate_sys_error(GetLastError()); + /* USERPROFILE is not set, so call uv__getpwuid_r() */ + r = uv__getpwuid_r(&pwd); - bufsize = MAX_PATH; - if (!GetUserProfileDirectoryW(token, path, &bufsize)) { - r = GetLastError(); - CloseHandle(token); + if (r != 0) { + return r; + } - /* This should not be possible */ - if (r == ERROR_INSUFFICIENT_BUFFER) - return UV_EIO; + len = strlen(pwd.homedir); - return uv_translate_sys_error(r); + if (len >= *size) { + *size = len + 1; + uv_os_free_passwd(&pwd); + return UV_ENOBUFS; } - CloseHandle(token); + memcpy(buffer, pwd.homedir, len + 1); + *size = len; + uv_os_free_passwd(&pwd); + + return 0; +} -convert_buffer: + +int uv_os_tmpdir(char* buffer, size_t* size) { + wchar_t path[MAX_PATH + 1]; + DWORD bufsize; + size_t len; + + if (buffer == NULL || size == NULL || *size == 0) + return UV_EINVAL; + + len = GetTempPathW(MAX_PATH + 1, path); + + if (len == 0) { + return uv_translate_sys_error(GetLastError()); + } else if (len > MAX_PATH + 1) { + /* This should not be possible */ + return UV_EIO; + } + + /* The returned directory should not have a trailing slash, unless it */ + /* points at a drive root, like c:\. Remove it if needed.*/ + if (path[len - 1] == L'\\' && + !(len == 3 && path[1] == L':')) { + len--; + path[len] = L'\0'; + } /* Check how much space we need */ - bufsize = uv_utf16_to_utf8(path, -1, NULL, 0); + bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL); + if (bufsize == 0) { return uv_translate_sys_error(GetLastError()); } else if (bufsize > *size) { - *size = bufsize - 1; + *size = bufsize; return UV_ENOBUFS; } /* Convert to UTF-8 */ - bufsize = uv_utf16_to_utf8(path, -1, buffer, *size); + bufsize = WideCharToMultiByte(CP_UTF8, + 0, + path, + -1, + buffer, + *size, + NULL, + NULL); + if (bufsize == 0) return uv_translate_sys_error(GetLastError()); *size = bufsize - 1; return 0; } + + +void uv_os_free_passwd(uv_passwd_t* pwd) { + if (pwd == NULL) + return; + + uv__free(pwd->username); + uv__free(pwd->homedir); + pwd->username = NULL; + pwd->homedir = NULL; +} + + +int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8) { + DWORD bufsize; + + if (utf16 == NULL) + return UV_EINVAL; + + /* Check how much space we need */ + bufsize = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL); + + if (bufsize == 0) + return uv_translate_sys_error(GetLastError()); + + /* Allocate the destination buffer */ + *utf8 = uv__malloc(bufsize); + + if (*utf8 == NULL) + return UV_ENOMEM; + + /* Convert to UTF-8 */ + bufsize = WideCharToMultiByte(CP_UTF8, + 0, + utf16, + -1, + *utf8, + bufsize, + NULL, + NULL); + + if (bufsize == 0) { + uv__free(*utf8); + return uv_translate_sys_error(GetLastError()); + } + + return 0; +} + + +int uv__getpwuid_r(uv_passwd_t* pwd) { + HANDLE token; + wchar_t username[UNLEN + 1]; + wchar_t path[MAX_PATH]; + DWORD bufsize; + int r; + + if (pwd == NULL) + return UV_EINVAL; + + /* Get the home directory using GetUserProfileDirectoryW() */ + if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0) + return uv_translate_sys_error(GetLastError()); + + bufsize = sizeof(path); + if (!GetUserProfileDirectoryW(token, path, &bufsize)) { + r = GetLastError(); + CloseHandle(token); + + /* This should not be possible */ + if (r == ERROR_INSUFFICIENT_BUFFER) + return UV_ENOMEM; + + return uv_translate_sys_error(r); + } + + CloseHandle(token); + + /* Get the username using GetUserNameW() */ + bufsize = sizeof(username); + if (!GetUserNameW(username, &bufsize)) { + r = GetLastError(); + + /* This should not be possible */ + if (r == ERROR_INSUFFICIENT_BUFFER) + return UV_ENOMEM; + + return uv_translate_sys_error(r); + } + + pwd->homedir = NULL; + r = uv__convert_utf16_to_utf8(path, &pwd->homedir); + + if (r != 0) + return r; + + pwd->username = NULL; + r = uv__convert_utf16_to_utf8(username, &pwd->username); + + if (r != 0) { + uv__free(pwd->homedir); + return r; + } + + pwd->shell = NULL; + pwd->uid = -1; + pwd->gid = -1; + + return 0; +} + + +int uv_os_get_passwd(uv_passwd_t* pwd) { + return uv__getpwuid_r(pwd); +} diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 2264d1e89d5fae..2405fa878c0805 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -226,7 +226,7 @@ int process_wait(process_info_t* vec, int n, int timeout) { tv = timebase; for (;;) { /* Check that gettimeofday() doesn't jump back in time. */ - assert(tv.tv_sec == timebase.tv_sec || + assert(tv.tv_sec > timebase.tv_sec || (tv.tv_sec == timebase.tv_sec && tv.tv_usec >= timebase.tv_usec)); elapsed_ms = diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index d18c1daa364702..96cc6377cb1fa6 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -108,10 +108,10 @@ typedef enum { /* This macro cleans up the main loop. This is used to avoid valgrind * warnings about memory being "leaked" by the main event loop. */ -#define MAKE_VALGRIND_HAPPY() \ - do { \ - close_loop(uv_default_loop()); \ - uv_loop_delete(uv_default_loop()); \ +#define MAKE_VALGRIND_HAPPY() \ + do { \ + close_loop(uv_default_loop()); \ + ASSERT(0 == uv_loop_close(uv_default_loop())); \ } while (0) /* Just sugar for wrapping the main() for a task or helper. */ @@ -207,7 +207,7 @@ UNUSED static int can_ipv6(void) { int i; if (uv_interface_addresses(&addr, &count)) - return 1; /* Assume IPv6 support on failure. */ + return 0; /* Assume no IPv6 support on failure. */ supported = 0; for (i = 0; supported == 0 && i < count; i += 1) diff --git a/deps/uv/test/test-condvar.c b/deps/uv/test/test-condvar.c index dbacdba384d158..83b28494adbb3f 100644 --- a/deps/uv/test/test-condvar.c +++ b/deps/uv/test/test-condvar.c @@ -25,24 +25,33 @@ #include #include -typedef struct { +typedef struct worker_config { uv_mutex_t mutex; uv_cond_t cond; - int delay; + int signal_delay; + int wait_delay; int use_broadcast; - volatile int posted; + volatile int posted_1; + volatile int posted_2; + void (*signal_cond)(struct worker_config* c, volatile int* flag); + void (*wait_cond)(struct worker_config* c, const volatile int* flag); } worker_config; static void worker(void* arg) { worker_config* c = arg; + c->signal_cond(c, &c->posted_1); + c->wait_cond(c, &c->posted_2); +} + - if (c->delay) - uv_sleep(c->delay); +static void condvar_signal(worker_config* c, volatile int* flag) { + if (c->signal_delay) + uv_sleep(c->signal_delay); uv_mutex_lock(&c->mutex); - ASSERT(c->posted == 0); - c->posted = 1; + ASSERT(*flag == 0); + *flag = 1; if (c->use_broadcast) uv_cond_broadcast(&c->cond); else @@ -51,21 +60,33 @@ static void worker(void* arg) { } +static void condvar_wait(worker_config* c, const volatile int* flag) { + uv_mutex_lock(&c->mutex); + if (c->wait_delay) + uv_sleep(c->wait_delay); + while (*flag == 0) { + uv_cond_wait(&c->cond, &c->mutex); + } + ASSERT(*flag == 1); + uv_mutex_unlock(&c->mutex); +} + + TEST_IMPL(condvar_1) { uv_thread_t thread; worker_config wc; memset(&wc, 0, sizeof(wc)); + wc.wait_delay = 100; + wc.signal_cond = condvar_signal; + wc.wait_cond = condvar_wait; ASSERT(0 == uv_cond_init(&wc.cond)); ASSERT(0 == uv_mutex_init(&wc.mutex)); ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - uv_mutex_lock(&wc.mutex); - uv_sleep(100); - uv_cond_wait(&wc.cond, &wc.mutex); - ASSERT(wc.posted == 1); - uv_mutex_unlock(&wc.mutex); + wc.wait_cond(&wc, &wc.posted_1); + wc.signal_cond(&wc, &wc.posted_2); ASSERT(0 == uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); @@ -80,15 +101,16 @@ TEST_IMPL(condvar_2) { worker_config wc; memset(&wc, 0, sizeof(wc)); - wc.delay = 100; + wc.signal_delay = 100; + wc.signal_cond = condvar_signal; + wc.wait_cond = condvar_wait; ASSERT(0 == uv_cond_init(&wc.cond)); ASSERT(0 == uv_mutex_init(&wc.mutex)); ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - uv_mutex_lock(&wc.mutex); - uv_cond_wait(&wc.cond, &wc.mutex); - uv_mutex_unlock(&wc.mutex); + wc.wait_cond(&wc, &wc.posted_1); + wc.signal_cond(&wc, &wc.posted_2); ASSERT(0 == uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); @@ -98,22 +120,35 @@ TEST_IMPL(condvar_2) { } +static void condvar_timedwait(worker_config* c, const volatile int* flag) { + int r; + + uv_mutex_lock(&c->mutex); + if (c->wait_delay) + uv_sleep(c->wait_delay); + while (*flag == 0) { + r = uv_cond_timedwait(&c->cond, &c->mutex, (uint64_t)(150 * 1e6)); + ASSERT(r == 0); + } + uv_mutex_unlock(&c->mutex); +} + + TEST_IMPL(condvar_3) { uv_thread_t thread; worker_config wc; - int r; memset(&wc, 0, sizeof(wc)); - wc.delay = 100; + wc.signal_delay = 100; + wc.signal_cond = condvar_signal; + wc.wait_cond = condvar_timedwait; ASSERT(0 == uv_cond_init(&wc.cond)); ASSERT(0 == uv_mutex_init(&wc.mutex)); ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - uv_mutex_lock(&wc.mutex); - r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(50 * 1e6)); - ASSERT(r == UV_ETIMEDOUT); - uv_mutex_unlock(&wc.mutex); + wc.wait_cond(&wc, &wc.posted_1); + wc.signal_cond(&wc, &wc.posted_2); ASSERT(0 == uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); @@ -126,19 +161,18 @@ TEST_IMPL(condvar_3) { TEST_IMPL(condvar_4) { uv_thread_t thread; worker_config wc; - int r; memset(&wc, 0, sizeof(wc)); - wc.delay = 100; + wc.signal_delay = 100; + wc.signal_cond = condvar_signal; + wc.wait_cond = condvar_timedwait; ASSERT(0 == uv_cond_init(&wc.cond)); ASSERT(0 == uv_mutex_init(&wc.mutex)); ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - uv_mutex_lock(&wc.mutex); - r = uv_cond_timedwait(&wc.cond, &wc.mutex, (uint64_t)(150 * 1e6)); - ASSERT(r == 0); - uv_mutex_unlock(&wc.mutex); + wc.wait_cond(&wc, &wc.posted_1); + wc.signal_cond(&wc, &wc.posted_2); ASSERT(0 == uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); @@ -154,16 +188,16 @@ TEST_IMPL(condvar_5) { memset(&wc, 0, sizeof(wc)); wc.use_broadcast = 1; + wc.signal_delay = 100; + wc.signal_cond = condvar_signal; + wc.wait_cond = condvar_wait; ASSERT(0 == uv_cond_init(&wc.cond)); ASSERT(0 == uv_mutex_init(&wc.mutex)); ASSERT(0 == uv_thread_create(&thread, worker, &wc)); - uv_mutex_lock(&wc.mutex); - uv_sleep(100); - uv_cond_wait(&wc.cond, &wc.mutex); - ASSERT(wc.posted == 1); - uv_mutex_unlock(&wc.mutex); + wc.wait_cond(&wc, &wc.posted_1); + wc.signal_cond(&wc, &wc.posted_2); ASSERT(0 == uv_thread_join(&thread)); uv_mutex_destroy(&wc.mutex); diff --git a/deps/uv/test/test-eintr-handling.c b/deps/uv/test/test-eintr-handling.c new file mode 100644 index 00000000000000..1aaf623b789b6e --- /dev/null +++ b/deps/uv/test/test-eintr-handling.c @@ -0,0 +1,94 @@ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +#ifdef _WIN32 + +TEST_IMPL(eintr_handling) { + RETURN_SKIP("Test not implemented on Windows."); +} + +#else /* !_WIN32 */ + +#include +#include + +static uv_loop_t* loop; +static uv_fs_t read_req; +static uv_buf_t iov; + +static char buf[32]; +static char test_buf[] = "test-buffer\n"; +int pipe_fds[2]; + +struct thread_ctx { + uv_barrier_t barrier; + int fd; +}; + +static void thread_main(void* arg) { + int nwritten; + ASSERT(0 == kill(getpid(), SIGUSR1)); + + do + nwritten = write(pipe_fds[1], test_buf, sizeof(test_buf)); + while (nwritten == -1 && errno == EINTR); + + ASSERT(nwritten == sizeof(test_buf)); +} + +static void sig_func(uv_signal_t* handle, int signum) { + uv_signal_stop(handle); +} + +TEST_IMPL(eintr_handling) { + struct thread_ctx ctx; + uv_thread_t thread; + uv_signal_t signal; + int nread; + + iov = uv_buf_init(buf, sizeof(buf)); + loop = uv_default_loop(); + + ASSERT(0 == uv_signal_init(loop, &signal)); + ASSERT(0 == uv_signal_start(&signal, sig_func, SIGUSR1)); + + ASSERT(0 == pipe(pipe_fds)); + ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx)); + + nread = uv_fs_read(loop, &read_req, pipe_fds[0], &iov, 1, -1, NULL); + + ASSERT(nread == sizeof(test_buf)); + ASSERT(0 == strcmp(buf, test_buf)); + + ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); + + ASSERT(0 == close(pipe_fds[0])); + ASSERT(0 == close(pipe_fds[1])); + uv_close((uv_handle_t*) &signal, NULL); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + +#endif /* !_WIN32 */ diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index e02ff2fda5e5d9..35583529e57507 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -531,6 +531,33 @@ TEST_IMPL(fs_event_watch_file_current_dir) { return 0; } +#ifdef _WIN32 +TEST_IMPL(fs_event_watch_file_root_dir) { + uv_loop_t* loop; + int r; + + const char* sys_drive = getenv("SystemDrive"); + char path[] = "\\\\?\\X:\\bootsect.bak"; + + ASSERT(sys_drive != NULL); + strncpy(path + sizeof("\\\\?\\") - 1, sys_drive, 1); + + loop = uv_default_loop(); + + r = uv_fs_event_init(loop, &fs_event); + ASSERT(r == 0); + r = uv_fs_event_start(&fs_event, fail_cb, path, 0); + if (r == UV_ENOENT) + RETURN_SKIP("bootsect.bak doesn't exist in system root.\n"); + ASSERT(r == 0); + + uv_close((uv_handle_t*) &fs_event, NULL); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif + TEST_IMPL(fs_event_no_callback_after_close) { uv_loop_t* loop = uv_default_loop(); int r; @@ -792,6 +819,7 @@ TEST_IMPL(fs_event_getpath) { r = uv_fs_event_getpath(&fs_event, buf, &len); ASSERT(r == 0); ASSERT(buf[len - 1] != 0); + ASSERT(buf[len] == '\0'); ASSERT(memcmp(buf, "watch_dir", len) == 0); r = uv_fs_event_stop(&fs_event); ASSERT(r == 0); diff --git a/deps/uv/test/test-fs-poll.c b/deps/uv/test/test-fs-poll.c index dbc1515b0b1b93..737d50dfd26937 100644 --- a/deps/uv/test/test-fs-poll.c +++ b/deps/uv/test/test-fs-poll.c @@ -173,6 +173,7 @@ TEST_IMPL(fs_poll_getpath) { len = sizeof buf; ASSERT(0 == uv_fs_poll_getpath(&poll_handle, buf, &len)); ASSERT(buf[len - 1] != 0); + ASSERT(buf[len] == '\0'); ASSERT(0 == memcmp(buf, FIXTURE, len)); uv_close((uv_handle_t*) &poll_handle, close_cb); diff --git a/deps/uv/test/test-get-passwd.c b/deps/uv/test/test-get-passwd.c new file mode 100644 index 00000000000000..58d9c73c691cf3 --- /dev/null +++ b/deps/uv/test/test-get-passwd.c @@ -0,0 +1,80 @@ +/* Copyright libuv contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" +#include + +TEST_IMPL(get_passwd) { + uv_passwd_t pwd; + size_t len; + int r; + + /* Test the normal case */ + r = uv_os_get_passwd(&pwd); + ASSERT(r == 0); + len = strlen(pwd.username); + ASSERT(len > 0); + +#ifdef _WIN32 + ASSERT(pwd.shell == NULL); +#else + len = strlen(pwd.shell); + ASSERT(len > 0); +#endif + + len = strlen(pwd.homedir); + ASSERT(len > 0); + +#ifdef _WIN32 + ASSERT(pwd.homedir[len - 1] != '\\'); +#else + ASSERT(pwd.homedir[len - 1] != '/'); +#endif + +#ifdef _WIN32 + ASSERT(pwd.uid == -1); + ASSERT(pwd.gid == -1); +#else + ASSERT(pwd.uid >= 0); + ASSERT(pwd.gid >= 0); +#endif + + /* Test uv_os_free_passwd() */ + uv_os_free_passwd(&pwd); + + ASSERT(pwd.username == NULL); + ASSERT(pwd.shell == NULL); + ASSERT(pwd.homedir == NULL); + + /* Test a double free */ + uv_os_free_passwd(&pwd); + + ASSERT(pwd.username == NULL); + ASSERT(pwd.shell == NULL); + ASSERT(pwd.homedir == NULL); + + /* Test invalid input */ + r = uv_os_get_passwd(NULL); + ASSERT(r == UV_EINVAL); + + return 0; +} diff --git a/deps/uv/test/test-homedir.c b/deps/uv/test/test-homedir.c index cbc47566c55e42..5027d44c1ea358 100644 --- a/deps/uv/test/test-homedir.c +++ b/deps/uv/test/test-homedir.c @@ -1,3 +1,24 @@ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + #include "uv.h" #include "task.h" #include diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 858a20af49c291..8b10f1a5f68507 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -44,6 +44,7 @@ TEST_DECLARE (semaphore_2) TEST_DECLARE (semaphore_3) TEST_DECLARE (tty) TEST_DECLARE (tty_file) +TEST_DECLARE (tty_pty) TEST_DECLARE (stdio_over_pipes) TEST_DECLARE (ip6_pton) TEST_DECLARE (ipc_listen_before_write) @@ -154,6 +155,7 @@ TEST_DECLARE (timer_huge_repeat) TEST_DECLARE (timer_run_once) TEST_DECLARE (timer_from_check) TEST_DECLARE (timer_null_callback) +TEST_DECLARE (timer_early_check) TEST_DECLARE (idle_starvation) TEST_DECLARE (loop_handles) TEST_DECLARE (get_loadavg) @@ -191,12 +193,15 @@ TEST_DECLARE (active) TEST_DECLARE (embed) TEST_DECLARE (async) TEST_DECLARE (async_null_cb) +TEST_DECLARE (eintr_handling) TEST_DECLARE (get_currentexe) TEST_DECLARE (process_title) TEST_DECLARE (cwd_and_chdir) TEST_DECLARE (get_memory) +TEST_DECLARE (get_passwd) TEST_DECLARE (handle_fileno) TEST_DECLARE (homedir) +TEST_DECLARE (tmpdir) TEST_DECLARE (hrtime) TEST_DECLARE (getaddrinfo_fail) TEST_DECLARE (getaddrinfo_fail_sync) @@ -267,6 +272,9 @@ TEST_DECLARE (fs_event_watch_dir_recursive) TEST_DECLARE (fs_event_watch_file) TEST_DECLARE (fs_event_watch_file_twice) TEST_DECLARE (fs_event_watch_file_current_dir) +#ifdef _WIN32 +TEST_DECLARE (fs_event_watch_file_root_dir) +#endif TEST_DECLARE (fs_event_no_callback_after_close) TEST_DECLARE (fs_event_no_callback_on_close) TEST_DECLARE (fs_event_immediate_close) @@ -292,6 +300,7 @@ TEST_DECLARE (threadpool_cancel_work) TEST_DECLARE (threadpool_cancel_fs) TEST_DECLARE (threadpool_cancel_single) TEST_DECLARE (thread_local_storage) +TEST_DECLARE (thread_stack_size) TEST_DECLARE (thread_mutex) TEST_DECLARE (thread_rwlock) TEST_DECLARE (thread_rwlock_trylock) @@ -301,6 +310,7 @@ TEST_DECLARE (dlerror) TEST_DECLARE (poll_duplex) TEST_DECLARE (poll_unidirectional) TEST_DECLARE (poll_close) +TEST_DECLARE (poll_bad_fdtype) TEST_DECLARE (ip4_addr) TEST_DECLARE (ip6_addr_link_local) @@ -378,6 +388,7 @@ TASK_LIST_START TEST_ENTRY (pipe_set_non_blocking) TEST_ENTRY (tty) TEST_ENTRY (tty_file) + TEST_ENTRY (tty_pty) TEST_ENTRY (stdio_over_pipes) TEST_ENTRY (ip6_pton) TEST_ENTRY (ipc_listen_before_write) @@ -522,6 +533,7 @@ TASK_LIST_START TEST_ENTRY (timer_run_once) TEST_ENTRY (timer_from_check) TEST_ENTRY (timer_null_callback) + TEST_ENTRY (timer_early_check) TEST_ENTRY (idle_starvation) @@ -566,6 +578,7 @@ TASK_LIST_START TEST_ENTRY (async) TEST_ENTRY (async_null_cb) + TEST_ENTRY (eintr_handling) TEST_ENTRY (get_currentexe) @@ -575,12 +588,16 @@ TASK_LIST_START TEST_ENTRY (get_memory) + TEST_ENTRY (get_passwd) + TEST_ENTRY (get_loadavg) TEST_ENTRY (handle_fileno) TEST_ENTRY (homedir) + TEST_ENTRY (tmpdir) + TEST_ENTRY (hrtime) TEST_ENTRY_CUSTOM (getaddrinfo_fail, 0, 0, 10000) @@ -600,6 +617,7 @@ TASK_LIST_START TEST_ENTRY (poll_duplex) TEST_ENTRY (poll_unidirectional) TEST_ENTRY (poll_close) + TEST_ENTRY (poll_bad_fdtype) TEST_ENTRY (socket_buffer_size) @@ -688,6 +706,9 @@ TASK_LIST_START TEST_ENTRY (fs_event_watch_file) TEST_ENTRY (fs_event_watch_file_twice) TEST_ENTRY (fs_event_watch_file_current_dir) +#ifdef _WIN32 + TEST_ENTRY (fs_event_watch_file_root_dir) +#endif TEST_ENTRY (fs_event_no_callback_after_close) TEST_ENTRY (fs_event_no_callback_on_close) TEST_ENTRY (fs_event_immediate_close) @@ -706,13 +727,21 @@ TASK_LIST_START TEST_ENTRY (fs_read_write_null_arguments) TEST_ENTRY (threadpool_queue_work_simple) TEST_ENTRY (threadpool_queue_work_einval) +#if defined(__PPC__) || defined(__PPC64__) /* For linux PPC and AIX */ + /* pthread_join takes a while, especially on AIX. + * Therefore being gratuitous with timeout. + */ + TEST_ENTRY_CUSTOM (threadpool_multiple_event_loops, 0, 0, 120000) +#else TEST_ENTRY (threadpool_multiple_event_loops) +#endif TEST_ENTRY (threadpool_cancel_getaddrinfo) TEST_ENTRY (threadpool_cancel_getnameinfo) TEST_ENTRY (threadpool_cancel_work) TEST_ENTRY (threadpool_cancel_fs) TEST_ENTRY (threadpool_cancel_single) TEST_ENTRY (thread_local_storage) + TEST_ENTRY (thread_stack_size) TEST_ENTRY (thread_mutex) TEST_ENTRY (thread_rwlock) TEST_ENTRY (thread_rwlock_trylock) diff --git a/deps/uv/test/test-pipe-close-stdout-read-stdin.c b/deps/uv/test/test-pipe-close-stdout-read-stdin.c index ee8bb2a9a8bc38..4ab14789a3858b 100644 --- a/deps/uv/test/test-pipe-close-stdout-read-stdin.c +++ b/deps/uv/test/test-pipe-close-stdout-read-stdin.c @@ -53,6 +53,7 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { int pid; int fd[2]; int status; + char buf; uv_pipe_t stdin_pipe; r = pipe(fd); @@ -64,6 +65,8 @@ TEST_IMPL(pipe_close_stdout_read_stdin) { * The write side will be closed by the parent process. */ close(fd[1]); + /* block until write end of pipe is closed */ + read(fd[0], &buf, 1); close(0); r = dup(fd[0]); ASSERT(r != -1); diff --git a/deps/uv/test/test-pipe-getsockname.c b/deps/uv/test/test-pipe-getsockname.c index 5e036f9d528a58..58041c02668271 100644 --- a/deps/uv/test/test-pipe-getsockname.c +++ b/deps/uv/test/test-pipe-getsockname.c @@ -114,6 +114,7 @@ TEST_IMPL(pipe_getsockname) { ASSERT(r == 0); ASSERT(buf[len - 1] != 0); + ASSERT(buf[len] == '\0'); ASSERT(memcmp(buf, TEST_PIPENAME, len) == 0); len = sizeof buf; diff --git a/deps/uv/test/test-platform-output.c b/deps/uv/test/test-platform-output.c index 76495e14fd87c3..2c4740550a198c 100644 --- a/deps/uv/test/test-platform-output.c +++ b/deps/uv/test/test-platform-output.c @@ -32,6 +32,7 @@ TEST_IMPL(platform_output) { uv_rusage_t rusage; uv_cpu_info_t* cpus; uv_interface_address_t* interfaces; + uv_passwd_t pwd; int count; int i; int err; @@ -122,5 +123,15 @@ TEST_IMPL(platform_output) { } uv_free_interface_addresses(interfaces, count); + err = uv_os_get_passwd(&pwd); + ASSERT(err == 0); + + printf("uv_os_get_passwd:\n"); + printf(" euid: %ld\n", pwd.uid); + printf(" gid: %ld\n", pwd.gid); + printf(" username: %s\n", pwd.username); + printf(" shell: %s\n", pwd.shell); + printf(" home directory: %s\n", pwd.homedir); + return 0; } diff --git a/deps/uv/test/test-poll.c b/deps/uv/test/test-poll.c index be8b00c32ca99b..bfb75af13355ab 100644 --- a/deps/uv/test/test-poll.c +++ b/deps/uv/test/test-poll.c @@ -21,7 +21,9 @@ #include -#ifndef _WIN32 +#ifdef _WIN32 +# include +#else # include # include #endif @@ -49,7 +51,7 @@ typedef struct connection_context_s { size_t read, sent; int is_server_connection; int open_handles; - int got_fin, sent_fin; + int got_fin, sent_fin, got_disconnect; unsigned int events, delayed_events; } connection_context_t; @@ -70,6 +72,8 @@ static int closed_connections = 0; static int valid_writable_wakeups = 0; static int spurious_writable_wakeups = 0; +static int disconnects = 0; + static int got_eagain(void) { #ifdef _WIN32 @@ -140,6 +144,7 @@ static connection_context_t* create_connection_context( context->delayed_events = 0; context->got_fin = 0; context->sent_fin = 0; + context->got_disconnect = 0; r = uv_poll_init_socket(uv_default_loop(), &context->poll_handle, sock); context->open_handles++; @@ -373,7 +378,13 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { } } - if (context->got_fin && context->sent_fin) { + if (events & UV_DISCONNECT) { + context->got_disconnect = 1; + ++disconnects; + new_events &= ~UV_DISCONNECT; + } + + if (context->got_fin && context->sent_fin && context->got_disconnect) { /* Sent and received FIN. Close and destroy context. */ close_socket(context->sock); destroy_connection_context(context); @@ -461,9 +472,9 @@ static void server_poll_cb(uv_poll_t* handle, int status, int events) { #endif connection_context = create_connection_context(sock, 1); - connection_context->events = UV_READABLE | UV_WRITABLE; + connection_context->events = UV_READABLE | UV_WRITABLE | UV_DISCONNECT; r = uv_poll_start(&connection_context->poll_handle, - UV_READABLE | UV_WRITABLE, + UV_READABLE | UV_WRITABLE | UV_DISCONNECT, connection_poll_cb); ASSERT(r == 0); @@ -505,9 +516,9 @@ static void start_client(void) { sock = create_bound_socket(addr); context = create_connection_context(sock, 0); - context->events = UV_READABLE | UV_WRITABLE; + context->events = UV_READABLE | UV_WRITABLE | UV_DISCONNECT; r = uv_poll_start(&context->poll_handle, - UV_READABLE | UV_WRITABLE, + UV_READABLE | UV_WRITABLE | UV_DISCONNECT, connection_poll_cb); ASSERT(r == 0); @@ -541,6 +552,7 @@ static void start_poll_test(void) { spurious_writable_wakeups > 20); ASSERT(closed_connections == NUM_CLIENTS * 2); + ASSERT(disconnects == NUM_CLIENTS * 2); MAKE_VALGRIND_HAPPY(); } @@ -558,3 +570,29 @@ TEST_IMPL(poll_unidirectional) { start_poll_test(); return 0; } + + +/* Windows won't let you open a directory so we open a file instead. + * OS X lets you poll a file so open the $PWD instead. Both fail + * on Linux so it doesn't matter which one we pick. Both succeed + * on FreeBSD, Solaris and AIX so skip the test on those platforms. + */ +TEST_IMPL(poll_bad_fdtype) { +#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__sun) && \ + !defined(_AIX) + uv_poll_t poll_handle; + int fd; + +#if defined(_WIN32) + fd = open("test/fixtures/empty_file", O_RDONLY); +#else + fd = open(".", O_RDONLY); +#endif + ASSERT(fd != -1); + ASSERT(0 != uv_poll_init(uv_default_loop(), &poll_handle, fd)); + ASSERT(0 == close(fd)); +#endif + + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/deps/uv/test/test-tcp-close-while-connecting.c b/deps/uv/test/test-tcp-close-while-connecting.c index 2c39b652b61078..60df7a574409aa 100644 --- a/deps/uv/test/test-tcp-close-while-connecting.c +++ b/deps/uv/test/test-tcp-close-while-connecting.c @@ -72,7 +72,7 @@ TEST_IMPL(tcp_close_while_connecting) { RETURN_SKIP("Network unreachable."); ASSERT(r == 0); ASSERT(0 == uv_timer_init(loop, &timer1_handle)); - ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 50, 0)); + ASSERT(0 == uv_timer_start(&timer1_handle, timer1_cb, 1, 0)); ASSERT(0 == uv_timer_init(loop, &timer2_handle)); ASSERT(0 == uv_timer_start(&timer2_handle, timer2_cb, 86400 * 1000, 0)); ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); diff --git a/deps/uv/test/test-thread.c b/deps/uv/test/test-thread.c index 7f3321aa06d2c0..10bec3fe6c6587 100644 --- a/deps/uv/test/test-thread.c +++ b/deps/uv/test/test-thread.c @@ -209,3 +209,24 @@ TEST_IMPL(thread_local_storage) { uv_key_delete(&tls_key); return 0; } + + +#if defined(__APPLE__) +static void thread_check_stack(void* arg) { + /* 512KB is the default stack size of threads other than the main thread + * on OSX. */ + ASSERT(pthread_get_stacksize_np(pthread_self()) > 512*1024); +} +#endif + + +TEST_IMPL(thread_stack_size) { +#if defined(__APPLE__) + uv_thread_t thread; + ASSERT(0 == uv_thread_create(&thread, thread_check_stack, NULL)); + ASSERT(0 == uv_thread_join(&thread)); + return 0; +#else + RETURN_SKIP("OSX only test"); +#endif +} diff --git a/deps/uv/test/test-timer.c b/deps/uv/test/test-timer.c index aba050fd64c72a..080a73005ee3c2 100644 --- a/deps/uv/test/test-timer.c +++ b/deps/uv/test/test-timer.c @@ -301,3 +301,30 @@ TEST_IMPL(timer_null_callback) { MAKE_VALGRIND_HAPPY(); return 0; } + + +static uint64_t timer_early_check_expected_time; + + +static void timer_early_check_cb(uv_timer_t* handle) { + uint64_t hrtime = uv_hrtime() / 1000000; + ASSERT(hrtime >= timer_early_check_expected_time); +} + + +TEST_IMPL(timer_early_check) { + uv_timer_t timer_handle; + const uint64_t timeout_ms = 10; + + timer_early_check_expected_time = uv_now(uv_default_loop()) + timeout_ms; + + ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle)); + ASSERT(0 == uv_timer_start(&timer_handle, timer_early_check_cb, timeout_ms, 0)); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + uv_close((uv_handle_t*) &timer_handle, NULL); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/deps/uv/test/test-tmpdir.c b/deps/uv/test/test-tmpdir.c new file mode 100644 index 00000000000000..29e8055f1d5d91 --- /dev/null +++ b/deps/uv/test/test-tmpdir.c @@ -0,0 +1,71 @@ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" +#include + +#define PATHMAX 1024 +#define SMALLPATH 1 + +TEST_IMPL(tmpdir) { + char tmpdir[PATHMAX]; + size_t len; + char last; + int r; + + /* Test the normal case */ + len = sizeof tmpdir; + tmpdir[0] = '\0'; + + ASSERT(strlen(tmpdir) == 0); + r = uv_os_tmpdir(tmpdir, &len); + ASSERT(r == 0); + ASSERT(strlen(tmpdir) == len); + ASSERT(len > 0); + ASSERT(tmpdir[len] == '\0'); + + if (len > 1) { + last = tmpdir[len - 1]; +#ifdef _WIN32 + ASSERT(last != '\\'); +#else + ASSERT(last != '/'); +#endif + } + + /* Test the case where the buffer is too small */ + len = SMALLPATH; + r = uv_os_tmpdir(tmpdir, &len); + ASSERT(r == UV_ENOBUFS); + ASSERT(len > SMALLPATH); + + /* Test invalid inputs */ + r = uv_os_tmpdir(NULL, &len); + ASSERT(r == UV_EINVAL); + r = uv_os_tmpdir(tmpdir, NULL); + ASSERT(r == UV_EINVAL); + len = 0; + r = uv_os_tmpdir(tmpdir, &len); + ASSERT(r == UV_EINVAL); + + return 0; +} diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index b844959d526340..461d1941359018 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -28,6 +28,13 @@ #else /* Unix */ # include # include +# if defined(__linux__) +# include +# elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +# include +# elif defined(__FreeBSD__) || defined(__DragonFly__) +# include +# endif #endif #include @@ -182,3 +189,35 @@ TEST_IMPL(tty_file) { #endif return 0; } + +TEST_IMPL(tty_pty) { +# if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) + int master_fd, slave_fd; + struct winsize w; + uv_loop_t loop; + uv_tty_t master_tty, slave_tty; + + ASSERT(0 == uv_loop_init(&loop)); + + ASSERT(0 == openpty(&master_fd, &slave_fd, NULL, NULL, &w)); + ASSERT(0 == uv_tty_init(&loop, &slave_tty, slave_fd, 0)); + ASSERT(0 == uv_tty_init(&loop, &master_tty, master_fd, 0)); + /* Check if the file descriptor was reopened. If it is, + * UV_STREAM_BLOCKING (value 0x80) isn't set on flags. + */ + ASSERT(0 == (slave_tty.flags & 0x80)); + /* The master_fd of a pty should never be reopened. + */ + ASSERT(master_tty.flags & 0x80); + ASSERT(0 == close(slave_fd)); + uv_close((uv_handle_t*) &slave_tty, NULL); + ASSERT(0 == close(master_fd)); + uv_close((uv_handle_t*) &master_tty, NULL); + + ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + + MAKE_VALGRIND_HAPPY(); +#endif + return 0; +} diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 635a234ea6eee8..757540193dd7a2 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -92,6 +92,7 @@ 'src/win/req.c', 'src/win/req-inl.h', 'src/win/signal.c', + 'src/win/snprintf.c', 'src/win/stream.c', 'src/win/stream-inl.h', 'src/win/tcp.c', @@ -104,13 +105,6 @@ 'src/win/winsock.c', 'src/win/winsock.h', ], - 'conditions': [ - ['MSVS_VERSION < "2015"', { - 'sources': [ - 'src/win/snprintf.c' - ] - }] - ], 'link_settings': { 'libraries': [ '-ladvapi32', @@ -247,6 +241,7 @@ '_ALL_SOURCE', '_XOPEN_SOURCE=500', '_LINUX_SOURCE_COMPAT', + '_THREAD_SAFE', ], 'link_settings': { 'libraries': [ @@ -300,6 +295,7 @@ 'test/test-cwd-and-chdir.c', 'test/test-default-loop-close.c', 'test/test-delayed-accept.c', + 'test/test-eintr-handling.c', 'test/test-error.c', 'test/test-embed.c', 'test/test-emfile.c', @@ -308,6 +304,7 @@ 'test/test-fs-event.c', 'test/test-get-currentexe.c', 'test/test-get-memory.c', + 'test/test-get-passwd.c', 'test/test-getaddrinfo.c', 'test/test-getnameinfo.c', 'test/test-getsockname.c', @@ -386,6 +383,7 @@ 'test/test-threadpool.c', 'test/test-threadpool-cancel.c', 'test/test-thread-equal.c', + 'test/test-tmpdir.c', 'test/test-mutexes.c', 'test/test-thread.c', 'test/test-barrier.c', @@ -417,7 +415,8 @@ [ 'OS=="win"', { 'sources': [ 'test/runner-win.c', - 'test/runner-win.h' + 'test/runner-win.h', + 'src/win/snprintf.c', ], 'libraries': [ '-lws2_32' ] }, { # POSIX @@ -427,6 +426,11 @@ 'test/runner-unix.h', ], }], + [ 'OS in "mac dragonflybsd freebsd linux netbsd openbsd".split()', { + 'link_settings': { + 'libraries': [ '-lutil' ], + }, + }], [ 'OS=="solaris"', { # make test-fs.c compile, needs _POSIX_C_SOURCE 'defines': [ '__EXTENSIONS__', @@ -485,6 +489,7 @@ 'sources': [ 'test/runner-win.c', 'test/runner-win.h', + 'src/win/snprintf.c', ], 'libraries': [ '-lws2_32' ] }, { # POSIX diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 696f0db30e15ad..9a7ed4b8c512e0 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -49,6 +49,7 @@ if not defined VS140COMNTOOLS goto vc-set-2013 if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013 call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2015 +echo Using Visual Studio 2015 goto select-target :vc-set-2013 @@ -57,6 +58,7 @@ if not defined VS120COMNTOOLS goto vc-set-2012 if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012 call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2013 +echo Using Visual Studio 2013 goto select-target :vc-set-2012 @@ -65,6 +67,7 @@ if not defined VS110COMNTOOLS goto vc-set-2010 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010 call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2012 +echo Using Visual Studio 2012 goto select-target :vc-set-2010 @@ -73,6 +76,7 @@ if not defined VS100COMNTOOLS goto vc-set-2008 if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008 call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2010 +echo Using Visual Studio 2010 goto select-target :vc-set-2008 @@ -81,6 +85,7 @@ if not defined VS90COMNTOOLS goto vc-set-notfound if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% set GYP_MSVS_VERSION=2008 +echo Using Visual Studio 2008 goto select-target :vc-set-notfound From da7b74b9bc70c06f69e82ec29e80f41ec4ddbb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 17 May 2016 00:25:23 +0200 Subject: [PATCH 055/261] deps: upgrade libuv to 1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/4002 Fixes: https://github.com/nodejs/node/issues/5384 Fixes: https://github.com/nodejs/node/issues/6563 Refs: https://github.com/nodejs/node/issues/2680#issuecomment-213521708 PR-URL: https://github.com/nodejs/node/pull/6796 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Johan Bergström Reviewed-By: Myles Borins --- deps/uv/AUTHORS | 4 + deps/uv/ChangeLog | 89 ++++++++++ deps/uv/Makefile.am | 13 +- deps/uv/Makefile.mingw | 1 + deps/uv/README.md | 5 + deps/uv/android-configure | 4 +- deps/uv/appveyor.yml | 2 +- deps/uv/common.gypi | 7 - deps/uv/configure.ac | 5 +- deps/uv/docs/src/poll.rst | 6 + deps/uv/include/pthread-barrier.h | 64 +++++++ deps/uv/include/uv-unix.h | 21 +-- deps/uv/include/uv-version.h | 2 +- deps/uv/include/uv-win.h | 3 +- deps/uv/src/unix/aix.c | 82 +++++---- deps/uv/src/unix/async.c | 4 +- deps/uv/src/unix/core.c | 10 +- deps/uv/src/unix/freebsd.c | 8 +- deps/uv/src/unix/fs.c | 15 +- deps/uv/src/unix/internal.h | 58 ++----- deps/uv/src/unix/kqueue.c | 38 +++-- deps/uv/src/unix/linux-core.c | 69 +++++--- deps/uv/src/unix/linux-inotify.c | 2 +- deps/uv/src/unix/linux-syscalls.h | 8 - deps/uv/src/unix/openbsd.c | 4 +- deps/uv/src/unix/pipe.c | 4 +- deps/uv/src/unix/poll.c | 14 +- deps/uv/src/unix/pthread-barrier.c | 120 ++++++++++++++ deps/uv/src/unix/pthread-fixes.c | 70 ++------ deps/uv/src/unix/signal.c | 2 +- deps/uv/src/unix/stream.c | 70 ++++---- deps/uv/src/unix/sunos.c | 20 ++- deps/uv/src/unix/tcp.c | 4 +- deps/uv/src/unix/thread.c | 109 +++++------- deps/uv/src/unix/udp.c | 20 +-- deps/uv/src/uv-common.c | 29 +++- deps/uv/src/win/fs-event.c | 61 +++---- deps/uv/src/win/fs.c | 18 +- deps/uv/src/win/internal.h | 3 +- deps/uv/src/win/tty.c | 174 +++++++++++++++----- deps/uv/src/win/util.c | 108 +++++------- deps/uv/test/test-emfile.c | 7 + deps/uv/test/test-fs-event.c | 11 +- deps/uv/test/test-fs.c | 4 + deps/uv/test/test-get-passwd.c | 10 +- deps/uv/test/test-homedir.c | 14 +- deps/uv/test/test-list.h | 6 + deps/uv/test/test-platform-output.c | 5 + deps/uv/test/test-poll.c | 11 +- deps/uv/test/test-tcp-create-socket-early.c | 3 + deps/uv/test/test-tcp-write-queue-order.c | 2 + deps/uv/test/test-tty.c | 69 ++++++++ deps/uv/test/test-udp-create-socket-early.c | 3 + deps/uv/uv.gyp | 7 +- deps/uv/vcbuild.bat | 10 +- 55 files changed, 962 insertions(+), 550 deletions(-) create mode 100644 deps/uv/include/pthread-barrier.h create mode 100644 deps/uv/src/unix/pthread-barrier.c diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 9a9e9c2a2204b8..7acee7c5333388 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -253,3 +253,7 @@ Robert Chiras Kári Tristan Helgason Krishnaraj Bhat Enno Boland +Michael Fero +Robert Jefe Lindstaedt +Myles Borins +Tony Theodore diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index 85d40113e4f052..3f376de6bae6c3 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,92 @@ +2016.05.17, Version 1.9.1 (Stable), d989902ac658b4323a4f4020446e6f4dc449e25c + +Changes since version 1.9.0: + +* test: handle root home directories (cjihrig) + +* unix: implement uv__fs_futime for AIX 7.1 (Imran Iqbal) + +* test: skip early bind tests if no IPv6 is supported (Saúl Ibarra Corretgé) + +* win: fix var declaration to be C89 compliant (Michael Fero) + +* unix: use POLL{IN,OUT,etc} constants directly (Ben Noordhuis) + +* doc: add ability to live reload and regenerate HTML (Saúl Ibarra Corretgé) + +* Revert "win,build: remove unused build defines" (cjihrig) + +* linux: fix fd leaks in uv_cpu_info() error paths (Ben Noordhuis) + +* linux: don't abort on malformed /proc/stat (Ben Noordhuis) + +* linux: fix long lines in linux-core.c (Ben Noordhuis) + +* test: fix fs_event_watch_file_current_dir for AIX (Imran Iqbal) + +* unix,fs: code cleanup of uv_fs_event_start for AIX (Imran Iqbal) + +* unix: delay signal handling until after normal i/o (Ben Noordhuis) + +* android: pthread_sigmask() does not set errno (Oguz Bastemur) + +* win: work around sharepoint scandir bug (Ben Noordhuis) + +* unix: guard against clobbering errno in uv__free() (Ben Noordhuis) + +* unix: remove unneeded SAVE_ERRNO wrappers (Ben Noordhuis) + +* test: skip fs_event_close_in_callback on AIX (Imran Iqbal) + +* win: add maxrss, pagefaults to uv_getrusage() (Robert Jefe Lindstaedt) + +* test: set a big send buffer size for tcp_write_queue_order (Andrius Bentkus) + +* unix: error on realpath if PATH_MAX is undefined (Myles Borins) + +* unix: fix bug in barrier fallback implementation (Kári Tristan Helgason) + +* build: bump android ndk version (Kári Tristan Helgason) + +* build: always compile with -fvisibility=hidden (Ben Noordhuis) + +* test: fix -Wformat warnings in platform test (Ben Noordhuis) + +* win: clarify fsevents handling code (Saúl Ibarra Corretgé) + +* test: fix POLLHDRUP related failures for AIX (Imran Iqbal) + +* build, mingw: set LIBS in configure.ac (Tony Theodore) + +* win: improve uv__convert_utf16_to_utf8 (Saúl Ibarra Corretgé) + +* win: simplified UTF16 -> UTF8 conversions (Saúl Ibarra Corretgé) + +* win: remove unneeded condition (Saúl Ibarra Corretgé) + +* darwin: work around condition variable kernel bug (Ben Noordhuis) + +* darwin: make thread stack multiple of page size (Ben Noordhuis) + +* build,win: rename platform to msbuild_platform (João Reis) + +* gitignore: ignore VS temporary database files (João Reis) + +* test: skip emfile on AIX (Imran Iqbal) + +* unix: use system allocator for scandir() (cjihrig) + +* common: release uv_fs_scandir() array (cjihrig) + +* win: call uv__fs_scandir_cleanup() (cjihrig) + +* win,tty: fix read stop in line mode (João Reis) + +* win,tty: don't duplicate handle for line reads (João Reis) + +* win,tty: restore cursor after canceling line read (Alexis Campailla) + + 2016.04.08, Version 1.9.0 (Stable), 229b3a4cc150aebd6561e6bd43076eafa7a03756 Changes since version 1.8.0: diff --git a/deps/uv/Makefile.am b/deps/uv/Makefile.am index dfd4353a31b649..05ccd58ac9612b 100644 --- a/deps/uv/Makefile.am +++ b/deps/uv/Makefile.am @@ -43,8 +43,8 @@ if WINNT include_HEADERS += include/uv-win.h include/tree.h AM_CPPFLAGS += -I$(top_srcdir)/src/win \ + -DWIN32_LEAN_AND_MEAN \ -D_WIN32_WINNT=0x0600 -LIBS += -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv libuv_la_SOURCES += src/win/async.c \ src/win/atomicops-inl.h \ src/win/core.c \ @@ -290,20 +290,23 @@ endif if ANDROID include_HEADERS += include/android-ifaddrs.h \ - include/pthread-fixes.h + include/pthread-barrier.h libuv_la_SOURCES += src/unix/android-ifaddrs.c \ - src/unix/pthread-fixes.c + src/unix/pthread-fixes.c \ + src/unix/pthread-barrier.c endif if DARWIN -include_HEADERS += include/uv-darwin.h +include_HEADERS += include/uv-darwin.h \ + include/pthread-barrier.h libuv_la_CFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 libuv_la_CFLAGS += -D_DARWIN_UNLIMITED_SELECT=1 libuv_la_SOURCES += src/unix/darwin.c \ src/unix/darwin-proctitle.c \ src/unix/fsevents.c \ src/unix/kqueue.c \ - src/unix/proctitle.c + src/unix/proctitle.c \ + src/unix/pthread-barrier.c test_run_tests_LDFLAGS += -lutil endif diff --git a/deps/uv/Makefile.mingw b/deps/uv/Makefile.mingw index 3130bac473d30c..156f15dab159f1 100644 --- a/deps/uv/Makefile.mingw +++ b/deps/uv/Makefile.mingw @@ -20,6 +20,7 @@ CFLAGS += -Wall \ -Iinclude \ -Isrc \ -Isrc/win \ + -DWIN32_LEAN_AND_MEAN \ -D_WIN32_WINNT=0x0600 INCLUDES = include/stdint-msvc2008.h \ diff --git a/deps/uv/README.md b/deps/uv/README.md index 17304a7ab57125..e94fcc902f9981 100644 --- a/deps/uv/README.md +++ b/deps/uv/README.md @@ -60,6 +60,11 @@ Build documentation as HTML: $ make html +Build documentation as HTML and live reload it when it changes (this requires +sphinx-autobuild to be installed and is only supported on Unix): + + $ make livehtml + Build documentation as man pages: $ make man diff --git a/deps/uv/android-configure b/deps/uv/android-configure index e0b250fb6348e2..7ffc035c1bfbfc 100755 --- a/deps/uv/android-configure +++ b/deps/uv/android-configure @@ -3,7 +3,7 @@ export TOOLCHAIN=$PWD/android-toolchain mkdir -p $TOOLCHAIN $1/build/tools/make-standalone-toolchain.sh \ - --toolchain=arm-linux-androideabi-4.8 \ + --toolchain=arm-linux-androideabi-4.9 \ --arch=arm \ --install-dir=$TOOLCHAIN \ --platform=android-21 @@ -14,7 +14,7 @@ export CXX=arm-linux-androideabi-g++ export LINK=arm-linux-androideabi-g++ export PLATFORM=android -if [ $2 -a $2 == 'gyp' ] +if [[ $2 == 'gyp' ]] then ./gyp_uv.py -Dtarget_arch=arm -DOS=android -f make-android fi diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml index 835730b924c8ff..c7ea736502b2ac 100644 --- a/deps/uv/appveyor.yml +++ b/deps/uv/appveyor.yml @@ -1,4 +1,4 @@ -version: v1.9.0.build{build} +version: v1.9.1.build{build} install: - cinst -y nsis diff --git a/deps/uv/common.gypi b/deps/uv/common.gypi index 7cebcde5f89137..56bca2948db6d9 100644 --- a/deps/uv/common.gypi +++ b/deps/uv/common.gypi @@ -1,6 +1,5 @@ { 'variables': { - 'visibility%': 'hidden', # V8's visibility setting 'target_arch%': 'ia32', # set v8's target architecture 'host_arch%': 'ia32', # set v8's host architecture 'uv_library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds @@ -156,9 +155,6 @@ 'cflags': [ '-pthread' ], 'ldflags': [ '-pthread' ], }], - [ 'visibility=="hidden"', { - 'cflags': [ '-fvisibility=hidden' ], - }], ], }], ['OS=="mac"', { @@ -170,9 +166,6 @@ 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings - # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES', - 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics 'PREBINDING': 'NO', # No -Wl,-prebind 'USE_HEADERMAP': 'NO', diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 2d5a3b9de5eb6d..d9251f31985427 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.9.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.9.1], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) @@ -58,6 +58,9 @@ AM_CONDITIONAL([NETBSD], [AS_CASE([$host_os],[netbsd*], [true], [false]) AM_CONDITIONAL([OPENBSD], [AS_CASE([$host_os],[openbsd*], [true], [false])]) AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])]) AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])]) +AS_CASE([$host_os],[mingw*], [ + LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32" +]) AC_CHECK_HEADERS([sys/ahafs_evProds.h]) AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes) AM_CONDITIONAL([HAVE_PKG_CONFIG], [test "x$PKG_CONFIG" != "x"]) diff --git a/deps/uv/docs/src/poll.rst b/deps/uv/docs/src/poll.rst index 69d45be6d32b29..004ff4b92e5ea5 100644 --- a/deps/uv/docs/src/poll.rst +++ b/deps/uv/docs/src/poll.rst @@ -31,6 +31,8 @@ closed immediately after a call to :c:func:`uv_poll_stop` or :c:func:`uv_close`. On windows only sockets can be polled with poll handles. On Unix any file descriptor that would be accepted by :man:`poll(2)` can be used. +.. note:: + On AIX, watching for disconnection is not supported. Data types ---------- @@ -101,6 +103,10 @@ API Calling :c:func:`uv_poll_start` on a handle that is already active is fine. Doing so will update the events mask that is being watched for. + .. note:: + Though UV_DISCONNECT can be set, it is unsupported on AIX and as such will not be set + on the `events` field in the callback. + .. versionchanged:: 1.9.0 Added the UV_DISCONNECT event. .. c:function:: int uv_poll_stop(uv_poll_t* poll) diff --git a/deps/uv/include/pthread-barrier.h b/deps/uv/include/pthread-barrier.h new file mode 100644 index 00000000000000..084e1c2d556e3e --- /dev/null +++ b/deps/uv/include/pthread-barrier.h @@ -0,0 +1,64 @@ +/* +Copyright (c) 2016, Kari Tristan Helgason + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#ifndef _UV_PTHREAD_BARRIER_ +#define _UV_PTHREAD_BARRIER_ +#include +#include +#include /* sem_t */ + +#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 + +/* + * To maintain ABI compatibility with + * libuv v1.x struct is padded according + * to target platform + */ +#if defined(__ANDROID__) +# define UV_BARRIER_STRUCT_PADDING \ + sizeof(pthread_mutex_t) + \ + sizeof(pthread_cond_t) + \ + sizeof(unsigned int) - \ + sizeof(void *) +#elif defined(__APPLE__) +# define UV_BARRIER_STRUCT_PADDING \ + sizeof(pthread_mutex_t) + \ + 2 * sizeof(sem_t) + \ + 2 * sizeof(unsigned int) - \ + sizeof(void *) +#endif + +typedef struct { + pthread_mutex_t mutex; + pthread_cond_t cond; + unsigned threshold; + unsigned in; + unsigned out; +} _uv_barrier; + +typedef struct { + _uv_barrier* b; + char _pad[UV_BARRIER_STRUCT_PADDING]; +} pthread_barrier_t; + +int pthread_barrier_init(pthread_barrier_t* barrier, + const void* barrier_attr, + unsigned count); + +int pthread_barrier_wait(pthread_barrier_t* barrier); +int pthread_barrier_destroy(pthread_barrier_t *barrier); + +#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/deps/uv/include/uv-unix.h b/deps/uv/include/uv-unix.h index 82d193bdca4fe2..a852c40e49baa5 100644 --- a/deps/uv/include/uv-unix.h +++ b/deps/uv/include/uv-unix.h @@ -38,9 +38,6 @@ #include #include -#ifdef __ANDROID__ -#include "pthread-fixes.h" -#endif #include #include "uv-threadpool.h" @@ -60,6 +57,10 @@ # include "uv-bsd.h" #endif +#ifndef PTHREAD_BARRIER_SERIAL_THREAD +# include "pthread-barrier.h" +#endif + #ifndef NI_MAXHOST # define NI_MAXHOST 1025 #endif @@ -136,22 +137,8 @@ typedef pthread_rwlock_t uv_rwlock_t; typedef UV_PLATFORM_SEM_T uv_sem_t; typedef pthread_cond_t uv_cond_t; typedef pthread_key_t uv_key_t; - -#if defined(__APPLE__) && defined(__MACH__) - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -#else /* defined(__APPLE__) && defined(__MACH__) */ - typedef pthread_barrier_t uv_barrier_t; -#endif /* defined(__APPLE__) && defined(__MACH__) */ /* Platform-specific definitions for uv_spawn support. */ typedef gid_t uv_gid_t; diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index cb666182892dea..08ad0edaa748e0 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -32,7 +32,7 @@ #define UV_VERSION_MAJOR 1 #define UV_VERSION_MINOR 9 -#define UV_VERSION_PATCH 0 +#define UV_VERSION_PATCH 1 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/include/uv-win.h b/deps/uv/include/uv-win.h index 6b537fed0d9019..a75dba8d1c5afa 100644 --- a/deps/uv/include/uv-win.h +++ b/deps/uv/include/uv-win.h @@ -483,7 +483,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); union { \ struct { \ /* Used for readable TTY handles */ \ - HANDLE read_line_handle; \ + /* TODO: remove me in v2.x. */ \ + HANDLE unused_; \ uv_buf_t read_line_buffer; \ HANDLE read_raw_wait; \ /* Fields used for translating win keystrokes into vt100 characters */ \ diff --git a/deps/uv/src/unix/aix.c b/deps/uv/src/unix/aix.c index bcaa5ee50bc203..2276985fc0dd95 100644 --- a/deps/uv/src/unix/aix.c +++ b/deps/uv/src/unix/aix.c @@ -118,6 +118,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { uv__io_t* w; uint64_t base; uint64_t diff; + int have_signals; int nevents; int count; int nfds; @@ -225,6 +226,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { goto update_timeout; } + have_signals = 0; nevents = 0; assert(loop->watchers != NULL); @@ -255,13 +257,26 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { continue; } - w->cb(loop, w, pe->revents); + /* Run signal watchers last. This also affects child process watchers + * because those are implemented in terms of signal watchers. + */ + if (w == &loop->signal_io_watcher) + have_signals = 1; + else + w->cb(loop, w, pe->revents); + nevents++; } + if (have_signals != 0) + loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); + loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; + if (have_signals != 0) + return; /* Event loop should cycle now so don't poll again. */ + if (nevents != 0) { if (nfds == ARRAY_SIZE(events) && --count != 0) { /* Poll for more events but don't block this time. */ @@ -782,53 +797,30 @@ int uv_fs_event_start(uv_fs_event_t* handle, const char* filename, unsigned int flags) { #ifdef HAVE_SYS_AHAFS_EVPRODS_H - int fd, rc, i = 0, res = 0; + int fd, rc, str_offset = 0; char cwd[PATH_MAX]; char absolute_path[PATH_MAX]; - char fname[PATH_MAX]; - char *p; + char readlink_cwd[PATH_MAX]; - /* Clean all the buffers*/ - for(i = 0; i < PATH_MAX; i++) { - cwd[i] = 0; - absolute_path[i] = 0; - fname[i] = 0; - } - i = 0; /* Figure out whether filename is absolute or not */ if (filename[0] == '/') { - /* We have absolute pathname, create the relative pathname*/ - sprintf(absolute_path, filename); - p = strrchr(filename, '/'); - p++; + /* We have absolute pathname */ + snprintf(absolute_path, sizeof(absolute_path), "%s", filename); } else { - if (filename[0] == '.' && filename[1] == '/') { - /* We have a relative pathname, compose the absolute pathname */ - sprintf(fname, filename); - snprintf(cwd, PATH_MAX-1, "/proc/%lu/cwd", (unsigned long) getpid()); - res = readlink(cwd, absolute_path, sizeof(absolute_path) - 1); - if (res < 0) - return res; - p = strrchr(absolute_path, '/'); - p++; - p++; - } else { - /* We have a relative pathname, compose the absolute pathname */ - sprintf(fname, filename); - snprintf(cwd, PATH_MAX-1, "/proc/%lu/cwd", (unsigned long) getpid()); - res = readlink(cwd, absolute_path, sizeof(absolute_path) - 1); - if (res < 0) - return res; - p = strrchr(absolute_path, '/'); - p++; - } - /* Copy to filename buffer */ - while(filename[i] != NULL) { - *p = filename[i]; - i++; - p++; - } + /* We have a relative pathname, compose the absolute pathname */ + snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid()); + rc = readlink(cwd, readlink_cwd, sizeof(readlink_cwd) - 1); + if (rc < 0) + return rc; + /* readlink does not null terminate our string */ + readlink_cwd[rc] = '\0'; + + if (filename[0] == '.' && filename[1] == '/') + str_offset = 2; + + snprintf(absolute_path, sizeof(absolute_path), "%s%s", readlink_cwd, + filename + str_offset); } if (uv__is_ahafs_mounted() < 0) /* /aha checks failed */ @@ -845,7 +837,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, handle->path = uv__strdup(filename); handle->cb = cb; - uv__io_start(handle->loop, &handle->event_watcher, UV__POLLIN); + uv__io_start(handle->loop, &handle->event_watcher, POLLIN); return 0; #else @@ -1036,14 +1028,14 @@ int uv_interface_addresses(uv_interface_address_t** addresses, } if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) { - SAVE_ERRNO(uv__close(sockfd)); + uv__close(sockfd); return -errno; } ifc.ifc_req = (struct ifreq*)uv__malloc(size); ifc.ifc_len = size; if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) { - SAVE_ERRNO(uv__close(sockfd)); + uv__close(sockfd); return -errno; } @@ -1062,7 +1054,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) { - SAVE_ERRNO(uv__close(sockfd)); + uv__close(sockfd); return -errno; } diff --git a/deps/uv/src/unix/async.c b/deps/uv/src/unix/async.c index 184b598126eb2c..393cdebd4ea3fc 100644 --- a/deps/uv/src/unix/async.c +++ b/deps/uv/src/unix/async.c @@ -223,7 +223,7 @@ int uv__async_start(uv_loop_t* loop, struct uv__async* wa, uv__async_cb cb) { return err; uv__io_init(&wa->io_watcher, uv__async_io, pipefd[0]); - uv__io_start(loop, &wa->io_watcher, UV__POLLIN); + uv__io_start(loop, &wa->io_watcher, POLLIN); wa->wfd = pipefd[1]; wa->cb = cb; @@ -241,7 +241,7 @@ void uv__async_stop(uv_loop_t* loop, struct uv__async* wa) { wa->wfd = -1; } - uv__io_stop(loop, &wa->io_watcher, UV__POLLIN); + uv__io_stop(loop, &wa->io_watcher, POLLIN); uv__close(wa->io_watcher.fd); wa->io_watcher.fd = -1; } diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c index 9aaca84187001e..cdcd0b504f32f4 100644 --- a/deps/uv/src/unix/core.c +++ b/deps/uv/src/unix/core.c @@ -762,7 +762,7 @@ static int uv__run_pending(uv_loop_t* loop) { QUEUE_REMOVE(q); QUEUE_INIT(q); w = QUEUE_DATA(q, uv__io_t, pending_queue); - w->cb(loop, w, UV__POLLOUT); + w->cb(loop, w, POLLOUT); } return 1; @@ -833,7 +833,7 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) { void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); + assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP))); assert(0 != events); assert(w->fd >= 0); assert(w->fd < INT_MAX); @@ -866,7 +866,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) { void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); + assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP))); assert(0 != events); if (w->fd == -1) @@ -898,7 +898,7 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) { void uv__io_close(uv_loop_t* loop, uv__io_t* w) { - uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); + uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP); QUEUE_REMOVE(&w->pending_queue); /* Remove stale events for this file descriptor */ @@ -913,7 +913,7 @@ void uv__io_feed(uv_loop_t* loop, uv__io_t* w) { int uv__io_active(const uv__io_t* w, unsigned int events) { - assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP))); + assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP))); assert(0 != events); return 0 != (w->pevents & events); } diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index b747abdf5bc46e..adc95235ceefdf 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -292,7 +292,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { size = sizeof(cpuspeed); if (sysctlbyname("hw.clockrate", &cpuspeed, &size, NULL, 0)) { - SAVE_ERRNO(uv__free(*cpu_infos)); + uv__free(*cpu_infos); return -errno; } @@ -301,7 +301,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { */ size = sizeof(maxcpus); if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) { - SAVE_ERRNO(uv__free(*cpu_infos)); + uv__free(*cpu_infos); return -errno; } @@ -314,8 +314,8 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { } if (sysctlbyname(cptimes_key, cp_times, &size, NULL, 0)) { - SAVE_ERRNO(uv__free(cp_times)); - SAVE_ERRNO(uv__free(*cpu_infos)); + uv__free(cp_times); + uv__free(*cpu_infos); return -errno; } diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 8936ad9d837095..085970a06d9e7b 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -33,6 +33,7 @@ #include #include #include +#include /* PATH_MAX */ #include #include @@ -205,6 +206,13 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { # else return futimes(req->file, tv); # endif +#elif defined(_AIX71) + struct timespec ts[2]; + ts[0].tv_sec = req->atime; + ts[0].tv_nsec = (unsigned long)(req->atime * 1000000) % 1000000 * 1000; + ts[1].tv_sec = req->mtime; + ts[1].tv_nsec = (unsigned long)(req->mtime * 1000000) % 1000000 * 1000; + return futimens(req->file, ts); #else errno = ENOSYS; return -1; @@ -362,9 +370,10 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) { if (dents != NULL) { int i; + /* Memory was allocated using the system allocator, so use free() here. */ for (i = 0; i < n; i++) - uv__free(dents[i]); - uv__free(dents); + free(dents[i]); + free(dents); } errno = saved_errno; @@ -383,7 +392,7 @@ static ssize_t uv__fs_pathmax_size(const char* path) { #if defined(PATH_MAX) return PATH_MAX; #else - return 4096; +#error "PATH_MAX undefined in the current platform" #endif } diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 938e76f1d18d88..670b14bc2a2aa5 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -44,15 +44,25 @@ #endif /* __sun */ #if defined(_AIX) -#define reqevents events -#define rtnevents revents -#include +# define reqevents events +# define rtnevents revents +# include +#else +# include #endif /* _AIX */ #if defined(__APPLE__) && !TARGET_OS_IPHONE # include #endif +#if defined(__ANDROID__) +int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset); +# ifdef pthread_sigmask +# undef pthread_sigmask +# endif +# define pthread_sigmask(how, set, oldset) uv__pthread_sigmask(how, set, oldset) +#endif + #define ACCESS_ONCE(type, var) \ (*(volatile type*) &(var)) @@ -89,43 +99,11 @@ # define UV_UNUSED(declaration) declaration #endif -#if defined(__linux__) -# define UV__POLLIN UV__EPOLLIN -# define UV__POLLOUT UV__EPOLLOUT -# define UV__POLLERR UV__EPOLLERR -# define UV__POLLHUP UV__EPOLLHUP -# define UV__POLLRDHUP UV__EPOLLRDHUP -#endif - -#if defined(__sun) || defined(_AIX) -# define UV__POLLIN POLLIN -# define UV__POLLOUT POLLOUT -# define UV__POLLERR POLLERR -# define UV__POLLHUP POLLHUP -#endif - -#ifndef UV__POLLIN -# define UV__POLLIN 1 -#endif - -#ifndef UV__POLLOUT -# define UV__POLLOUT 2 -#endif - -#ifndef UV__POLLERR -# define UV__POLLERR 4 -#endif - -#ifndef UV__POLLHUP -# define UV__POLLHUP 8 -#endif - -#ifndef UV__POLLRDHUP -# ifdef POLLRDHUP -# define UV__POLLRDHUP POLLRDHUP -# else -# define UV__POLLRDHUP 0x200 -# endif +/* Leans on the fact that, on Linux, POLLRDHUP == EPOLLRDHUP. */ +#ifdef POLLRDHUP +# define UV__POLLRDHUP POLLRDHUP +#else +# define UV__POLLRDHUP 0x2000 #endif #if !defined(O_CLOEXEC) && defined(__FreeBSD__) diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c index 400b4a4b7c6842..fffd4626f17579 100644 --- a/deps/uv/src/unix/kqueue.c +++ b/deps/uv/src/unix/kqueue.c @@ -78,6 +78,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { sigset_t set; uint64_t base; uint64_t diff; + int have_signals; int filter; int fflags; int count; @@ -103,7 +104,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { assert(w->fd >= 0); assert(w->fd < (int) loop->nwatchers); - if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) { + if ((w->events & POLLIN) == 0 && (w->pevents & POLLIN) != 0) { filter = EVFILT_READ; fflags = 0; op = EV_ADD; @@ -124,7 +125,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } } - if ((w->events & UV__POLLOUT) == 0 && (w->pevents & UV__POLLOUT) != 0) { + if ((w->events & POLLOUT) == 0 && (w->pevents & POLLOUT) != 0) { EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0); if (++nevents == ARRAY_SIZE(events)) { @@ -192,6 +193,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { goto update_timeout; } + have_signals = 0; nevents = 0; assert(loop->watchers != NULL); @@ -219,8 +221,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } if (ev->filter == EVFILT_VNODE) { - assert(w->events == UV__POLLIN); - assert(w->pevents == UV__POLLIN); + assert(w->events == POLLIN); + assert(w->pevents == POLLIN); w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */ nevents++; continue; @@ -229,8 +231,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { revents = 0; if (ev->filter == EVFILT_READ) { - if (w->pevents & UV__POLLIN) { - revents |= UV__POLLIN; + if (w->pevents & POLLIN) { + revents |= POLLIN; w->rcount = ev->data; } else { /* TODO batch up */ @@ -243,8 +245,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } if (ev->filter == EVFILT_WRITE) { - if (w->pevents & UV__POLLOUT) { - revents |= UV__POLLOUT; + if (w->pevents & POLLOUT) { + revents |= POLLOUT; w->wcount = ev->data; } else { /* TODO batch up */ @@ -257,7 +259,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { } if (ev->flags & EV_ERROR) - revents |= UV__POLLERR; + revents |= POLLERR; if ((ev->flags & EV_EOF) && (w->pevents & UV__POLLRDHUP)) revents |= UV__POLLRDHUP; @@ -265,12 +267,26 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (revents == 0) continue; - w->cb(loop, w, revents); + /* Run signal watchers last. This also affects child process watchers + * because those are implemented in terms of signal watchers. + */ + if (w == &loop->signal_io_watcher) + have_signals = 1; + else + w->cb(loop, w, revents); + nevents++; } + + if (have_signals != 0) + loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); + loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; + if (have_signals != 0) + return; /* Event loop should cycle now so don't poll again. */ + if (nevents != 0) { if (nfds == ARRAY_SIZE(events) && --count != 0) { /* Poll for more events but don't block this time. */ @@ -409,7 +425,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, fallback: #endif /* defined(__APPLE__) */ - uv__io_start(handle->loop, &handle->event_watcher, UV__POLLIN); + uv__io_start(handle->loop, &handle->event_watcher, POLLIN); return 0; } diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index fb8ac3f2379851..b48a1111701753 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -18,6 +18,11 @@ * IN THE SOFTWARE. */ +/* We lean on the fact that POLL{IN,OUT,ERR,HUP} correspond with their + * EPOLL* counterparts. We use the POLL* variants in this file because that + * is what libuv uses elsewhere and it avoids a dependency on . + */ + #include "uv.h" #include "internal.h" @@ -69,7 +74,9 @@ #endif static int read_models(unsigned int numcpus, uv_cpu_info_t* ci); -static int read_times(FILE* statfile_fp, unsigned int numcpus, uv_cpu_info_t* ci); +static int read_times(FILE* statfile_fp, + unsigned int numcpus, + uv_cpu_info_t* ci); static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci); static unsigned long read_cpufreq(unsigned int cpunum); @@ -102,7 +109,7 @@ int uv__platform_loop_init(uv_loop_t* loop) { void uv__platform_loop_delete(uv_loop_t* loop) { if (loop->inotify_fd == -1) return; - uv__io_stop(loop, &loop->inotify_read_watcher, UV__POLLIN); + uv__io_stop(loop, &loop->inotify_read_watcher, POLLIN); uv__close(loop->inotify_fd); loop->inotify_fd = -1; } @@ -144,7 +151,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) { struct uv__epoll_event e; int rc; - e.events = UV__EPOLLIN; + e.events = POLLIN; e.data = -1; rc = 0; @@ -181,6 +188,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { sigset_t sigset; uint64_t sigmask; uint64_t base; + int have_signals; int nevents; int count; int nfds; @@ -308,6 +316,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { goto update_timeout; } + have_signals = 0; nevents = 0; assert(loop->watchers != NULL); @@ -341,7 +350,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * the current watcher. Also, filters out events that users has not * requested us to watch. */ - pe->events &= w->pevents | UV__POLLERR | UV__POLLHUP; + pe->events &= w->pevents | POLLERR | POLLHUP; /* Work around an epoll quirk where it sometimes reports just the * EPOLLERR or EPOLLHUP event. In order to force the event loop to @@ -358,17 +367,31 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { * needs to remember the error/hangup event. We should get that for * free when we switch over to edge-triggered I/O. */ - if (pe->events == UV__EPOLLERR || pe->events == UV__EPOLLHUP) - pe->events |= w->pevents & (UV__EPOLLIN | UV__EPOLLOUT); + if (pe->events == POLLERR || pe->events == POLLHUP) + pe->events |= w->pevents & (POLLIN | POLLOUT); if (pe->events != 0) { - w->cb(loop, w, pe->events); + /* Run signal watchers last. This also affects child process watchers + * because those are implemented in terms of signal watchers. + */ + if (w == &loop->signal_io_watcher) + have_signals = 1; + else + w->cb(loop, w, pe->events); + nevents++; } } + + if (have_signals != 0) + loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); + loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; + if (have_signals != 0) + return; /* Event loop should cycle now so don't poll again. */ + if (nevents != 0) { if (nfds == ARRAY_SIZE(events) && --count != 0) { /* Poll for more events but don't block this time. */ @@ -557,7 +580,7 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { char buf[1024]; if (!fgets(buf, sizeof(buf), statfile_fp)) - abort(); + return -EIO; num = 0; while (fgets(buf, sizeof(buf), statfile_fp)) { @@ -566,6 +589,9 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { num++; } + if (num == 0) + return -EIO; + *numcpus = num; return 0; } @@ -586,26 +612,20 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { err = uv__cpu_num(statfile_fp, &numcpus); if (err < 0) - return err; - - assert(numcpus != (unsigned int) -1); - assert(numcpus != 0); + goto out; + err = -ENOMEM; ci = uv__calloc(numcpus, sizeof(*ci)); if (ci == NULL) - return -ENOMEM; + goto out; err = read_models(numcpus, ci); if (err == 0) err = read_times(statfile_fp, numcpus, ci); - if (fclose(statfile_fp)) - if (errno != EINTR && errno != EINPROGRESS) - abort(); - if (err) { uv_free_cpu_info(ci, numcpus); - return err; + goto out; } /* read_models() on x86 also reads the CPU speed from /proc/cpuinfo. @@ -616,8 +636,15 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { *cpu_infos = ci; *count = numcpus; + err = 0; - return 0; +out: + + if (fclose(statfile_fp)) + if (errno != EINTR && errno != EINPROGRESS) + abort(); + + return err; } @@ -727,7 +754,9 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) { } -static int read_times(FILE* statfile_fp, unsigned int numcpus, uv_cpu_info_t* ci) { +static int read_times(FILE* statfile_fp, + unsigned int numcpus, + uv_cpu_info_t* ci) { unsigned long clock_ticks; struct uv_cpu_times_s ts; unsigned long user; diff --git a/deps/uv/src/unix/linux-inotify.c b/deps/uv/src/unix/linux-inotify.c index 282912115d8120..4708c051d3b540 100644 --- a/deps/uv/src/unix/linux-inotify.c +++ b/deps/uv/src/unix/linux-inotify.c @@ -102,7 +102,7 @@ static int init_inotify(uv_loop_t* loop) { loop->inotify_fd = err; uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd); - uv__io_start(loop, &loop->inotify_read_watcher, UV__POLLIN); + uv__io_start(loop, &loop->inotify_read_watcher, POLLIN); return 0; } diff --git a/deps/uv/src/unix/linux-syscalls.h b/deps/uv/src/unix/linux-syscalls.h index 4260df111f3ae4..4c095e9b537996 100644 --- a/deps/uv/src/unix/linux-syscalls.h +++ b/deps/uv/src/unix/linux-syscalls.h @@ -72,14 +72,6 @@ #define UV__EPOLL_CTL_DEL 2 #define UV__EPOLL_CTL_MOD 3 -#define UV__EPOLLIN 1 -#define UV__EPOLLOUT 4 -#define UV__EPOLLERR 8 -#define UV__EPOLLHUP 16 -#define UV__EPOLLRDHUP 0x2000 -#define UV__EPOLLONESHOT 0x40000000 -#define UV__EPOLLET 0x80000000 - /* inotify flags */ #define UV__IN_ACCESS 0x001 #define UV__IN_MODIFY 0x002 diff --git a/deps/uv/src/unix/openbsd.c b/deps/uv/src/unix/openbsd.c index 6a3909a666c1d0..8c40bde40f69ad 100644 --- a/deps/uv/src/unix/openbsd.c +++ b/deps/uv/src/unix/openbsd.c @@ -247,7 +247,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { which[1] = HW_CPUSPEED; size = sizeof(cpuspeed); if (sysctl(which, 2, &cpuspeed, &size, NULL, 0)) { - SAVE_ERRNO(uv__free(*cpu_infos)); + uv__free(*cpu_infos); return -errno; } @@ -258,7 +258,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { which[2] = i; size = sizeof(info); if (sysctl(which, 3, &info, &size, NULL, 0)) { - SAVE_ERRNO(uv__free(*cpu_infos)); + uv__free(*cpu_infos); return -errno; } diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c index d4fdfa9d5a5480..c8d163dcc796d5 100644 --- a/deps/uv/src/unix/pipe.c +++ b/deps/uv/src/unix/pipe.c @@ -102,7 +102,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) { handle->connection_cb = cb; handle->io_watcher.cb = uv__server_io; - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN); + uv__io_start(handle->loop, &handle->io_watcher, POLLIN); return 0; } @@ -185,7 +185,7 @@ void uv_pipe_connect(uv_connect_t* req, } if (err == 0) - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT); + uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT); out: handle->delayed_error = err; diff --git a/deps/uv/src/unix/poll.c b/deps/uv/src/unix/poll.c index e5efb17160ff95..0d5944b0afb8ba 100644 --- a/deps/uv/src/unix/poll.c +++ b/deps/uv/src/unix/poll.c @@ -33,17 +33,17 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { handle = container_of(w, uv_poll_t, io_watcher); - if (events & UV__POLLERR) { - uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); + if (events & POLLERR) { + uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP); uv__handle_stop(handle); handle->poll_cb(handle, -EBADF, 0); return; } pevents = 0; - if (events & UV__POLLIN) + if (events & POLLIN) pevents |= UV_READABLE; - if (events & UV__POLLOUT) + if (events & POLLOUT) pevents |= UV_WRITABLE; if (events & UV__POLLRDHUP) pevents |= UV_DISCONNECT; @@ -79,7 +79,7 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, static void uv__poll_stop(uv_poll_t* handle) { uv__io_stop(handle->loop, &handle->io_watcher, - UV__POLLIN | UV__POLLOUT | UV__POLLRDHUP); + POLLIN | POLLOUT | UV__POLLRDHUP); uv__handle_stop(handle); } @@ -104,9 +104,9 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { events = 0; if (pevents & UV_READABLE) - events |= UV__POLLIN; + events |= POLLIN; if (pevents & UV_WRITABLE) - events |= UV__POLLOUT; + events |= POLLOUT; if (pevents & UV_DISCONNECT) events |= UV__POLLRDHUP; diff --git a/deps/uv/src/unix/pthread-barrier.c b/deps/uv/src/unix/pthread-barrier.c new file mode 100644 index 00000000000000..f57bf25080c4e1 --- /dev/null +++ b/deps/uv/src/unix/pthread-barrier.c @@ -0,0 +1,120 @@ +/* +Copyright (c) 2016, Kari Tristan Helgason + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +#include "uv-common.h" +#include "pthread-barrier.h" + +#include +#include + +/* TODO: support barrier_attr */ +int pthread_barrier_init(pthread_barrier_t* barrier, + const void* barrier_attr, + unsigned count) { + int rc; + _uv_barrier* b; + + if (barrier == NULL || count == 0) + return EINVAL; + + if (barrier_attr != NULL) + return ENOTSUP; + + b = uv__malloc(sizeof(*b)); + if (b == NULL) + return ENOMEM; + + b->in = 0; + b->out = 0; + b->threshold = count; + + if ((rc = pthread_mutex_init(&b->mutex, NULL)) != 0) + goto error2; + if ((rc = pthread_cond_init(&b->cond, NULL)) != 0) + goto error; + + barrier->b = b; + return 0; + +error: + pthread_mutex_destroy(&b->mutex); +error2: + uv__free(b); + return rc; +} + +int pthread_barrier_wait(pthread_barrier_t* barrier) { + int rc; + _uv_barrier* b; + + if (barrier == NULL || barrier->b == NULL) + return EINVAL; + + b = barrier->b; + /* Lock the mutex*/ + if ((rc = pthread_mutex_lock(&b->mutex)) != 0) + return rc; + + /* Increment the count. If this is the first thread to reach the threshold, + wake up waiters, unlock the mutex, then return + PTHREAD_BARRIER_SERIAL_THREAD. */ + if (++b->in == b->threshold) { + b->in = 0; + b->out = b->threshold - 1; + assert(pthread_cond_signal(&b->cond) == 0); + + pthread_mutex_unlock(&b->mutex); + return PTHREAD_BARRIER_SERIAL_THREAD; + } + /* Otherwise, wait for other threads until in is set to 0, + then return 0 to indicate this is not the first thread. */ + do { + if ((rc = pthread_cond_wait(&b->cond, &b->mutex)) != 0) + break; + } while (b->in != 0); + + /* mark thread exit */ + b->out--; + pthread_cond_signal(&b->cond); + pthread_mutex_unlock(&b->mutex); + return rc; +} + +int pthread_barrier_destroy(pthread_barrier_t* barrier) { + int rc; + _uv_barrier* b; + + if (barrier == NULL || barrier->b == NULL) + return EINVAL; + + b = barrier->b; + + if ((rc = pthread_mutex_lock(&b->mutex)) != 0) + return rc; + + if (b->in > 0 || b->out > 0) + rc = EBUSY; + + pthread_mutex_unlock(&b->mutex); + + if (rc) + return rc; + + pthread_cond_destroy(&b->cond); + pthread_mutex_destroy(&b->mutex); + uv__free(barrier->b); + barrier->b = NULL; + return 0; +} diff --git a/deps/uv/src/unix/pthread-fixes.c b/deps/uv/src/unix/pthread-fixes.c index 3a71eb5aae743f..fb179958467231 100644 --- a/deps/uv/src/unix/pthread-fixes.c +++ b/deps/uv/src/unix/pthread-fixes.c @@ -29,76 +29,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* Android versions < 4.1 have a broken pthread_sigmask. - * Note that this block of code must come before any inclusion of - * pthread-fixes.h so that the real pthread_sigmask can be referenced. - * */ +/* Android versions < 4.1 have a broken pthread_sigmask. */ #include #include #include int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) { static int workaround; + int err; if (workaround) { return sigprocmask(how, set, oset); - } else if (pthread_sigmask(how, set, oset)) { - if (errno == EINVAL && sigprocmask(how, set, oset) == 0) { - workaround = 1; - return 0; - } else { - return -1; - } } else { - return 0; - } -} - -/*Android doesn't provide pthread_barrier_t for now.*/ -#ifndef PTHREAD_BARRIER_SERIAL_THREAD - -#include "pthread-fixes.h" - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count) { - barrier->count = count; - pthread_mutex_init(&barrier->mutex, NULL); - pthread_cond_init(&barrier->cond, NULL); - return 0; -} - -int pthread_barrier_wait(pthread_barrier_t* barrier) { - /* Lock the mutex*/ - pthread_mutex_lock(&barrier->mutex); - /* Decrement the count. If this is the first thread to reach 0, wake up - waiters, unlock the mutex, then return PTHREAD_BARRIER_SERIAL_THREAD.*/ - if (--barrier->count == 0) { - /* First thread to reach the barrier */ - pthread_cond_broadcast(&barrier->cond); - pthread_mutex_unlock(&barrier->mutex); - return PTHREAD_BARRIER_SERIAL_THREAD; + err = pthread_sigmask(how, set, oset); + if (err) { + if (err == EINVAL && sigprocmask(how, set, oset) == 0) { + workaround = 1; + return 0; + } else { + return -1; + } + } } - /* Otherwise, wait for other threads until the count reaches 0, then - return 0 to indicate this is not the first thread.*/ - do { - pthread_cond_wait(&barrier->cond, &barrier->mutex); - } while (barrier->count > 0); - - pthread_mutex_unlock(&barrier->mutex); - return 0; -} - -int pthread_barrier_destroy(pthread_barrier_t *barrier) { - barrier->count = 0; - pthread_cond_destroy(&barrier->cond); - pthread_mutex_destroy(&barrier->mutex); - return 0; -} - -#endif /* defined(PTHREAD_BARRIER_SERIAL_THREAD) */ -int pthread_yield(void) { - sched_yield(); return 0; } diff --git a/deps/uv/src/unix/signal.c b/deps/uv/src/unix/signal.c index edd9085d3f352f..d82b9b7cf83ca1 100644 --- a/deps/uv/src/unix/signal.c +++ b/deps/uv/src/unix/signal.c @@ -222,7 +222,7 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) { uv__io_init(&loop->signal_io_watcher, uv__signal_event, loop->signal_pipefd[0]); - uv__io_start(loop, &loop->signal_io_watcher, UV__POLLIN); + uv__io_start(loop, &loop->signal_io_watcher, POLLIN); return 0; } diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 9043664dfcaf9a..7dbc556f74e0bc 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -159,9 +159,9 @@ static void uv__stream_osx_select(void* arg) { memset(s->sread, 0, s->sread_sz); memset(s->swrite, 0, s->swrite_sz); - if (uv__io_active(&stream->io_watcher, UV__POLLIN)) + if (uv__io_active(&stream->io_watcher, POLLIN)) FD_SET(fd, s->sread); - if (uv__io_active(&stream->io_watcher, UV__POLLOUT)) + if (uv__io_active(&stream->io_watcher, POLLOUT)) FD_SET(fd, s->swrite); FD_SET(s->int_fd, s->sread); @@ -202,9 +202,9 @@ static void uv__stream_osx_select(void* arg) { /* Handle events */ events = 0; if (FD_ISSET(fd, s->sread)) - events |= UV__POLLIN; + events |= POLLIN; if (FD_ISSET(fd, s->swrite)) - events |= UV__POLLOUT; + events |= POLLOUT; assert(events != 0 || FD_ISSET(s->int_fd, s->sread)); if (events != 0) { @@ -233,14 +233,14 @@ static void uv__stream_osx_select_cb(uv_async_t* handle) { ACCESS_ONCE(int, s->events) = 0; assert(events != 0); - assert(events == (events & (UV__POLLIN | UV__POLLOUT))); + assert(events == (events & (POLLIN | POLLOUT))); /* Invoke callback on event-loop */ - if ((events & UV__POLLIN) && uv__io_active(&stream->io_watcher, UV__POLLIN)) - uv__stream_io(stream->loop, &stream->io_watcher, UV__POLLIN); + if ((events & POLLIN) && uv__io_active(&stream->io_watcher, POLLIN)) + uv__stream_io(stream->loop, &stream->io_watcher, POLLIN); - if ((events & UV__POLLOUT) && uv__io_active(&stream->io_watcher, UV__POLLOUT)) - uv__stream_io(stream->loop, &stream->io_watcher, UV__POLLOUT); + if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT)) + uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT); if (stream->flags & UV_CLOSING) return; @@ -437,7 +437,7 @@ void uv__stream_flush_write_queue(uv_stream_t* stream, int error) { void uv__stream_destroy(uv_stream_t* stream) { - assert(!uv__io_active(&stream->io_watcher, UV__POLLIN | UV__POLLOUT)); + assert(!uv__io_active(&stream->io_watcher, POLLIN | POLLOUT)); assert(stream->flags & UV_CLOSED); if (stream->connect_req) { @@ -511,11 +511,11 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { int err; stream = container_of(w, uv_stream_t, io_watcher); - assert(events == UV__POLLIN); + assert(events == POLLIN); assert(stream->accepted_fd == -1); assert(!(stream->flags & UV_CLOSING)); - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN); + uv__io_start(stream->loop, &stream->io_watcher, POLLIN); /* connection_cb can close the server socket while we're * in the loop so check it on each iteration. @@ -552,7 +552,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { if (stream->accepted_fd != -1) { /* The user hasn't yet accepted called uv_accept() */ - uv__io_stop(loop, &stream->io_watcher, UV__POLLIN); + uv__io_stop(loop, &stream->io_watcher, POLLIN); return; } @@ -626,7 +626,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) { } else { server->accepted_fd = -1; if (err == 0) - uv__io_start(server->loop, &server->io_watcher, UV__POLLIN); + uv__io_start(server->loop, &server->io_watcher, POLLIN); } return err; } @@ -660,7 +660,7 @@ static void uv__drain(uv_stream_t* stream) { int err; assert(QUEUE_EMPTY(&stream->write_queue)); - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); /* Shutdown? */ @@ -846,8 +846,8 @@ static void uv__write(uv_stream_t* stream) { /* Error */ req->error = -errno; uv__write_req_finish(req); - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); - if (!uv__io_active(&stream->io_watcher, UV__POLLIN)) + uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); + if (!uv__io_active(&stream->io_watcher, POLLIN)) uv__handle_stop(stream); uv__stream_osx_interrupt_select(stream); return; @@ -910,7 +910,7 @@ static void uv__write(uv_stream_t* stream) { assert(!(stream->flags & UV_STREAM_BLOCKING)); /* We're not done. */ - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); /* Notify select() thread about state change */ uv__stream_osx_interrupt_select(stream); @@ -989,8 +989,8 @@ uv_handle_type uv__handle_type(int fd) { static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) { stream->flags |= UV_STREAM_READ_EOF; - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN); - if (!uv__io_active(&stream->io_watcher, UV__POLLOUT)) + uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); + if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); uv__stream_osx_interrupt_select(stream); stream->read_cb(stream, UV_EOF, buf); @@ -1159,7 +1159,7 @@ static void uv__read(uv_stream_t* stream) { if (errno == EAGAIN || errno == EWOULDBLOCK) { /* Wait for the next one. */ if (stream->flags & UV_STREAM_READING) { - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN); + uv__io_start(stream->loop, &stream->io_watcher, POLLIN); uv__stream_osx_interrupt_select(stream); } stream->read_cb(stream, 0, &buf); @@ -1168,8 +1168,8 @@ static void uv__read(uv_stream_t* stream) { stream->read_cb(stream, -errno, &buf); if (stream->flags & UV_STREAM_READING) { stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN); - if (!uv__io_active(&stream->io_watcher, UV__POLLOUT)) + uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); + if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); uv__stream_osx_interrupt_select(stream); } @@ -1230,7 +1230,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) { stream->shutdown_req = req; stream->flags |= UV_STREAM_SHUTTING; - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); return 0; @@ -1255,7 +1255,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { assert(uv__stream_fd(stream) >= 0); /* Ignore POLLHUP here. Even it it's set, there may still be data to read. */ - if (events & (UV__POLLIN | UV__POLLERR | UV__POLLHUP)) + if (events & (POLLIN | POLLERR | POLLHUP)) uv__read(stream); if (uv__stream_fd(stream) == -1) @@ -1267,7 +1267,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { * have to do anything. If the partial read flag is not set, we can't * report the EOF yet because there is still data to read. */ - if ((events & UV__POLLHUP) && + if ((events & POLLHUP) && (stream->flags & UV_STREAM_READING) && (stream->flags & UV_STREAM_READ_PARTIAL) && !(stream->flags & UV_STREAM_READ_EOF)) { @@ -1278,7 +1278,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { if (uv__stream_fd(stream) == -1) return; /* read_cb closed stream. */ - if (events & (UV__POLLOUT | UV__POLLERR | UV__POLLHUP)) { + if (events & (POLLOUT | POLLERR | POLLHUP)) { uv__write(stream); uv__write_callbacks(stream); @@ -1327,7 +1327,7 @@ static void uv__stream_connect(uv_stream_t* stream) { uv__req_unregister(stream->loop, req); if (error < 0 || QUEUE_EMPTY(&stream->write_queue)) { - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); } if (req->cb) @@ -1422,7 +1422,7 @@ int uv_write2(uv_write_t* req, * sufficiently flushed in uv__write. */ assert(!(stream->flags & UV_STREAM_BLOCKING)); - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_start(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); } @@ -1461,7 +1461,7 @@ int uv_try_write(uv_stream_t* stream, if (stream->connect_req != NULL || stream->write_queue_size != 0) return -EAGAIN; - has_pollout = uv__io_active(&stream->io_watcher, UV__POLLOUT); + has_pollout = uv__io_active(&stream->io_watcher, POLLOUT); r = uv_write(&req, stream, bufs, nbufs, uv_try_write_cb); if (r != 0) @@ -1485,7 +1485,7 @@ int uv_try_write(uv_stream_t* stream, /* Do not poll for writable, if we wasn't before calling this */ if (!has_pollout) { - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); + uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT); uv__stream_osx_interrupt_select(stream); } @@ -1520,7 +1520,7 @@ int uv_read_start(uv_stream_t* stream, stream->read_cb = read_cb; stream->alloc_cb = alloc_cb; - uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN); + uv__io_start(stream->loop, &stream->io_watcher, POLLIN); uv__handle_start(stream); uv__stream_osx_interrupt_select(stream); @@ -1533,8 +1533,8 @@ int uv_read_stop(uv_stream_t* stream) { return 0; stream->flags &= ~UV_STREAM_READING; - uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN); - if (!uv__io_active(&stream->io_watcher, UV__POLLOUT)) + uv__io_stop(stream->loop, &stream->io_watcher, POLLIN); + if (!uv__io_active(&stream->io_watcher, POLLOUT)) uv__handle_stop(stream); uv__stream_osx_interrupt_select(stream); @@ -1621,7 +1621,7 @@ void uv__stream_close(uv_stream_t* handle) { handle->queued_fds = NULL; } - assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT)); + assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); } diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index 9a6cc42b5bf3fd..e67be8fcf81ec4 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -140,6 +140,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { unsigned int nfds; unsigned int i; int saved_errno; + int have_signals; int nevents; int count; int err; @@ -230,6 +231,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { return; } + have_signals = 0; nevents = 0; assert(loop->watchers != NULL); @@ -252,7 +254,14 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (w == NULL) continue; - w->cb(loop, w, pe->portev_events); + /* Run signal watchers last. This also affects child process watchers + * because those are implemented in terms of signal watchers. + */ + if (w == &loop->signal_io_watcher) + have_signals = 1; + else + w->cb(loop, w, pe->portev_events); + nevents++; if (w != loop->watchers[fd]) @@ -262,9 +271,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { if (w->pevents != 0 && QUEUE_EMPTY(&w->watcher_queue)) QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue); } + + if (have_signals != 0) + loop->signal_io_watcher.cb(loop, &loop->signal_io_watcher, POLLIN); + loop->watchers[loop->nwatchers] = NULL; loop->watchers[loop->nwatchers + 1] = NULL; + if (have_signals != 0) + return; /* Event loop should cycle now so don't poll again. */ + if (nevents != 0) { if (nfds == ARRAY_SIZE(events) && --count != 0) { /* Poll for more events but don't block this time. */ @@ -456,7 +472,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, if (first_run) { uv__io_init(&handle->loop->fs_event_watcher, uv__fs_event_read, portfd); - uv__io_start(handle->loop, &handle->loop->fs_event_watcher, UV__POLLIN); + uv__io_start(handle->loop, &handle->loop->fs_event_watcher, POLLIN); } return 0; diff --git a/deps/uv/src/unix/tcp.c b/deps/uv/src/unix/tcp.c index 6d213a497787d8..793e4c7d60b543 100644 --- a/deps/uv/src/unix/tcp.c +++ b/deps/uv/src/unix/tcp.c @@ -181,7 +181,7 @@ int uv__tcp_connect(uv_connect_t* req, QUEUE_INIT(&req->queue); handle->connect_req = req; - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT); + uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); if (handle->delayed_error) uv__io_feed(handle->loop, &handle->io_watcher); @@ -273,7 +273,7 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) { /* Start listening for connections. */ tcp->io_watcher.cb = uv__server_io; - uv__io_start(tcp->loop, &tcp->io_watcher, UV__POLLIN); + uv__io_start(tcp->loop, &tcp->io_watcher, POLLIN); return 0; } diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index c35bc926bf0fac..236f5913936650 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -28,13 +28,13 @@ #include #include /* getrlimit() */ +#include /* getpagesize() */ #include #undef NANOSEC #define NANOSEC ((uint64_t) 1e9) - struct thread_ctx { void (*entry)(void* arg); void* arg; @@ -82,10 +82,13 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { if (pthread_attr_init(attr)) abort(); - if (lim.rlim_cur != RLIM_INFINITY && - lim.rlim_cur >= PTHREAD_STACK_MIN) { - if (pthread_attr_setstacksize(attr, lim.rlim_cur)) - abort(); + if (lim.rlim_cur != RLIM_INFINITY) { + /* pthread_attr_setstacksize() expects page-aligned values. */ + lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize(); + + if (lim.rlim_cur >= PTHREAD_STACK_MIN) + if (pthread_attr_setstacksize(attr, lim.rlim_cur)) + abort(); } #else attr = NULL; @@ -393,6 +396,35 @@ int uv_cond_init(uv_cond_t* cond) { #endif /* defined(__APPLE__) && defined(__MACH__) */ void uv_cond_destroy(uv_cond_t* cond) { +#if defined(__APPLE__) && defined(__MACH__) + /* It has been reported that destroying condition variables that have been + * signalled but not waited on can sometimes result in application crashes. + * See https://codereview.chromium.org/1323293005. + */ + pthread_mutex_t mutex; + struct timespec ts; + int err; + + if (pthread_mutex_init(&mutex, NULL)) + abort(); + + if (pthread_mutex_lock(&mutex)) + abort(); + + ts.tv_sec = 0; + ts.tv_nsec = 1; + + err = pthread_cond_timedwait_relative_np(cond, &mutex, &ts); + if (err != 0 && err != ETIMEDOUT) + abort(); + + if (pthread_mutex_unlock(&mutex)) + abort(); + + if (pthread_mutex_destroy(&mutex)) + abort(); +#endif /* defined(__APPLE__) && defined(__MACH__) */ + if (pthread_cond_destroy(cond)) abort(); } @@ -448,72 +480,6 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) { } -#if defined(__APPLE__) && defined(__MACH__) - -int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { - int err; - - barrier->n = count; - barrier->count = 0; - - err = uv_mutex_init(&barrier->mutex); - if (err) - return -err; - - err = uv_sem_init(&barrier->turnstile1, 0); - if (err) - goto error2; - - err = uv_sem_init(&barrier->turnstile2, 1); - if (err) - goto error; - - return 0; - -error: - uv_sem_destroy(&barrier->turnstile1); -error2: - uv_mutex_destroy(&barrier->mutex); - return -err; - -} - - -void uv_barrier_destroy(uv_barrier_t* barrier) { - uv_sem_destroy(&barrier->turnstile2); - uv_sem_destroy(&barrier->turnstile1); - uv_mutex_destroy(&barrier->mutex); -} - - -int uv_barrier_wait(uv_barrier_t* barrier) { - int serial_thread; - - uv_mutex_lock(&barrier->mutex); - if (++barrier->count == barrier->n) { - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile1); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile1); - - uv_mutex_lock(&barrier->mutex); - serial_thread = (--barrier->count == 0); - if (serial_thread) { - uv_sem_wait(&barrier->turnstile1); - uv_sem_post(&barrier->turnstile2); - } - uv_mutex_unlock(&barrier->mutex); - - uv_sem_wait(&barrier->turnstile2); - uv_sem_post(&barrier->turnstile2); - return serial_thread; -} - -#else /* !(defined(__APPLE__) && defined(__MACH__)) */ - int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) { return -pthread_barrier_init(barrier, NULL, count); } @@ -532,7 +498,6 @@ int uv_barrier_wait(uv_barrier_t* barrier) { return r == PTHREAD_BARRIER_SERIAL_THREAD; } -#endif /* defined(__APPLE__) && defined(__MACH__) */ int uv_key_create(uv_key_t* key) { return -pthread_key_create(key, NULL); diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 39ade8de338afc..4527bba1f1931c 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -61,7 +61,7 @@ void uv__udp_finish_close(uv_udp_t* handle) { uv_udp_send_t* req; QUEUE* q; - assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT)); + assert(!uv__io_active(&handle->io_watcher, POLLIN | POLLOUT)); assert(handle->io_watcher.fd == -1); while (!QUEUE_EMPTY(&handle->write_queue)) { @@ -120,8 +120,8 @@ static void uv__udp_run_completed(uv_udp_t* handle) { if (QUEUE_EMPTY(&handle->write_queue)) { /* Pending queue and completion queue empty, stop watcher. */ - uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLOUT); - if (!uv__io_active(&handle->io_watcher, UV__POLLIN)) + uv__io_stop(handle->loop, &handle->io_watcher, POLLOUT); + if (!uv__io_active(&handle->io_watcher, POLLIN)) uv__handle_stop(handle); } @@ -135,10 +135,10 @@ static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) { handle = container_of(w, uv_udp_t, io_watcher); assert(handle->type == UV_UDP); - if (revents & UV__POLLIN) + if (revents & POLLIN) uv__udp_recvmsg(handle); - if (revents & UV__POLLOUT) { + if (revents & POLLOUT) { uv__udp_sendmsg(handle); uv__udp_run_completed(handle); } @@ -424,7 +424,7 @@ int uv__udp_send(uv_udp_send_t* req, if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) { uv__udp_sendmsg(handle); } else { - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT); + uv__io_start(handle->loop, &handle->io_watcher, POLLOUT); } return 0; @@ -843,7 +843,7 @@ int uv__udp_recv_start(uv_udp_t* handle, if (alloc_cb == NULL || recv_cb == NULL) return -EINVAL; - if (uv__io_active(&handle->io_watcher, UV__POLLIN)) + if (uv__io_active(&handle->io_watcher, POLLIN)) return -EALREADY; /* FIXME(bnoordhuis) Should be -EBUSY. */ err = uv__udp_maybe_deferred_bind(handle, AF_INET, 0); @@ -853,7 +853,7 @@ int uv__udp_recv_start(uv_udp_t* handle, handle->alloc_cb = alloc_cb; handle->recv_cb = recv_cb; - uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN); + uv__io_start(handle->loop, &handle->io_watcher, POLLIN); uv__handle_start(handle); return 0; @@ -861,9 +861,9 @@ int uv__udp_recv_start(uv_udp_t* handle, int uv__udp_recv_stop(uv_udp_t* handle) { - uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN); + uv__io_stop(handle->loop, &handle->io_watcher, POLLIN); - if (!uv__io_active(&handle->io_watcher, UV__POLLOUT)) + if (!uv__io_active(&handle->io_watcher, POLLOUT)) uv__handle_stop(handle); handle->alloc_cb = NULL; diff --git a/deps/uv/src/uv-common.c b/deps/uv/src/uv-common.c index 6b8c584fbe75b1..ba26446915a39c 100644 --- a/deps/uv/src/uv-common.c +++ b/deps/uv/src/uv-common.c @@ -22,10 +22,11 @@ #include "uv.h" #include "uv-common.h" -#include #include +#include #include #include /* NULL */ +#include #include /* malloc */ #include /* memset */ @@ -75,7 +76,14 @@ void* uv__malloc(size_t size) { } void uv__free(void* ptr) { + int saved_errno; + + /* Libuv expects that free() does not clobber errno. The system allocator + * honors that assumption but custom allocators may not be so careful. + */ + saved_errno = errno; uv__allocator.local_free(ptr); + errno = saved_errno; } void* uv__calloc(size_t count, size_t size) { @@ -475,6 +483,16 @@ static unsigned int* uv__get_nbufs(uv_fs_t* req) { #endif } +/* uv_fs_scandir() uses the system allocator to allocate memory on non-Windows + * systems. So, the memory should be released using free(). On Windows, + * uv__malloc() is used, so use uv__free() to free memory. +*/ +#ifdef _WIN32 +# define uv__fs_scandir_free uv__free +#else +# define uv__fs_scandir_free free +#endif + void uv__fs_scandir_cleanup(uv_fs_t* req) { uv__dirent_t** dents; @@ -484,7 +502,10 @@ void uv__fs_scandir_cleanup(uv_fs_t* req) { if (*nbufs > 0 && *nbufs != (unsigned int) req->result) (*nbufs)--; for (; *nbufs < (unsigned int) req->result; (*nbufs)++) - uv__free(dents[*nbufs]); + uv__fs_scandir_free(dents[*nbufs]); + + uv__fs_scandir_free(req->ptr); + req->ptr = NULL; } @@ -498,11 +519,11 @@ int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) { /* Free previous entity */ if (*nbufs > 0) - uv__free(dents[*nbufs - 1]); + uv__fs_scandir_free(dents[*nbufs - 1]); /* End was already reached */ if (*nbufs == (unsigned int) req->result) { - uv__free(dents); + uv__fs_scandir_free(dents); req->ptr = NULL; return UV_EOF; } diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c index 77c935a2d8c8fe..e79a48d0e99686 100644 --- a/deps/uv/src/win/fs-event.c +++ b/deps/uv/src/win/fs-event.c @@ -66,11 +66,12 @@ static void uv_fs_event_queue_readdirchanges(uv_loop_t* loop, static void uv_relative_path(const WCHAR* filename, const WCHAR* dir, WCHAR** relpath) { + size_t relpathlen; + size_t filenamelen = wcslen(filename); size_t dirlen = wcslen(dir); if (dirlen > 0 && dir[dirlen - 1] == '\\') dirlen--; - size_t filenamelen = wcslen(filename); - size_t relpathlen = filenamelen - dirlen - 1; + relpathlen = filenamelen - dirlen - 1; *relpath = uv__malloc((relpathlen + 1) * sizeof(WCHAR)); if (!*relpath) uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); @@ -348,7 +349,8 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, FILE_NOTIFY_INFORMATION* file_info; int err, sizew, size; char* filename = NULL; - WCHAR* filenamew, *long_filenamew = NULL; + WCHAR* filenamew = NULL; + WCHAR* long_filenamew = NULL; DWORD offset = 0; assert(req->type == UV_FS_EVENT_REQ); @@ -373,6 +375,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, do { file_info = (FILE_NOTIFY_INFORMATION*)((char*)file_info + offset); assert(!filename); + assert(!filenamew); assert(!long_filenamew); /* @@ -437,14 +440,17 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, uv__free(long_filenamew); long_filenamew = filenamew; sizew = -1; + } else { + /* We couldn't get the long filename, use the one reported. */ + filenamew = file_info->FileName; + sizew = file_info->FileNameLength / sizeof(WCHAR); } - } - /* - * Removed or renamed events cannot be resolved to the long form. - * We therefore use the name given by ReadDirectoryChangesW. - * This may be the long form or the 8.3 short name in some cases. - */ - if (!long_filenamew) { + } else { + /* + * Removed or renamed events cannot be resolved to the long form. + * We therefore use the name given by ReadDirectoryChangesW. + * This may be the long form or the 8.3 short name in some cases. + */ filenamew = file_info->FileName; sizew = file_info->FileNameLength / sizeof(WCHAR); } @@ -454,38 +460,8 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, sizew = -1; } - if (filenamew) { - /* Convert the filename to utf8. */ - size = WideCharToMultiByte(CP_UTF8, - 0, - filenamew, - sizew, - NULL, - 0, - NULL, - NULL); - if (size) { - filename = (char*)uv__malloc(size + 1); - if (!filename) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - size = WideCharToMultiByte(CP_UTF8, - 0, - filenamew, - sizew, - filename, - size, - NULL, - NULL); - if (size) { - filename[size] = '\0'; - } else { - uv__free(filename); - filename = NULL; - } - } - } + /* Convert the filename to utf8. */ + uv__convert_utf16_to_utf8(filenamew, sizew, &filename); switch (file_info->Action) { case FILE_ACTION_ADDED: @@ -504,6 +480,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req, filename = NULL; uv__free(long_filenamew); long_filenamew = NULL; + filenamew = NULL; } offset = file_info->NextEntryOffset; diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index 16e3ae7cf1b416..54dfea7240864e 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -901,7 +901,15 @@ void fs__scandir(uv_fs_t* req) { /* Compute the length of the filename in WCHARs. */ wchar_len = info->FileNameLength / sizeof info->FileName[0]; - /* Skip over '.' and '..' entries. */ + /* Skip over '.' and '..' entries. It has been reported that + * the SharePoint driver includes the terminating zero byte in + * the filename length. Strip those first. + */ + while (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0') + wchar_len -= 1; + + if (wchar_len == 0) + continue; if (wchar_len == 1 && info->FileName[0] == L'.') continue; if (wchar_len == 2 && info->FileName[0] == L'.' && @@ -1870,8 +1878,12 @@ void uv_fs_req_cleanup(uv_fs_t* req) { if (req->flags & UV_FS_FREE_PATHS) uv__free(req->file.pathw); - if (req->flags & UV_FS_FREE_PTR) - uv__free(req->ptr); + if (req->flags & UV_FS_FREE_PTR) { + if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) + uv__fs_scandir_cleanup(req); + else + uv__free(req->ptr); + } req->path = NULL; req->file.pathw = NULL; diff --git a/deps/uv/src/win/internal.h b/deps/uv/src/win/internal.h index c724793bf05a41..0a7c9404fa3faf 100644 --- a/deps/uv/src/win/internal.h +++ b/deps/uv/src/win/internal.h @@ -83,6 +83,7 @@ extern UV_THREAD_LOCAL int uv__crt_assert_enabled; #define UV_HANDLE_ZERO_READ 0x00080000 #define UV_HANDLE_EMULATE_IOCP 0x00100000 #define UV_HANDLE_BLOCKING_WRITES 0x00200000 +#define UV_HANDLE_CANCELLATION_PENDING 0x00400000 /* Used by uv_tcp_t and uv_udp_t handles */ #define UV_HANDLE_IPV6 0x01000000 @@ -329,7 +330,7 @@ int uv_parent_pid(); int uv_current_pid(); __declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall); int uv__getpwuid_r(uv_passwd_t* pwd); -int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8); +int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8); /* diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index 1b27f60a6f0c9c..9b9637784401d8 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -57,11 +57,23 @@ static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info); static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info); +static int uv__cancel_read_console(uv_tty_t* handle); /* Null uv_buf_t */ static const uv_buf_t uv_null_buf_ = { 0, NULL }; +enum uv__read_console_status_e { + NOT_STARTED, + IN_PROGRESS, + TRAP_REQUESTED, + COMPLETED +}; + +static volatile LONG uv__read_console_status = NOT_STARTED; +static volatile LONG uv__restore_screen_state; +static CONSOLE_SCREEN_BUFFER_INFO uv__saved_screen_state; + /* * The console virtual window. @@ -173,7 +185,8 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { if (readable) { /* Initialize TTY input specific fields. */ tty->flags |= UV_HANDLE_TTY_READABLE | UV_HANDLE_READABLE; - tty->tty.rd.read_line_handle = NULL; + /* TODO: remove me in v2.x. */ + tty->tty.rd.unused_ = NULL; tty->tty.rd.read_line_buffer = uv_null_buf_; tty->tty.rd.read_raw_wait = NULL; @@ -398,6 +411,8 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { DWORD bytes, read_bytes; WCHAR utf16[MAX_INPUT_BUFFER_LENGTH / 3]; DWORD chars, read_chars; + LONG status; + COORD pos; assert(data); @@ -419,7 +434,15 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { /* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */ chars = bytes / 3; - if (ReadConsoleW(handle->tty.rd.read_line_handle, + status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS); + if (status == TRAP_REQUESTED) { + SET_REQ_SUCCESS(req); + req->u.io.overlapped.InternalHigh = 0; + POST_COMPLETION_FOR_REQ(loop, req); + return 0; + } + + if (ReadConsoleW(handle->handle, (void*) utf16, chars, &read_chars, @@ -438,6 +461,33 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) { SET_REQ_ERROR(req, GetLastError()); } + InterlockedExchange(&uv__read_console_status, COMPLETED); + + /* If we canceled the read by sending a VK_RETURN event, restore the screen + state to undo the visual effect of the VK_RETURN*/ + if (InterlockedOr(&uv__restore_screen_state, 0)) { + HANDLE active_screen_buffer = CreateFileA("conout$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (active_screen_buffer != INVALID_HANDLE_VALUE) { + pos = uv__saved_screen_state.dwCursorPosition; + + /* If the cursor was at the bottom line of the screen buffer, the + VK_RETURN would have caused the buffer contents to scroll up by + one line. The right position to reset the cursor to is therefore one + line higher */ + if (pos.Y == uv__saved_screen_state.dwSize.Y - 1) + pos.Y--; + + SetConsoleCursorPosition(active_screen_buffer, pos); + CloseHandle(active_screen_buffer); + } + } + POST_COMPLETION_FOR_REQ(loop, req); return 0; } @@ -463,25 +513,11 @@ static void uv_tty_queue_read_line(uv_loop_t* loop, uv_tty_t* handle) { } assert(handle->tty.rd.read_line_buffer.base != NULL); - /* Duplicate the console handle, so if we want to cancel the read, we can */ - /* just close this handle duplicate. */ - if (handle->tty.rd.read_line_handle == NULL) { - HANDLE this_process = GetCurrentProcess(); - r = DuplicateHandle(this_process, - handle->handle, - this_process, - &handle->tty.rd.read_line_handle, - 0, - 0, - DUPLICATE_SAME_ACCESS); - if (!r) { - handle->tty.rd.read_line_handle = NULL; - SET_REQ_ERROR(req, GetLastError()); - uv_insert_pending_req(loop, (uv_req_t*)req); - goto out; - } - } - + /* Reset flags No locking is required since there cannot be a line read + in progress. We are also relying on the memory barrier provided by + QueueUserWorkItem*/ + uv__restore_screen_state = FALSE; + uv__read_console_status = NOT_STARTED; r = QueueUserWorkItem(uv_tty_line_read_thread, (void*) req, WT_EXECUTELONGFUNCTION); @@ -490,7 +526,6 @@ static void uv_tty_queue_read_line(uv_loop_t* loop, uv_tty_t* handle) { uv_insert_pending_req(loop, (uv_req_t*)req); } - out: handle->flags |= UV_HANDLE_READ_PENDING; handle->reqs_pending++; } @@ -857,8 +892,7 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, if (!REQ_SUCCESS(req)) { /* Read was not successful */ - if ((handle->flags & UV_HANDLE_READING) && - handle->tty.rd.read_line_handle != NULL) { + if (handle->flags & UV_HANDLE_READING) { /* Real error */ handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(loop, handle); @@ -871,10 +905,15 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, } } else { - /* Read successful */ - /* TODO: read unicode, convert to utf-8 */ - DWORD bytes = req->u.io.overlapped.InternalHigh; - handle->read_cb((uv_stream_t*) handle, bytes, &buf); + if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { + /* Read successful */ + /* TODO: read unicode, convert to utf-8 */ + DWORD bytes = req->u.io.overlapped.InternalHigh; + handle->read_cb((uv_stream_t*) handle, bytes, &buf); + } else { + handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING; + handle->read_cb((uv_stream_t*) handle, 0, &buf); + } } /* Wait for more input events. */ @@ -937,30 +976,82 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, int uv_tty_read_stop(uv_tty_t* handle) { + INPUT_RECORD record; + DWORD written, err; + handle->flags &= ~UV_HANDLE_READING; DECREASE_ACTIVE_COUNT(handle->loop, handle); - /* Cancel raw read */ - if ((handle->flags & UV_HANDLE_READ_PENDING) && - (handle->flags & UV_HANDLE_TTY_RAW)) { + if (!(handle->flags & UV_HANDLE_READ_PENDING)) + return 0; + + if (handle->flags & UV_HANDLE_TTY_RAW) { + /* Cancel raw read */ /* Write some bullshit event to force the console wait to return. */ - INPUT_RECORD record; - DWORD written; memset(&record, 0, sizeof record); if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) { return GetLastError(); } + } else if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) { + /* Cancel line-buffered read if not already pending */ + err = uv__cancel_read_console(handle); + if (err) + return err; + + handle->flags |= UV_HANDLE_CANCELLATION_PENDING; + } + + return 0; +} + +static int uv__cancel_read_console(uv_tty_t* handle) { + HANDLE active_screen_buffer = INVALID_HANDLE_VALUE; + INPUT_RECORD record; + DWORD written; + DWORD err = 0; + LONG status; + + assert(!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)); + + status = InterlockedExchange(&uv__read_console_status, TRAP_REQUESTED); + if (status != IN_PROGRESS) { + /* Either we have managed to set a trap for the other thread before + ReadConsole is called, or ReadConsole has returned because the user + has pressed ENTER. In either case, there is nothing else to do. */ + return 0; } - /* Cancel line-buffered read */ - if (handle->tty.rd.read_line_handle != NULL) { - /* Closing this handle will cancel the ReadConsole operation */ - CloseHandle(handle->tty.rd.read_line_handle); - handle->tty.rd.read_line_handle = NULL; + /* Save screen state before sending the VK_RETURN event */ + active_screen_buffer = CreateFileA("conout$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (active_screen_buffer != INVALID_HANDLE_VALUE && + GetConsoleScreenBufferInfo(active_screen_buffer, + &uv__saved_screen_state)) { + InterlockedOr(&uv__restore_screen_state, 1); } + /* Write enter key event to force the console wait to return. */ + record.EventType = KEY_EVENT; + record.Event.KeyEvent.bKeyDown = TRUE; + record.Event.KeyEvent.wRepeatCount = 1; + record.Event.KeyEvent.wVirtualKeyCode = VK_RETURN; + record.Event.KeyEvent.wVirtualScanCode = + MapVirtualKeyW(VK_RETURN, MAPVK_VK_TO_VSC); + record.Event.KeyEvent.uChar.UnicodeChar = L'\r'; + record.Event.KeyEvent.dwControlKeyState = 0; + if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) + err = GetLastError(); - return 0; + if (active_screen_buffer != INVALID_HANDLE_VALUE) + CloseHandle(active_screen_buffer); + + return err; } @@ -2045,11 +2136,6 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) { if (handle->flags & UV__HANDLE_CLOSING && handle->reqs_pending == 0) { - /* The console handle duplicate used for line reading should be destroyed */ - /* by uv_tty_read_stop. */ - assert(!(handle->flags & UV_HANDLE_TTY_READABLE) || - handle->tty.rd.read_line_handle == NULL); - /* The wait handle used for raw reading should be unregistered when the */ /* wait callback runs. */ assert(!(handle->flags & UV_HANDLE_TTY_READABLE) || diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 1788b1780e9bba..4cebad390818cd 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -124,7 +124,7 @@ int uv_exepath(char* buffer, size_t* size_ptr) { utf16_buffer, -1, buffer, - *size_ptr > INT_MAX ? INT_MAX : (int) *size_ptr, + (int) *size_ptr, NULL, NULL); if (utf8_len == 0) { @@ -403,36 +403,13 @@ int uv_set_process_title(const char* title) { static int uv__get_process_title() { WCHAR title_w[MAX_TITLE_LENGTH]; - int length; if (!GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR))) { return -1; } - /* Find out what the size of the buffer is that we need */ - length = WideCharToMultiByte(CP_UTF8, 0, title_w, -1, NULL, 0, NULL, NULL); - if (!length) { - return -1; - } - - assert(!process_title); - process_title = (char*)uv__malloc(length); - if (!process_title) { - uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc"); - } - - /* Do utf16 -> utf8 conversion here */ - if (!WideCharToMultiByte(CP_UTF8, - 0, - title_w, - -1, - process_title, - length, - NULL, - NULL)) { - uv__free(process_title); + if (uv__convert_utf16_to_utf8(title_w, -1, &process_title) != 0) return -1; - } return 0; } @@ -704,43 +681,9 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) { cpu_info->cpu_times.irq = sppi[i].InterruptTime.QuadPart / 10000; cpu_info->cpu_times.nice = 0; - - len = WideCharToMultiByte(CP_UTF8, - 0, - cpu_brand, + uv__convert_utf16_to_utf8(cpu_brand, cpu_brand_size / sizeof(WCHAR), - NULL, - 0, - NULL, - NULL); - if (len == 0) { - err = GetLastError(); - goto error; - } - - assert(len > 0); - - /* Allocate 1 extra byte for the null terminator. */ - cpu_info->model = uv__malloc(len + 1); - if (cpu_info->model == NULL) { - err = ERROR_OUTOFMEMORY; - goto error; - } - - if (WideCharToMultiByte(CP_UTF8, - 0, - cpu_brand, - cpu_brand_size / sizeof(WCHAR), - cpu_info->model, - len, - NULL, - NULL) == 0) { - err = GetLastError(); - goto error; - } - - /* Ensure that cpu_info->model is null terminated. */ - cpu_info->model[len] = '\0'; + &(cpu_info->model)); } uv__free(sppi); @@ -1118,6 +1061,7 @@ void uv_free_interface_addresses(uv_interface_address_t* addresses, int uv_getrusage(uv_rusage_t *uv_rusage) { FILETIME createTime, exitTime, kernelTime, userTime; SYSTEMTIME kernelSystemTime, userSystemTime; + PROCESS_MEMORY_COUNTERS memCounters; int ret; ret = GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime); @@ -1135,6 +1079,13 @@ int uv_getrusage(uv_rusage_t *uv_rusage) { return uv_translate_sys_error(GetLastError()); } + ret = GetProcessMemoryInfo(GetCurrentProcess(), + &memCounters, + sizeof(memCounters)); + if (ret == 0) { + return uv_translate_sys_error(GetLastError()); + } + memset(uv_rusage, 0, sizeof(*uv_rusage)); uv_rusage->ru_utime.tv_sec = userSystemTime.wHour * 3600 + @@ -1147,6 +1098,9 @@ int uv_getrusage(uv_rusage_t *uv_rusage) { kernelSystemTime.wSecond; uv_rusage->ru_stime.tv_usec = kernelSystemTime.wMilliseconds * 1000; + uv_rusage->ru_majflt = (uint64_t) memCounters.PageFaultCount; + uv_rusage->ru_maxrss = (uint64_t) memCounters.PeakWorkingSetSize / 1024; + return 0; } @@ -1288,20 +1242,36 @@ void uv_os_free_passwd(uv_passwd_t* pwd) { } -int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8) { +/* + * Converts a UTF-16 string into a UTF-8 one. The resulting string is + * null-terminated. + * + * If utf16 is null terminated, utf16len can be set to -1, otherwise it must + * be specified. + */ +int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8) { DWORD bufsize; if (utf16 == NULL) return UV_EINVAL; /* Check how much space we need */ - bufsize = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL); + bufsize = WideCharToMultiByte(CP_UTF8, + 0, + utf16, + utf16len, + NULL, + 0, + NULL, + NULL); if (bufsize == 0) return uv_translate_sys_error(GetLastError()); - /* Allocate the destination buffer */ - *utf8 = uv__malloc(bufsize); + /* Allocate the destination buffer adding an extra byte for the terminating + * NULL. If utf16len is not -1 WideCharToMultiByte will not add it, so + * we do it ourselves always, just in case. */ + *utf8 = uv__malloc(bufsize + 1); if (*utf8 == NULL) return UV_ENOMEM; @@ -1310,7 +1280,7 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8) { bufsize = WideCharToMultiByte(CP_UTF8, 0, utf16, - -1, + utf16len, *utf8, bufsize, NULL, @@ -1318,9 +1288,11 @@ int uv__convert_utf16_to_utf8(const WCHAR* utf16, char** utf8) { if (bufsize == 0) { uv__free(*utf8); + *utf8 = NULL; return uv_translate_sys_error(GetLastError()); } + (*utf8)[bufsize] = '\0'; return 0; } @@ -1366,13 +1338,13 @@ int uv__getpwuid_r(uv_passwd_t* pwd) { } pwd->homedir = NULL; - r = uv__convert_utf16_to_utf8(path, &pwd->homedir); + r = uv__convert_utf16_to_utf8(path, -1, &pwd->homedir); if (r != 0) return r; pwd->username = NULL; - r = uv__convert_utf16_to_utf8(username, &pwd->username); + r = uv__convert_utf16_to_utf8(username, -1, &pwd->username); if (r != 0) { uv__free(pwd->homedir); diff --git a/deps/uv/test/test-emfile.c b/deps/uv/test/test-emfile.c index dd35f785b46352..5f4dd9efdf7e77 100644 --- a/deps/uv/test/test-emfile.c +++ b/deps/uv/test/test-emfile.c @@ -38,6 +38,13 @@ static uv_tcp_t client_handle; TEST_IMPL(emfile) { +#ifdef _AIX + /* On AIX, if a 'accept' call fails ECONNRESET is set on the socket + * which causes uv__emfile_trick to not work as intended and this test + * to fail. + */ + RETURN_SKIP("uv__emfile_trick does not work on AIX"); +#endif struct sockaddr_in addr; struct rlimit limits; uv_connect_t connect_req; diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index 35583529e57507..353c43b0de4e07 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -511,7 +511,7 @@ TEST_IMPL(fs_event_watch_file_current_dir) { r = uv_timer_init(loop, &timer); ASSERT(r == 0); - r = uv_timer_start(&timer, timer_cb_touch, 10, 0); + r = uv_timer_start(&timer, timer_cb_touch, 100, 0); ASSERT(r == 0); ASSERT(timer_cb_touch_called == 0); @@ -698,18 +698,19 @@ TEST_IMPL(fs_event_close_with_pending_event) { return 0; } -#if defined(HAVE_KQUEUE) +#if defined(HAVE_KQUEUE) || defined(_AIX) /* kqueue doesn't register fs events if you don't have an active watcher. * The file descriptor needs to be part of the kqueue set of interest and * that's not the case until we actually enter the event loop. + * This is also observed on AIX with ahafs. */ TEST_IMPL(fs_event_close_in_callback) { - fprintf(stderr, "Skipping test, doesn't work with kqueue.\n"); + fprintf(stderr, "Skipping test, doesn't work with kqueue and AIX.\n"); return 0; } -#else /* !HAVE_KQUEUE */ +#else /* !HAVE_KQUEUE || !_AIX */ static void fs_event_cb_close(uv_fs_event_t* handle, const char* filename, int events, int status) { @@ -766,7 +767,7 @@ TEST_IMPL(fs_event_close_in_callback) { return 0; } -#endif /* HAVE_KQUEUE */ +#endif /* HAVE_KQUEUE || _AIX */ TEST_IMPL(fs_event_start_and_close) { uv_loop_t* loop; diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index cf37ac4909ca12..1cc1a7c064107f 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -2033,6 +2033,9 @@ TEST_IMPL(fs_stat_root) { TEST_IMPL(fs_futime) { +#if defined(_AIX) && !defined(_AIX71) + RETURN_SKIP("futime is not implemented for AIX versions below 7.1"); +#else utime_check_t checkme; const char* path = "test_file"; double atime; @@ -2087,6 +2090,7 @@ TEST_IMPL(fs_futime) { MAKE_VALGRIND_HAPPY(); return 0; +#endif } diff --git a/deps/uv/test/test-get-passwd.c b/deps/uv/test/test-get-passwd.c index 58d9c73c691cf3..8e16fb83c8f1b6 100644 --- a/deps/uv/test/test-get-passwd.c +++ b/deps/uv/test/test-get-passwd.c @@ -45,9 +45,15 @@ TEST_IMPL(get_passwd) { ASSERT(len > 0); #ifdef _WIN32 - ASSERT(pwd.homedir[len - 1] != '\\'); + if (len == 3 && pwd.homedir[1] == ':') + ASSERT(pwd.homedir[2] == '\\'); + else + ASSERT(pwd.homedir[len - 1] != '\\'); #else - ASSERT(pwd.homedir[len - 1] != '/'); + if (len == 1) + ASSERT(pwd.homedir[0] == '/'); + else + ASSERT(pwd.homedir[len - 1] != '/'); #endif #ifdef _WIN32 diff --git a/deps/uv/test/test-homedir.c b/deps/uv/test/test-homedir.c index 5027d44c1ea358..856534a40ceaa9 100644 --- a/deps/uv/test/test-homedir.c +++ b/deps/uv/test/test-homedir.c @@ -29,7 +29,6 @@ TEST_IMPL(homedir) { char homedir[PATHMAX]; size_t len; - char last; int r; /* Test the normal case */ @@ -42,14 +41,17 @@ TEST_IMPL(homedir) { ASSERT(len > 0); ASSERT(homedir[len] == '\0'); - if (len > 1) { - last = homedir[len - 1]; #ifdef _WIN32 - ASSERT(last != '\\'); + if (len == 3 && homedir[1] == ':') + ASSERT(homedir[2] == '\\'); + else + ASSERT(homedir[len - 1] != '\\'); #else - ASSERT(last != '/'); + if (len == 1) + ASSERT(homedir[0] == '/'); + else + ASSERT(homedir[len - 1] != '/'); #endif - } /* Test the case where the buffer is too small */ len = SMALLPATH; diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 8b10f1a5f68507..c93f081992a481 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -43,6 +43,9 @@ TEST_DECLARE (semaphore_1) TEST_DECLARE (semaphore_2) TEST_DECLARE (semaphore_3) TEST_DECLARE (tty) +#ifdef _WIN32 +TEST_DECLARE (tty_raw) +#endif TEST_DECLARE (tty_file) TEST_DECLARE (tty_pty) TEST_DECLARE (stdio_over_pipes) @@ -387,6 +390,9 @@ TASK_LIST_START #endif TEST_ENTRY (pipe_set_non_blocking) TEST_ENTRY (tty) +#ifdef _WIN32 + TEST_ENTRY (tty_raw) +#endif TEST_ENTRY (tty_file) TEST_ENTRY (tty_pty) TEST_ENTRY (stdio_over_pipes) diff --git a/deps/uv/test/test-platform-output.c b/deps/uv/test/test-platform-output.c index 2c4740550a198c..bd61454fa7c742 100644 --- a/deps/uv/test/test-platform-output.c +++ b/deps/uv/test/test-platform-output.c @@ -61,6 +61,8 @@ TEST_IMPL(platform_output) { ASSERT(rusage.ru_utime.tv_usec >= 0); ASSERT(rusage.ru_stime.tv_sec >= 0); ASSERT(rusage.ru_stime.tv_usec >= 0); + ASSERT(rusage.ru_majflt >= 0); + ASSERT(rusage.ru_maxrss >= 0); printf("uv_getrusage:\n"); printf(" user: %llu sec %llu microsec\n", (unsigned long long) rusage.ru_utime.tv_sec, @@ -68,6 +70,9 @@ TEST_IMPL(platform_output) { printf(" system: %llu sec %llu microsec\n", (unsigned long long) rusage.ru_stime.tv_sec, (unsigned long long) rusage.ru_stime.tv_usec); + printf(" page faults: %llu\n", (unsigned long long) rusage.ru_majflt); + printf(" maximum resident set size: %llu\n", + (unsigned long long) rusage.ru_maxrss); err = uv_cpu_info(&cpus, &count); ASSERT(err == 0); diff --git a/deps/uv/test/test-poll.c b/deps/uv/test/test-poll.c index bfb75af13355ab..f3cfe7977753c4 100644 --- a/deps/uv/test/test-poll.c +++ b/deps/uv/test/test-poll.c @@ -72,8 +72,9 @@ static int closed_connections = 0; static int valid_writable_wakeups = 0; static int spurious_writable_wakeups = 0; +#ifndef _AIX static int disconnects = 0; - +#endif /* !_AIX */ static int got_eagain(void) { #ifdef _WIN32 @@ -377,7 +378,7 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { new_events &= ~UV_WRITABLE; } } - +#ifndef _AIX if (events & UV_DISCONNECT) { context->got_disconnect = 1; ++disconnects; @@ -385,6 +386,9 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) { } if (context->got_fin && context->sent_fin && context->got_disconnect) { +#else /* _AIX */ + if (context->got_fin && context->sent_fin) { +#endif /* !_AIx */ /* Sent and received FIN. Close and destroy context. */ close_socket(context->sock); destroy_connection_context(context); @@ -552,8 +556,9 @@ static void start_poll_test(void) { spurious_writable_wakeups > 20); ASSERT(closed_connections == NUM_CLIENTS * 2); +#ifndef _AIX ASSERT(disconnects == NUM_CLIENTS * 2); - +#endif MAKE_VALGRIND_HAPPY(); } diff --git a/deps/uv/test/test-tcp-create-socket-early.c b/deps/uv/test/test-tcp-create-socket-early.c index 65650adcc27919..1a508e474aa700 100644 --- a/deps/uv/test/test-tcp-create-socket-early.c +++ b/deps/uv/test/test-tcp-create-socket-early.c @@ -139,6 +139,9 @@ TEST_IMPL(tcp_create_early_bad_bind) { uv_os_fd_t fd; int r; + if (!can_ipv6()) + RETURN_SKIP("IPv6 not supported"); + ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_tcp_init_ex(uv_default_loop(), &client, AF_INET6); diff --git a/deps/uv/test/test-tcp-write-queue-order.c b/deps/uv/test/test-tcp-write-queue-order.c index aa4d2acc24ab30..8a98ab83667934 100644 --- a/deps/uv/test/test-tcp-write-queue-order.c +++ b/deps/uv/test/test-tcp-write-queue-order.c @@ -107,6 +107,7 @@ static void start_server(void) { TEST_IMPL(tcp_write_queue_order) { uv_connect_t connect_req; struct sockaddr_in addr; + int buffer_size = 16 * 1024; start_server(); @@ -117,6 +118,7 @@ TEST_IMPL(tcp_write_queue_order) { &client, (struct sockaddr*) &addr, connect_cb)); + ASSERT(0 == uv_send_buffer_size((uv_handle_t*) &client, &buffer_size)); ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); ASSERT(0 == uv_timer_start(&timer, timer_cb, 100, 0)); diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index 461d1941359018..55cc016752d31b 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -146,6 +146,75 @@ TEST_IMPL(tty) { } +#ifdef _WIN32 +static void tty_raw_alloc(uv_handle_t* handle, size_t size, uv_buf_t* buf) { + buf->base = malloc(size); + buf->len = size; +} + +static void tty_raw_read(uv_stream_t* tty_in, ssize_t nread, const uv_buf_t* buf) { + if (nread > 0) { + ASSERT(nread == 1); + ASSERT(buf->base[0] == ' '); + uv_close((uv_handle_t*) tty_in, NULL); + } else { + ASSERT(nread == 0); + } +} + +TEST_IMPL(tty_raw) { + int r; + int ttyin_fd; + uv_tty_t tty_in; + uv_loop_t* loop = uv_default_loop(); + HANDLE handle; + INPUT_RECORD record; + DWORD written; + + /* Make sure we have an FD that refers to a tty */ + handle = CreateFileA("conin$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyin_fd = _open_osfhandle((intptr_t) handle, 0); + ASSERT(ttyin_fd >= 0); + ASSERT(UV_TTY == uv_guess_handle(ttyin_fd)); + + r = uv_tty_init(uv_default_loop(), &tty_in, ttyin_fd, 1); /* Readable. */ + ASSERT(r == 0); + + r = uv_read_start((uv_stream_t*)&tty_in, tty_raw_alloc, tty_raw_read); + ASSERT(r == 0); + + /* Give uv_tty_line_read_thread time to block on ReadConsoleW */ + Sleep(100); + + /* Turn on raw mode. */ + r = uv_tty_set_mode(&tty_in, UV_TTY_MODE_RAW); + ASSERT(r == 0); + + /* Write ' ' that should be read in raw mode */ + record.EventType = KEY_EVENT; + record.Event.KeyEvent.bKeyDown = TRUE; + record.Event.KeyEvent.wRepeatCount = 1; + record.Event.KeyEvent.wVirtualKeyCode = VK_SPACE; + record.Event.KeyEvent.wVirtualScanCode = MapVirtualKeyW(VK_SPACE, MAPVK_VK_TO_VSC); + record.Event.KeyEvent.uChar.UnicodeChar = L' '; + record.Event.KeyEvent.dwControlKeyState = 0; + WriteConsoleInputW(handle, &record, 1, &written); + + uv_run(loop, UV_RUN_DEFAULT); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif + + TEST_IMPL(tty_file) { #ifndef _WIN32 uv_loop_t loop; diff --git a/deps/uv/test/test-udp-create-socket-early.c b/deps/uv/test/test-udp-create-socket-early.c index 3d0152428b8bc9..3f3027404700f4 100644 --- a/deps/uv/test/test-udp-create-socket-early.c +++ b/deps/uv/test/test-udp-create-socket-early.c @@ -79,6 +79,9 @@ TEST_IMPL(udp_create_early_bad_bind) { uv_os_fd_t fd; int r; + if (!can_ipv6()) + RETURN_SKIP("IPv6 not supported"); + ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); r = uv_udp_init_ex(uv_default_loop(), &client, AF_INET6); diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 757540193dd7a2..2fdd59ac784300 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -17,6 +17,7 @@ }], ], 'xcode_settings': { + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden 'WARNING_CFLAGS': [ '-Wall', '-Wextra', '-Wno-unused-parameter' ], 'OTHER_CFLAGS': [ '-g', '--std=gnu89', '-pedantic' ], } @@ -111,12 +112,14 @@ '-liphlpapi', '-lpsapi', '-lshell32', + '-luser32', '-luserenv', '-lws2_32' ], }, }, { # Not Windows i.e. POSIX 'cflags': [ + '-fvisibility=hidden', '-g', '--std=gnu89', '-pedantic', @@ -184,6 +187,7 @@ 'src/unix/darwin.c', 'src/unix/fsevents.c', 'src/unix/darwin-proctitle.c', + 'src/unix/pthread-barrier.c' ], 'defines': [ '_DARWIN_USE_64_BIT_INODE=1', @@ -214,7 +218,8 @@ 'src/unix/linux-syscalls.c', 'src/unix/linux-syscalls.h', 'src/unix/pthread-fixes.c', - 'src/unix/android-ifaddrs.c' + 'src/unix/android-ifaddrs.c', + 'src/unix/pthread-barrier.c' ], 'link_settings': { 'libraries': [ '-ldl' ], diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 9a7ed4b8c512e0..91f45b72195301 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -19,7 +19,7 @@ set nobuild= set run= set target_arch=ia32 set vs_toolset=x86 -set platform=WIN32 +set msbuild_platform=WIN32 set library=static_library :next-arg @@ -31,9 +31,9 @@ if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok if /i "%1"=="clean" set target=Clean&goto arg-ok if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok -if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok -if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok -if /i "%1"=="x64" set target_arch=x64&set platform=x64&set vs_toolset=x64&goto arg-ok +if /i "%1"=="x86" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok +if /i "%1"=="ia32" set target_arch=ia32&set msbuild_platform=WIN32&set vs_toolset=x86&goto arg-ok +if /i "%1"=="x64" set target_arch=x64&set msbuild_platform=x64&set vs_toolset=x64&goto arg-ok if /i "%1"=="shared" set library=shared_library&goto arg-ok if /i "%1"=="static" set library=static_library&goto arg-ok :arg-ok @@ -132,7 +132,7 @@ goto run @rem Build the sln with msbuild. :msbuild-found -msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo +msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%msbuild_platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 exit /b 1 :run From 7779639a11b2df96a1ebac309138bfae056229dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 18 May 2016 15:13:04 +0100 Subject: [PATCH 056/261] unix,stream: fix getting the correct fd for a handle On OSX it's possible that the fd is replaced, so use the proper libuv API to get the correct fd. PR-URL: https://github.com/nodejs/node/pull/6753 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/stream_wrap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index e6236a6e529864..7118a9e573f4c2 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -91,7 +91,7 @@ int StreamWrap::GetFD() { int fd = -1; #if !defined(_WIN32) if (stream() != nullptr) - fd = stream()->io_watcher.fd; + uv_fileno(reinterpret_cast(stream()), &fd); #endif return fd; } From b07c3a6ea61cabeb048e18616d8d13adfaf9ec9f Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 20 May 2016 10:20:08 -0400 Subject: [PATCH 057/261] tty: use blocking mode on OS X OS X has a tiny 1kb hard-coded buffer size for stdout / stderr to TTYs (terminals). Output larger than that causes chunking, which ends up having some (very small but existent) delay past the first chunk. That causes two problems: 1. When output is written to stdout and stderr at similar times, the two can become mixed together (interleaved). This is especially problematic when using control characters, such as \r. With interleaving, chunked output will often have lines or characters erased unintentionally, or in the wrong spots, leading to broken output. CLI apps often extensively use such characters for things such as progress bars. 2. Output can be lost if the process is exited before chunked writes are finished flushing. This usually happens in applications that use `process.exit()`, which isn't infrequent. See https://github.com/nodejs/node/issues/6980 for more info. This became an issue as result of the Libuv 1.9.0 upgrade. A fix to an unrelated issue broke a hack previously required for the OS X implementation. This resulted in an unexpected behavior change in node. The 1.9.0 upgrade was done in c3cec1eefc9f3b55a3fb7bd623b3d921f493870d, which was included in v6.0.0. Full details of the Libuv issue that induced this are at https://github.com/nodejs/node/issues/6456#issuecomment-219974514 Refs: https://github.com/nodejs/node/pull/1771 Refs: https://github.com/nodejs/node/issues/6456 Refs: https://github.com/nodejs/node/pull/6773 Refs: https://github.com/nodejs/node/pull/6816 PR-URL: https://github.com/nodejs/node/pull/6895 Reviewed-By: Rod Vagg Reviewed-By: Anna Henningsen --- doc/api/console.md | 6 +++++- doc/api/process.md | 10 +++++++++- lib/tty.js | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/api/console.md b/doc/api/console.md index 67d82a3ed55eab..ead2c3607011a5 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -53,11 +53,15 @@ duplicate the browser's functionality exactly. ## Asynchronous vs Synchronous Consoles -The console functions are asynchronous unless the destination is a file. +The console functions are usually asynchronous unless the destination is a file. Disks are fast and operating systems normally employ write-back caching; it should be a very rare occurrence indeed that a write blocks, but it is possible. +Additionally, console functions are blocking when outputting to TTYs +(terminals) on OS X as a workaround for the OS's very small, 1kb buffer size. +This is to prevent interleaving between `stdout` and `stderr`. + ## Class: Console diff --git a/doc/api/process.md b/doc/api/process.md index 494a57ffe6be33..eb14cc7158e019 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -957,6 +957,10 @@ event and that writes can block when output is redirected to a file (although disks are fast and operating systems normally employ write-back caching so it should be a very rare occurrence indeed.) +Additionally, `process.stderr` and `process.stdout` are blocking when outputting +to TTYs (terminals) on OS X as a workaround for the OS's very small, 1kb +buffer size. This is to prevent interleaving between `stdout` and `stderr`. + ## process.stdin A `Readable Stream` for stdin (on fd `0`). @@ -1007,6 +1011,10 @@ event and that writes can block when output is redirected to a file (although disks are fast and operating systems normally employ write-back caching so it should be a very rare occurrence indeed.) +Additionally, `process.stderr` and `process.stdout` are blocking when outputting +to TTYs (terminals) on OS X as a workaround for the OS's very small, 1kb +buffer size. This is to prevent interleaving between `stdout` and `stderr`. + To check if Node.js is being run in a TTY context, read the `isTTY` property on `process.stderr`, `process.stdout`, or `process.stdin`: @@ -1102,4 +1110,4 @@ Will print something like: [Signal Events]: #process_signal_events [Stream compatibility]: stream.html#stream_compatibility_with_older_node_js_versions [the tty docs]: tty.html#tty_tty -[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify \ No newline at end of file +[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify diff --git a/lib/tty.js b/lib/tty.js index f3f84ca5a6e9f7..54a7b756ec9544 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -59,6 +59,13 @@ function WriteStream(fd) { writable: true }); + // Prevents interleaved stdout/stderr output in OS X terminals. + // As noted in the following reference, local TTYs tend to be quite fast and + // this behaviour has become expected due historical functionality on OS X, + // even though it was originally intended to change in v1.0.2 (Libuv 1.2.1). + // Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671 + if (process.platform === 'darwin') this._handle.setBlocking(true); + var winSize = []; var err = this._handle.getWindowSize(winSize); if (!err) { From a1719a94e9c5d4e0fd5adcb7599ae8428a1b642e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Sat, 21 May 2016 00:01:48 +0200 Subject: [PATCH 058/261] udp: use libuv API to get file descriptor Refs: https://github.com/nodejs/node/pull/6838 PR-URL: https://github.com/nodejs/node/pull/6908 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/udp_wrap.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 8c460ebac6ff22..e395ee85e0852e 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -136,12 +136,14 @@ void UDPWrap::New(const FunctionCallbackInfo& args) { void UDPWrap::GetFD(Local, const PropertyCallbackInfo& args) { + int fd = -1; #if !defined(_WIN32) HandleScope scope(args.GetIsolate()); UDPWrap* wrap = Unwrap(args.Holder()); - int fd = (wrap == nullptr) ? -1 : wrap->handle_.io_watcher.fd; - args.GetReturnValue().Set(fd); + if (wrap != nullptr) + uv_fileno(reinterpret_cast(&wrap->handle_), &fd); #endif + args.GetReturnValue().Set(fd); } From 01b314d165d3f4b8d7b7ca3151dd0066c7a8ee23 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 20 May 2016 19:05:54 -0400 Subject: [PATCH 059/261] test: test TTY problems by fakeing a TTY using openpty Many thanks to thefourtheye and addaleax who helped make the python bits of this possible. See https://github.com/nodejs/node/issues/6980 for more info regarding the related TTY issues. Refs: https://github.com/nodejs/node/issues/6456 Refs: https://github.com/nodejs/node/pull/6773 Refs: https://github.com/nodejs/node/pull/6816 PR-URL: https://github.com/nodejs/node/pull/6895 Reviewed-By: Rod Vagg Reviewed-By: Anna Henningsen --- Makefile | 4 +- test/pseudo-tty/no_dropped_stdio.js | 15 +++ test/pseudo-tty/no_dropped_stdio.out | 21 +++ test/pseudo-tty/no_interleaved_stdio.js | 17 +++ test/pseudo-tty/no_interleaved_stdio.out | 21 +++ test/pseudo-tty/testcfg.py | 161 +++++++++++++++++++++++ tools/test.py | 67 ++++++++-- 7 files changed, 292 insertions(+), 14 deletions(-) create mode 100644 test/pseudo-tty/no_dropped_stdio.js create mode 100644 test/pseudo-tty/no_dropped_stdio.out create mode 100644 test/pseudo-tty/no_interleaved_stdio.js create mode 100644 test/pseudo-tty/no_interleaved_stdio.out create mode 100644 test/pseudo-tty/testcfg.py diff --git a/Makefile b/Makefile index 55107392d35f11..5c16b9b66c5a35 100644 --- a/Makefile +++ b/Makefile @@ -111,7 +111,7 @@ v8: $(MAKE) -C deps/v8 $(V8_ARCH) $(V8_BUILD_OPTIONS) test: | cctest # Depends on 'all'. - $(PYTHON) tools/test.py --mode=release doctool message parallel sequential -J + $(PYTHON) tools/test.py --mode=release doctool message pseudo-tty parallel sequential -J $(MAKE) jslint $(MAKE) cpplint @@ -167,7 +167,7 @@ test-all-valgrind: test-build $(PYTHON) tools/test.py --mode=debug,release --valgrind CI_NATIVE_SUITES := addons -CI_JS_SUITES := doctool message parallel sequential +CI_JS_SUITES := doctool message parallel pseudo-tty sequential # Build and test addons without building anything else test-ci-native: | test/addons/.buildstamp diff --git a/test/pseudo-tty/no_dropped_stdio.js b/test/pseudo-tty/no_dropped_stdio.js new file mode 100644 index 00000000000000..1a20889073ce06 --- /dev/null +++ b/test/pseudo-tty/no_dropped_stdio.js @@ -0,0 +1,15 @@ +// https://github.com/nodejs/node/issues/6456#issuecomment-219320599 +// https://gist.github.com/isaacs/1495b91ec66b21d30b10572d72ad2cdd +'use strict'; +require('../common'); + +// 1000 bytes wrapped at 50 columns +// \n turns into a double-byte character +// (48 + {2}) * 20 = 1000 +var out = ('o'.repeat(48) + '\n').repeat(20); +// Add the remaining 24 bytes and terminate with an 'O'. +// This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer. +out += 'o'.repeat(24) + 'O'; + +process.stdout.write(out); +process.exit(0); diff --git a/test/pseudo-tty/no_dropped_stdio.out b/test/pseudo-tty/no_dropped_stdio.out new file mode 100644 index 00000000000000..78d2b7a36523a2 --- /dev/null +++ b/test/pseudo-tty/no_dropped_stdio.out @@ -0,0 +1,21 @@ +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +ooooooooooooooooooooooooO diff --git a/test/pseudo-tty/no_interleaved_stdio.js b/test/pseudo-tty/no_interleaved_stdio.js new file mode 100644 index 00000000000000..778b2c09583b90 --- /dev/null +++ b/test/pseudo-tty/no_interleaved_stdio.js @@ -0,0 +1,17 @@ +// https://github.com/nodejs/node/issues/6456#issuecomment-219320599 +// https://gist.github.com/isaacs/1495b91ec66b21d30b10572d72ad2cdd +'use strict'; +require('../common'); + +// 1000 bytes wrapped at 50 columns +// \n turns into a double-byte character +// (48 + {2}) * 20 = 1000 +var out = ('o'.repeat(48) + '\n').repeat(20); +// Add the remaining 24 bytes and terminate with an 'O'. +// This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer. +out += 'o'.repeat(24) + 'O'; + +const err = '__This is some stderr__'; + +process.stdout.write(out); +process.stderr.write(err); diff --git a/test/pseudo-tty/no_interleaved_stdio.out b/test/pseudo-tty/no_interleaved_stdio.out new file mode 100644 index 00000000000000..f39b87ff466725 --- /dev/null +++ b/test/pseudo-tty/no_interleaved_stdio.out @@ -0,0 +1,21 @@ +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +oooooooooooooooooooooooooooooooooooooooooooooooo +ooooooooooooooooooooooooO__This is some stderr__ diff --git a/test/pseudo-tty/testcfg.py b/test/pseudo-tty/testcfg.py new file mode 100644 index 00000000000000..469903152101c1 --- /dev/null +++ b/test/pseudo-tty/testcfg.py @@ -0,0 +1,161 @@ +# Copyright 2008 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import test +import os +from os.path import join, exists, basename, isdir +import re +import utils + +FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") + +class TTYTestCase(test.TestCase): + + def __init__(self, path, file, expected, arch, mode, context, config): + super(TTYTestCase, self).__init__(context, path, arch, mode) + self.file = file + self.expected = expected + self.config = config + self.arch = arch + self.mode = mode + + def IgnoreLine(self, str): + """Ignore empty lines and valgrind output.""" + if not str.strip(): return True + else: return str.startswith('==') or str.startswith('**') + + def IsFailureOutput(self, output): + f = file(self.expected) + # Convert output lines to regexps that we can match + env = { 'basename': basename(self.file) } + patterns = [ ] + for line in f: + if not line.strip(): + continue + pattern = re.escape(line.rstrip() % env) + pattern = pattern.replace('\\*', '.*') + pattern = '^%s$' % pattern + patterns.append(pattern) + # Compare actual output with the expected + raw_lines = (output.stdout + output.stderr).split('\n') + outlines = [ s.strip() for s in raw_lines if not self.IgnoreLine(s) ] + if len(outlines) != len(patterns): + print "length differs." + print "expect=%d" % len(patterns) + print "actual=%d" % len(outlines) + print "patterns:" + for i in xrange(len(patterns)): + print "pattern = %s" % patterns[i] + print "outlines:" + for i in xrange(len(outlines)): + print "outline = %s" % outlines[i] + return True + for i in xrange(len(patterns)): + if not re.match(patterns[i], outlines[i]): + print "match failed" + print "line=%d" % i + print "expect=%s" % patterns[i] + print "actual=%s" % outlines[i] + return True + return False + + def GetLabel(self): + return "%s %s" % (self.mode, self.GetName()) + + def GetName(self): + return self.path[-1] + + def GetCommand(self): + result = [self.config.context.GetVm(self.arch, self.mode)] + source = open(self.file).read() + flags_match = FLAGS_PATTERN.search(source) + if flags_match: + result += flags_match.group(1).strip().split() + result.append(self.file) + return result + + def GetSource(self): + return (open(self.file).read() + + "\n--- expected output ---\n" + + open(self.expected).read()) + + def RunCommand(self, command, env): + full_command = self.context.processor(command) + output = test.Execute(full_command, + self.context, + self.context.GetTimeout(self.mode), + env, + True) + self.Cleanup() + return test.TestOutput(self, + full_command, + output, + self.context.store_unexpected_output) + + +class TTYTestConfiguration(test.TestConfiguration): + + def __init__(self, context, root): + super(TTYTestConfiguration, self).__init__(context, root) + + def Ls(self, path): + if isdir(path): + return [f[:-3] for f in os.listdir(path) if f.endswith('.js')] + else: + return [] + + def ListTests(self, current_path, path, arch, mode): + all_tests = [current_path + [t] for t in self.Ls(self.root)] + result = [] + # Skip these tests on Windows, as pseudo terminals are not available + if utils.IsWindows(): + print ("Skipping pseudo-tty tests, as pseudo terminals are not available" + " on Windows.") + return result + for test in all_tests: + if self.Contains(path, test): + file_prefix = join(self.root, reduce(join, test[1:], "")) + file_path = file_prefix + ".js" + output_path = file_prefix + ".out" + if not exists(output_path): + print "Could not find %s" % output_path + continue + result.append(TTYTestCase(test, file_path, output_path, + arch, mode, self.context, self)) + return result + + def GetBuildRequirements(self): + return ['sample', 'sample=shell'] + + def GetTestStatus(self, sections, defs): + status_file = join(self.root, 'message.status') + if exists(status_file): + test.ReadConfigurationInto(status_file, sections, defs) + + +def GetConfiguration(context, root): + return TTYTestConfiguration(context, root) diff --git a/tools/test.py b/tools/test.py index 8b66b3136769b7..d50fd5b4662c36 100755 --- a/tools/test.py +++ b/tools/test.py @@ -575,11 +575,17 @@ def RunProcess(context, timeout, args, **rest): error_mode = SEM_NOGPFAULTERRORBOX; prev_error_mode = Win32SetErrorMode(error_mode); Win32SetErrorMode(error_mode | prev_error_mode); + + faketty = rest.pop('faketty', False) + pty_out = rest.pop('pty_out') + process = subprocess.Popen( shell = utils.IsWindows(), args = popen_args, **rest ) + if faketty: + os.close(rest['stdout']) if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_INVALID_VALUE: Win32SetErrorMode(prev_error_mode) # Compute the end time - if the process crosses this limit we @@ -591,6 +597,29 @@ def RunProcess(context, timeout, args, **rest): # loop and keep track of whether or not it times out. exit_code = None sleep_time = INITIAL_SLEEP_TIME + output = '' + if faketty: + while True: + if time.time() >= end_time: + # Kill the process and wait for it to exit. + KillProcessWithID(process.pid) + exit_code = process.wait() + timed_out = True + break + + # source: http://stackoverflow.com/a/12471855/1903116 + # related: http://stackoverflow.com/q/11165521/1903116 + try: + data = os.read(pty_out, 9999) + except OSError as e: + if e.errno != errno.EIO: + raise + break # EIO means EOF on some systems + else: + if not data: # EOF + break + output += data + while exit_code is None: if (not end_time is None) and (time.time() >= end_time): # Kill the process and wait for it to exit. @@ -603,7 +632,7 @@ def RunProcess(context, timeout, args, **rest): sleep_time = sleep_time * SLEEP_TIME_FACTOR if sleep_time > MAX_SLEEP_TIME: sleep_time = MAX_SLEEP_TIME - return (process, exit_code, timed_out) + return (process, exit_code, timed_out, output) def PrintError(str): @@ -625,29 +654,43 @@ def CheckedUnlink(name): PrintError("os.unlink() " + str(e)) break -def Execute(args, context, timeout=None, env={}): - (fd_out, outname) = tempfile.mkstemp() - (fd_err, errname) = tempfile.mkstemp() +def Execute(args, context, timeout=None, env={}, faketty=False): + if faketty: + import pty + (out_master, fd_out) = pty.openpty() + fd_err = fd_out + pty_out = out_master + else: + (fd_out, outname) = tempfile.mkstemp() + (fd_err, errname) = tempfile.mkstemp() + pty_out = None # Extend environment env_copy = os.environ.copy() for key, value in env.iteritems(): env_copy[key] = value - (process, exit_code, timed_out) = RunProcess( + (process, exit_code, timed_out, output) = RunProcess( context, timeout, args = args, stdout = fd_out, stderr = fd_err, - env = env_copy + env = env_copy, + faketty = faketty, + pty_out = pty_out ) - os.close(fd_out) - os.close(fd_err) - output = file(outname).read() - errors = file(errname).read() - CheckedUnlink(outname) - CheckedUnlink(errname) + if faketty: + os.close(out_master) + errors = '' + else: + os.close(fd_out) + os.close(fd_err) + output = file(outname).read() + errors = file(errname).read() + CheckedUnlink(outname) + CheckedUnlink(errname) + return CommandOutput(exit_code, timed_out, output, errors) From b21d145c2a20533839abd86fabfef03a2edf8463 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Sep 2015 21:42:25 +0800 Subject: [PATCH 060/261] src: add node::FreeEnvironment public API Since debugger::Agent's interface is not exported, third party embedders will have linking errors if they call Environment's destructor directly. PR-URL: https://github.com/nodejs/node/pull/3098 Reviewed-By: Ben Noordhuis --- src/node.cc | 7 +++++++ src/node.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/node.cc b/src/node.cc index 2068488b9ea7b7..12219b026d63b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3226,6 +3226,13 @@ void LoadEnvironment(Environment* env) { f->Call(global, 1, &arg); } + +void FreeEnvironment(Environment* env) { + CHECK_NE(env, nullptr); + env->Dispose(); +} + + static void PrintHelp(); static bool ParseDebugOpt(const char* arg) { diff --git a/src/node.h b/src/node.h index ef1f629d20aa0e..f70b5f8e784382 100644 --- a/src/node.h +++ b/src/node.h @@ -196,6 +196,7 @@ NODE_EXTERN Environment* CreateEnvironment(v8::Isolate* isolate, int exec_argc, const char* const* exec_argv); NODE_EXTERN void LoadEnvironment(Environment* env); +NODE_EXTERN void FreeEnvironment(Environment* env); // NOTE: Calling this is the same as calling // CreateEnvironment() + LoadEnvironment() from above. From f0edf87df15b0d1f2cb0c45403e11c6e55ba5fc8 Mon Sep 17 00:00:00 2001 From: Robert Jefe Lindstaedt Date: Thu, 21 Apr 2016 09:59:10 +0200 Subject: [PATCH 061/261] doc: add vm example, be able to require modules The intention behind is to present the user a way to execute code in a vm context. The current API doesn't allow this out-of-the-box, since it is neither passing a require function nor creating context with one. The missing docs for this behaviour have produced a number of Q&A items and have also been discussed in the node-archive repo. In both cases there was no real canonical answer. Refs: nodejs/node-v0.x-archive#9211, #4955 PR-URL: https://github.com/nodejs/node/pull/5323 Reviewed-By: James M Snell Reviewed-By: Stephen Belanger Reviewed-By: Myles Borins Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Benjamin Gruenbaum --- doc/api/vm.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/api/vm.md b/doc/api/vm.md index 4cccc12378631e..d53c8dc8d70850 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -297,6 +297,39 @@ e.g. `(0,eval)('code')`. However, it also has the following additional options: - `timeout`: a number of milliseconds to execute `code` before terminating execution. If execution is terminated, an [`Error`][] will be thrown. +## Example: Run a Server within a VM + +The context of `.runInThisContext()` refers to the V8 context. The code passed +to this VM context will have it's own isolated scope. To run a simple web server +using the `http` module, for instance, the code passed to the context must either +call `require('http')` on its own, or have a reference to the `http` module passed +to it. For instance: + +```js +'use strict'; +const vm = require('vm'); + +let code = +`(function(require) { + + const http = require('http'); + + http.createServer( (request, response) => { + response.writeHead(200, {'Content-Type': 'text/plain'}); + response.end('Hello World\\n'); + }).listen(8124); + + console.log('Server running at http://127.0.0.1:8124/'); + })`; + + vm.runInThisContext(code)(require); + ``` + +_Note: `require()` in the above case shares the state with context it is passed +from. This might introduce risks when unknown code is executed, e.g. altering +objects from the calling thread's context in unwanted ways. It is advisable to +run `vm` code in a separate process._ + [indirect `eval()` call]: https://es5.github.io/#x10.4.2 [global object]: https://es5.github.io/#x15.1 [`Error`]: errors.html#errors_class_error From a3fa5db5ca6ae28e449a8a72e15dcd326f4cdbc2 Mon Sep 17 00:00:00 2001 From: Eugene Obrezkov Date: Fri, 13 May 2016 10:54:31 +0300 Subject: [PATCH 062/261] repl: copying tabs shouldn't trigger completion PR-URL: https://github.com/nodejs/node/pull/5958 Fixes: https://github.com/nodejs/node/issues/5954 Reviewed-By: Anna Henningsen Reviewed-By: Jeremiah Senkpiel --- doc/api/readline.md | 7 +++++++ lib/readline.js | 15 ++++++++++++--- test/parallel/test-readline-interface.js | 4 +++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index c2b77c524533bf..e48865ac04a40a 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -354,6 +354,13 @@ a `'resize'` event on the `output` if/when the columns ever change Move cursor to the specified position in a given TTY stream. +## readline.emitKeypressEvents(stream[, interface]) + +Causes `stream` to begin emitting `'keypress'` events corresponding to its +input. +Optionally, `interface` specifies a `readline.Interface` instance for which +autocompletion is disabled when copy-pasted input is detected. + ## readline.moveCursor(stream, dx, dy) Move cursor relative to it's current position in a given TTY stream. diff --git a/lib/readline.js b/lib/readline.js index 2e799e21a3233a..1ff09d1db66e5a 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -36,6 +36,7 @@ function Interface(input, output, completer, terminal) { } this._sawReturn = false; + this.isCompletionEnabled = true; EventEmitter.call(this); var historySize; @@ -122,7 +123,7 @@ function Interface(input, output, completer, terminal) { } else { - exports.emitKeypressEvents(input); + exports.emitKeypressEvents(input, this); // input usually refers to stdin input.on('keypress', onkeypress); @@ -868,7 +869,7 @@ Interface.prototype._ttyWrite = function(s, key) { case 'tab': // If tab completion enabled, do that... - if (typeof this.completer === 'function') { + if (typeof this.completer === 'function' && this.isCompletionEnabled) { this._tabComplete(); break; } @@ -902,7 +903,7 @@ exports.Interface = Interface; const KEYPRESS_DECODER = Symbol('keypress-decoder'); const ESCAPE_DECODER = Symbol('escape-decoder'); -function emitKeypressEvents(stream) { +function emitKeypressEvents(stream, iface) { if (stream[KEYPRESS_DECODER]) return; var StringDecoder = require('string_decoder').StringDecoder; // lazy load stream[KEYPRESS_DECODER] = new StringDecoder('utf8'); @@ -915,6 +916,10 @@ function emitKeypressEvents(stream) { var r = stream[KEYPRESS_DECODER].write(b); if (r) { for (var i = 0; i < r.length; i++) { + if (r[i] === '\t' && typeof r[i + 1] === 'string' && iface) { + iface.isCompletionEnabled = false; + } + try { stream[ESCAPE_DECODER].next(r[i]); } catch (err) { @@ -923,6 +928,10 @@ function emitKeypressEvents(stream) { stream[ESCAPE_DECODER] = emitKeys(stream); stream[ESCAPE_DECODER].next(); throw err; + } finally { + if (iface) { + iface.isCompletionEnabled = true; + } } } } diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 5e9842acb00084..4997b6e9bdb60b 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -208,7 +208,9 @@ function isWarned(emitter) { assert.strictEqual(called, false); called = true; }); - fi.emit('data', '\tfo\to\t'); + for (var character of '\tfo\to\t') { + fi.emit('data', character); + } fi.emit('data', '\n'); assert.ok(called); rli.close(); From 5380743208085af3dcb2b6a3b12b9772129e269d Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Sat, 9 Apr 2016 10:18:13 +0530 Subject: [PATCH 063/261] doc: document socket.destroyed Fixes: https://github.com/nodejs/node/issues/5898 PR-URL: https://github.com/nodejs/node/pull/6128 Reviewed-By: Colin Ihrig --- doc/api/net.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/net.md b/doc/api/net.md index 0e2fc4f8e4c406..a5590bdad1491b 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -397,6 +397,11 @@ with options either as either `{port: port, host: host}` or `{path: path}`. Ensures that no more I/O activity happens on this socket. Only necessary in case of errors (parse error or so). +### socket.destroyed + +A Boolean value that indicates if the connection is destroyed or not. Once a +connection is destroyed no further data can be transferred using it. + ### socket.end([data][, encoding]) Half-closes the socket. i.e., it sends a FIN packet. It is possible the From 39e24742f83460c4820290b1eaa76d53e7672ce4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 27 Apr 2016 14:40:24 -0700 Subject: [PATCH 064/261] assert: allow circular references assert.deepEqual() and assert.deepStrictEqual() will no longer throw a RangeError if passed objects with circular references. PR-URL: https://github.com/nodejs/node/pull/6432 Fixes: https://github.com/nodejs/node/issues/6416 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/assert.js | 21 +++++++++++++++++---- test/parallel/test-assert.js | 32 ++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index f94bf63cae7edc..93b5876487deda 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -143,7 +143,7 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { } }; -function _deepEqual(actual, expected, strict) { +function _deepEqual(actual, expected, strict, memos) { // 7.1. All identical values are equivalent, as determined by ===. if (actual === expected) { return true; @@ -191,7 +191,19 @@ function _deepEqual(actual, expected, strict) { // corresponding key, and an identical 'prototype' property. Note: this // accounts for both named and indexed properties on Arrays. } else { - return objEquiv(actual, expected, strict); + memos = memos || {actual: [], expected: []}; + + const actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); } } @@ -199,7 +211,7 @@ function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } -function objEquiv(a, b, strict) { +function objEquiv(a, b, strict, actualVisitedObjects) { if (a === null || a === undefined || b === null || b === undefined) return false; // if one is a primitive, the other must be same @@ -235,7 +247,8 @@ function objEquiv(a, b, strict) { //~~~possibly expensive deep test for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; - if (!_deepEqual(a[key], b[key], strict)) return false; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; } return true; } diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 80af439e7f36ec..a97809b88bf3db 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -380,25 +380,33 @@ try { assert.ok(threw); -// GH-207. Make sure deepEqual doesn't loop forever on circular refs -var b = {}; -b.b = b; +// https://github.com/nodejs/node/issues/6416 +// Make sure circular refs don't throw. +{ + const b = {}; + b.b = b; -var c = {}; -c.b = c; + const c = {}; + c.b = c; -var gotError = false; -try { - assert.deepEqual(b, c); -} catch (e) { - gotError = true; -} + a.doesNotThrow(makeBlock(a.deepEqual, b, c)); + a.doesNotThrow(makeBlock(a.deepStrictEqual, b, c)); + const d = {}; + d.a = 1; + d.b = d; + + const e = {}; + e.a = 1; + e.b = e.a; + + a.throws(makeBlock(a.deepEqual, d, e), /AssertionError/); + a.throws(makeBlock(a.deepStrictEqual, d, e), /AssertionError/); +} // GH-7178. Ensure reflexivity of deepEqual with `arguments` objects. var args = (function() { return arguments; })(); a.throws(makeBlock(a.deepEqual, [], args)); a.throws(makeBlock(a.deepEqual, args, [])); -assert.ok(gotError); var circular = {y: 1}; From 5f444ed6a3beeb009dc555945353551bf7e6dc45 Mon Sep 17 00:00:00 2001 From: Alex J Burke Date: Thu, 12 May 2016 23:09:13 +0100 Subject: [PATCH 065/261] test: add tests for stream3 buffering using cork adds 2 new tests for streams3 cork behavior, cork then uncork and cork then end PR-URL: https://github.com/nodejs/node/pull/6493 Reviewed-By: James M Snell --- test/parallel/test-stream3-cork-end.js | 91 +++++++++++++++++++++++ test/parallel/test-stream3-cork-uncork.js | 86 +++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 test/parallel/test-stream3-cork-end.js create mode 100644 test/parallel/test-stream3-cork-uncork.js diff --git a/test/parallel/test-stream3-cork-end.js b/test/parallel/test-stream3-cork-end.js new file mode 100644 index 00000000000000..a0b611d0da1b66 --- /dev/null +++ b/test/parallel/test-stream3-cork-end.js @@ -0,0 +1,91 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const stream = require('stream'); +const Writable = stream.Writable; + +// Test the buffering behaviour of Writable streams. +// +// The call to cork() triggers storing chunks which are flushed +// on calling end() and the stream subsequently ended. +// +// node version target: 0.12 + +const expectedChunks = ['please', 'buffer', 'me', 'kindly']; +var inputChunks = expectedChunks.slice(0); +var seenChunks = []; +var seenEnd = false; + +var w = new Writable(); +// lets arrange to store the chunks +w._write = function(chunk, encoding, cb) { + // stream end event is not seen before the last write + assert.ok(!seenEnd); + // default encoding given none was specified + assert.equal(encoding, 'buffer'); + + seenChunks.push(chunk); + cb(); +}; +// lets record the stream end event +w.on('finish', () => { + seenEnd = true; +}); + +function writeChunks(remainingChunks, callback) { + var writeChunk = remainingChunks.shift(); + var writeState; + + if (writeChunk) { + setImmediate(() => { + writeState = w.write(writeChunk); + // we were not told to stop writing + assert.ok(writeState); + + writeChunks(remainingChunks, callback); + }); + } else { + callback(); + } +} + +// do an initial write +w.write('stuff'); +// the write was immediate +assert.equal(seenChunks.length, 1); +// reset the seen chunks +seenChunks = []; + +// trigger stream buffering +w.cork(); + +// write the bufferedChunks +writeChunks(inputChunks, () => { + // should not have seen anything yet + assert.equal(seenChunks.length, 0); + + // trigger flush and ending the stream + w.end(); + + // stream should not ended in current tick + assert.ok(!seenEnd); + + // buffered bytes should be seen in current tick + assert.equal(seenChunks.length, 4); + + // did the chunks match + for (var i = 0, l = expectedChunks.length; i < l; i++) { + var seen = seenChunks[i]; + // there was a chunk + assert.ok(seen); + + var expected = new Buffer(expectedChunks[i]); + // it was what we expected + assert.ok(seen.equals(expected)); + } + + setImmediate(() => { + // stream should have ended in next tick + assert.ok(seenEnd); + }); +}); diff --git a/test/parallel/test-stream3-cork-uncork.js b/test/parallel/test-stream3-cork-uncork.js new file mode 100644 index 00000000000000..cd86e8cf809bac --- /dev/null +++ b/test/parallel/test-stream3-cork-uncork.js @@ -0,0 +1,86 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const stream = require('stream'); +const Writable = stream.Writable; + +// Test the buffering behaviour of Writable streams. +// +// The call to cork() triggers storing chunks which are flushed +// on calling uncork() in the same tick. +// +// node version target: 0.12 + +const expectedChunks = ['please', 'buffer', 'me', 'kindly']; +var inputChunks = expectedChunks.slice(0); +var seenChunks = []; +var seenEnd = false; + +var w = new Writable(); +// lets arrange to store the chunks +w._write = function(chunk, encoding, cb) { + // default encoding given none was specified + assert.equal(encoding, 'buffer'); + + seenChunks.push(chunk); + cb(); +}; +// lets record the stream end event +w.on('finish', () => { + seenEnd = true; +}); + +function writeChunks(remainingChunks, callback) { + var writeChunk = remainingChunks.shift(); + var writeState; + + if (writeChunk) { + setImmediate(() => { + writeState = w.write(writeChunk); + // we were not told to stop writing + assert.ok(writeState); + + writeChunks(remainingChunks, callback); + }); + } else { + callback(); + } +} + +// do an initial write +w.write('stuff'); +// the write was immediate +assert.equal(seenChunks.length, 1); +// reset the chunks seen so far +seenChunks = []; + +// trigger stream buffering +w.cork(); + +// write the bufferedChunks +writeChunks(inputChunks, () => { + // should not have seen anything yet + assert.equal(seenChunks.length, 0); + + // trigger writing out the buffer + w.uncork(); + + // buffered bytes shoud be seen in current tick + assert.equal(seenChunks.length, 4); + + // did the chunks match + for (var i = 0, l = expectedChunks.length; i < l; i++) { + var seen = seenChunks[i]; + // there was a chunk + assert.ok(seen); + + var expected = new Buffer(expectedChunks[i]); + // it was what we expected + assert.ok(seen.equals(expected)); + } + + setImmediate(() => { + // the stream should not have been ended + assert.ok(!seenEnd); + }); +}); From 2259e5db6903b844b9e3fa4d1d0f1fece4cabdb7 Mon Sep 17 00:00:00 2001 From: Stefan Budeanu Date: Mon, 2 May 2016 16:17:13 -0400 Subject: [PATCH 066/261] test: avoid test-cluster-master-* flakiness Removed reliance on worker exit before arbitrary timeout. Instead of failing the test after 200 or 1000 ms wait indefinitely for child process exit. If the test hangs the test harness global timeout will kick in and fail the test. Note that if the orphaned children are not reaped correctly (in the absence of init, e.g. Docker) the test will hang and the harness will fail it. PR-URL: https://github.com/nodejs/node/pull/6531 Reviewed-By: Michael Dawson Reviewed-By: Andreas Madsen Reviewed-By: Santiago Gimeno --- test/parallel/test-cluster-master-error.js | 45 ++++++++++------------ test/parallel/test-cluster-master-kill.js | 21 ++++------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/test/parallel/test-cluster-master-error.js b/test/parallel/test-cluster-master-error.js index ae0f655bb8e5d0..1f0cb8c9098c62 100644 --- a/test/parallel/test-cluster-master-error.js +++ b/test/parallel/test-cluster-master-error.js @@ -30,7 +30,7 @@ if (cluster.isWorker) { } }); - // Throw accidently error when all workers are listening + // Throw accidental error when all workers are listening var listeningNum = 0; cluster.on('listening', function listeningEvent() { @@ -39,10 +39,10 @@ if (cluster.isWorker) { // Stop listening cluster.removeListener('listening', listeningEvent); - // throw accidently error + // Throw accidental error process.nextTick(function() { console.error('about to throw'); - throw new Error('accidently error'); + throw new Error('accidental error'); }); } @@ -68,8 +68,8 @@ if (cluster.isWorker) { } }; - var existMaster = false; - var existWorker = false; + var masterExited = false; + var workersExited = false; // List all workers var workers = []; @@ -89,36 +89,33 @@ if (cluster.isWorker) { // When cluster is dead master.on('exit', function(code) { - // Check that the cluster died accidently - existMaster = !!code; + // Check that the cluster died accidentally (non-zero exit code) + masterExited = !!code; - // Give the workers time to shut down - var timeout = 200; - if (common.isAix) { - // AIX needs more time due to default exit performance - timeout = 1000; - } - setTimeout(checkWorkers, timeout); - - function checkWorkers() { - // When master is dead all workers should be dead to + var pollWorkers = function() { + // When master is dead all workers should be dead too var alive = false; workers.forEach(function(pid) { if (isAlive(pid)) { alive = true; } }); - - // If a worker was alive this did not act as expected - existWorker = !alive; - } + if (alive) { + setTimeout(pollWorkers, 50); + } else { + workersExited = true; + } + }; + + // Loop indefinitely until worker exit + pollWorkers(); }); process.once('exit', function() { - var m = 'The master did not die after an error was throwed'; - assert.ok(existMaster, m); + var m = 'The master did not die after an error was thrown'; + assert.ok(masterExited, m); m = 'The workers did not die after an error in the master'; - assert.ok(existWorker, m); + assert.ok(workersExited, m); }); } diff --git a/test/parallel/test-cluster-master-kill.js b/test/parallel/test-cluster-master-kill.js index 32f22b0f968b7b..549655f1b64cbc 100644 --- a/test/parallel/test-cluster-master-kill.js +++ b/test/parallel/test-cluster-master-kill.js @@ -55,26 +55,21 @@ if (cluster.isWorker) { var alive = true; master.on('exit', function(code) { - // make sure that the master died by purpose + // make sure that the master died on purpose assert.equal(code, 0); // check worker process status - var timeout = 200; - if (common.isAix) { - // AIX needs more time due to default exit performance - timeout = 1000; - } - setTimeout(function() { + var pollWorker = function() { alive = isAlive(pid); - }, timeout); + if (alive) { + setTimeout(pollWorker, 50); + } + }; + // Loop indefinitely until worker exit. + pollWorker(); }); process.once('exit', function() { - // cleanup: kill the worker if alive - if (alive) { - process.kill(pid); - } - assert.equal(typeof pid, 'number', 'did not get worker pid info'); assert.equal(alive, false, 'worker was alive after master died'); }); From 3aef9b813f52e339d07b7a73521ba97b4ee5b39c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 2 May 2016 20:01:27 -0700 Subject: [PATCH 067/261] test: unmark test-http-regr-gh-2928 as flaky The flakiness issue for test-http-regr-gh-2928 on SmartOS was resolved in late February in https://github.com/nodejs/node/pull/5454. This change removes its flaky designation in sequential.status. PR-URL: https://github.com/nodejs/node/pull/6540 Reviewed-By: James M Snell --- test/sequential/sequential.status | 1 - 1 file changed, 1 deletion(-) diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status index a8db7594934708..d228c93b4534e9 100644 --- a/test/sequential/sequential.status +++ b/test/sequential/sequential.status @@ -13,7 +13,6 @@ prefix sequential [$system==macos] [$system==solaris] # Also applies to SmartOS -test-http-regr-gh-2928 : PASS,FLAKY [$system==freebsd] From 7813af7f16a61e975d601548dcdffd2f5e1c41ff Mon Sep 17 00:00:00 2001 From: Doug Wade Date: Wed, 4 May 2016 17:45:04 -0700 Subject: [PATCH 068/261] doc: Add resolveNaptr and naptr rrtype docs Updates the dns module documentation to include documentation on the resolveNaptr method, and also adds the option NAPTR to the list of valid values for rrtype in dns.resolve(hostname[, rrtype], callback). PR-URL: https://github.com/nodejs/node/pull/6586 Fixes: https://github.com/nodejs/node/issues/6507 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Roman Reiss --- doc/api/dns.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/api/dns.md b/doc/api/dns.md index ee520380aa1385..3a1535359a091d 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -155,6 +155,7 @@ Valid values for `rrtype` are: * `'NS'` - name server records * `'CNAME'` - canonical name records * `'SOA'` - start of authority record + * `'NAPTR'` - name authority pointer record The `callback` function has arguments `(err, addresses)`. When successful, `addresses` will be an array. The type of each item in `addresses` is @@ -191,6 +192,33 @@ Uses the DNS protocol to resolve mail exchange records (`MX` records) for the contain an array of objects containing both a `priority` and `exchange` property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). +## dns.resolveNaptr(hostname, callback) + +Uses the DNS protocol to resolve regular expression based records (`NAPTR` +records) for the `hostname`. The `callback` function has arguments +`(err, addresses)`. The `addresses` argument passed to the `callback` function +will contain an array of objects with the following properties: + +* `flags` +* `service` +* `regexp` +* `replacement` +* `order` +* `preference` + +For example: + +```js +{ + flags: 's', + service: 'SIP+D2U', + regexp: '', + replacement: '_sip._udp.example.com', + order: 30, + preference: 100 +} +``` + ## dns.resolveNs(hostname, callback) Uses the DNS protocol to resolve name server records (`NS` records) for the From 7c55f592145f5251ac4fc61cb046564c1a2c759e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 7 May 2016 14:07:29 -0700 Subject: [PATCH 069/261] test: make stdout buffer test more robust test-stdout-buffer-flush-on-exit is unfortunately non-deterministic. It will, every so often, pass when it is supposed to fail. This is currently guarded against by running the test with three different long strings. This change increases it to five to reduce the false negatives. PR-URL: https://github.com/nodejs/node/pull/6633 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- test/known_issues/test-stdout-buffer-flush-on-exit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/known_issues/test-stdout-buffer-flush-on-exit.js b/test/known_issues/test-stdout-buffer-flush-on-exit.js index be290810079956..709928693eeb9a 100644 --- a/test/known_issues/test-stdout-buffer-flush-on-exit.js +++ b/test/known_issues/test-stdout-buffer-flush-on-exit.js @@ -15,7 +15,7 @@ if (process.argv[2] === 'child') { process.exit(); } -[16, 18, 20].forEach((exponent) => { +[22, 21, 20, 19, 18, 17, 16, 16, 17, 18, 19, 20, 21, 22].forEach((exponent) => { const bigNum = Math.pow(2, exponent); const longLine = lineSeed.repeat(bigNum); const cmd = `${process.execPath} ${__filename} child ${exponent} ${bigNum}`; From af4b56d6be7541dfe7362d889ea7632412382464 Mon Sep 17 00:00:00 2001 From: hefangshi Date: Mon, 9 May 2016 15:17:06 +0800 Subject: [PATCH 070/261] test: pass python path to node-gyp node-gyp rebuild should use the same python interpreter as in Makefile rather than let node-gyp guess the python path by itself. PR-URL: https://github.com/nodejs/node/pull/6646 Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 5c16b9b66c5a35..a13d7388179dab 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,7 @@ test-valgrind: all test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE) $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ + --python="$(PYTHON)" \ --directory="$(shell pwd)/test/gc/node_modules/weak" \ --nodedir="$(shell pwd)" @@ -142,6 +143,7 @@ test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) | test/addons/.docbuildstamp # embedded addons have been generated from the documentation. for dirname in test/addons/*/; do \ $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \ + --python="$(PYTHON)" \ --directory="$$PWD/$$dirname" \ --nodedir="$$PWD"; \ done From 350f4cf292c8afb85def4e7c00a4214368d9e2af Mon Sep 17 00:00:00 2001 From: Jean Regisser Date: Mon, 9 May 2016 19:33:09 +0200 Subject: [PATCH 071/261] doc: server.listen truncates socket path on unix Internally it ends up calling `uv_pipe_bind` with the given path which itself is documented to truncate the path. See http://docs.libuv.org/en/v1.x/pipe.html#c.uv_pipe_bind This is NOT a bug, but a restriction of the unix socket api, as it stores the path in `sockaddr_un.sun_path` (104 chars on OS X, 108 chars on Linux), see `man unix`. PR-URL: https://github.com/nodejs/node/pull/6659 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Alexander Makarenko Reviewed-By: Anna Henningsen --- doc/api/net.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index a5590bdad1491b..976fd5677509fd 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -153,9 +153,12 @@ This function is asynchronous. When the server has been bound, will be added as a listener for the [`'listening'`][] event. On UNIX, the local domain is usually known as the UNIX domain. The path is a -filesystem path name. It is subject to the same naming conventions and -permissions checks as would be done on file creation, will be visible in the -filesystem, and will *persist until unlinked*. +filesystem path name. It gets truncated to `sizeof(sockaddr_un.sun_path)` +bytes, decreased by 1. It varies on different operating system between 91 and +107 bytes. The typical values are 107 on Linux and 103 on OS X. The path is +subject to the same naming conventions and permissions checks as would be done +on file creation, will be visible in the filesystem, and will *persist until +unlinked*. On Windows, the local domain is implemented using a named pipe. The path *must* refer to an entry in `\\?\pipe\` or `\\.\pipe\`. Any characters are permitted, From 140b84dd7dc10b4a525fc534db70c772ed2a4c28 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Mon, 16 May 2016 12:37:42 -0400 Subject: [PATCH 072/261] tools: print stderr on bad test.py `vmArch` check This makes it so you can see why the check fails if it does. Typically that sort of thing can happen if you are modifying bootstrapping or `process`. PR-URL: https://github.com/nodejs/node/pull/6786 Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen --- tools/test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test.py b/tools/test.py index d50fd5b4662c36..80cc1287fc17dc 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1571,6 +1571,7 @@ def Main(): vmArch = archEngineContext.stdout.rstrip() if archEngineContext.exit_code is not 0 or vmArch == "undefined": print "Can't determine the arch of: '%s'" % vm + print archEngineContext.stderr.rstrip() continue env = { 'mode': mode, From 65b75b51a6a624a3a5e953fb24d15aa1e2d6c706 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 19 May 2016 12:29:40 +0200 Subject: [PATCH 073/261] build: unbreak configure with python 2.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 2b1c01c2c ("build: refactor pkg-config for shared libraries") from May 2015 introduced python 2.7-specific code. It mainly affects people building on old RHEL platforms where the system python is 2.6. Seemingly a dying breed because the issue went unnoticed (or at least unreported) for a whole year. Fixes: https://github.com/nodejs/node/issues/6711 PR-URL: https://github.com/nodejs/node/pull/6874 Reviewed-By: Johan Bergström Reviewed-By: Robert Jefe Lindstaedt Reviewed-By: Sakthipriyan Vairamani --- configure | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 4434d53e47bb10..0be3a52bf7e886 100755 --- a/configure +++ b/configure @@ -1,4 +1,6 @@ #!/usr/bin/env python + +import errno import optparse import os import pprint @@ -400,19 +402,16 @@ def b(value): def pkg_config(pkg): pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') - args = '--silence-errors' retval = () for flag in ['--libs-only-l', '--cflags-only-I', '--libs-only-L']: try: - val = subprocess.check_output([pkg_config, args, flag, pkg]) - # check_output returns bytes - val = val.encode().strip().rstrip('\n') - except subprocess.CalledProcessError: - # most likely missing a .pc-file - val = None - except OSError: - # no pkg-config/pkgconf installed - return (None, None, None) + proc = subprocess.Popen( + shlex.split(pkg_config) + ['--silence-errors', flag, pkg], + stdout=subprocess.PIPE) + val = proc.communicate()[0].strip() + except OSError, e: + if e.errno != errno.ENOENT: raise e # Unexpected error. + return (None, None, None) # No pkg-config/pkgconf installed. retval += (val,) return retval From 373ffc5bad3d24f6ca3f1fcbd0e1a3d5bb7dcef4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 21 May 2016 11:14:05 +0200 Subject: [PATCH 074/261] installer: don't install node_internals.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the name suggests, it's for internal use only, so don't install it. Including it in an add-on doesn't work because the file depends on other header files that are not installed. Adding it to the install list appears to have been an oversight in commit 32478acf ("build: unix install node and dep library headers"). PR-URL: https://github.com/nodejs/node/pull/6913 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Johan Bergström Reviewed-By: Robert Jefe Lindstaedt --- tools/install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/install.py b/tools/install.py index 88791eab10d034..b1997d48525209 100755 --- a/tools/install.py +++ b/tools/install.py @@ -150,7 +150,6 @@ def headers(action): 'config.gypi', 'src/node.h', 'src/node_buffer.h', - 'src/node_internals.h', 'src/node_object_wrap.h', 'src/node_version.h', ], 'include/node/') From 9cccaa3c80835d09ba04ecf7361eb52831e0e898 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 21 May 2016 12:43:57 +0200 Subject: [PATCH 075/261] test: fix component printing on windows Commit 084b2ec ("test: include component in tap output") introduced an in hindsight glaringly obvious but fortunately not very critical Windows-specific bug by failing to take the path separator into account. This commit rectifies that, the prefix is now correctly stripped. PR-URL: https://github.com/nodejs/node/pull/6915 Refs: https://github.com/nodejs/node/pull/6653 Reviewed-By: Anna Henningsen --- tools/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 80cc1287fc17dc..55328a338ef9a8 100755 --- a/tools/test.py +++ b/tools/test.py @@ -273,10 +273,11 @@ def HasRun(self, output): # Print test name as (for example) "parallel/test-assert". Tests that are # scraped from the addons documentation are all named test.js, making it # hard to decipher what test is running when only the filename is printed. - prefix = abspath(join(dirname(__file__), '../test')) + '/' + prefix = abspath(join(dirname(__file__), '../test')) + os.sep command = output.command[-1] if command.endswith('.js'): command = command[:-3] if command.startswith(prefix): command = command[len(prefix):] + command = command.replace('\\', '/') if output.UnexpectedOutput(): status_line = 'not ok %i %s' % (self._done, command) From 426aa0a5e8348ef135a36710965e8c5dfc398f81 Mon Sep 17 00:00:00 2001 From: Bryce Simonds Date: Mon, 23 May 2016 16:14:02 -0500 Subject: [PATCH 076/261] src: fix Windows segfault with `--eval` When specifing a parameter that requries an additional argument on the command line, node would segfault. This appears to be specific to Windows, adjusted command line argument parsing to hold a nullptr terminal. Adding unit test for crash on missing arguments. PR-URL: https://github.com/nodejs/node/pull/6938 Reviewed-By: Anna Henningsen Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ben Noordhuis --- src/node_main.cc | 3 ++- test/parallel/test-cli-eval.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/node_main.cc b/src/node_main.cc index 58e747e52c49ef..7cc5918b228ba8 100644 --- a/src/node_main.cc +++ b/src/node_main.cc @@ -3,7 +3,7 @@ #ifdef _WIN32 int wmain(int argc, wchar_t *wargv[]) { // Convert argv to to UTF8 - char** argv = new char*[argc]; + char** argv = new char*[argc + 1]; for (int i = 0; i < argc; i++) { // Compute the size of the required buffer DWORD size = WideCharToMultiByte(CP_UTF8, @@ -35,6 +35,7 @@ int wmain(int argc, wchar_t *wargv[]) { exit(1); } } + argv[argc] = nullptr; // Now that conversion is done, we can finally start. return node::Start(argc, argv); } diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index d1db3a815f5df5..e6a47a3175172e 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -40,11 +40,11 @@ child.exec(nodejs + ' --eval "console.error(42)"', assert.equal(stderr, ''); }); - child.exec(cmd + "'[]'", + child.exec(cmd + "'[]'", common.mustCall( function(err, stdout, stderr) { assert.equal(stdout, '[]\n'); assert.equal(stderr, ''); - }); + })); }); // assert that module loading works @@ -59,6 +59,12 @@ child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"', assert.equal(status.code, 42); }); +// Missing argument should not crash +child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) { + assert.notStrictEqual(status, null); + assert.strictEqual(status.code, 9); +})); + // empty program should do nothing child.exec(nodejs + ' -e ""', function(status, stdout, stderr) { assert.equal(stdout, ''); From 4ee863d9565e66be10747f452ff710728c310f8f Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 23 May 2016 13:21:33 -0400 Subject: [PATCH 077/261] child_process: allow buffer encoding in spawnSync When the 'buffer' encoding is passed to spawnSync(), an exception is thrown in Buffer's toString() method because 'buffer' is not a valid encoding there. This commit special cases the 'buffer' encoding. Fixes: https://github.com/nodejs/node/issues/6930 PR-URL: https://github.com/nodejs/node/pull/6939 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis --- lib/child_process.js | 2 +- test/common.js | 11 +++++++++++ test/parallel/test-child-process-spawnsync.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/child_process.js b/lib/child_process.js index dda613afdeeec6..e43093ace1fa0d 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -428,7 +428,7 @@ function spawnSync(/*file, args, options*/) { var result = spawn_sync.spawn(options); - if (result.output && options.encoding) { + if (result.output && options.encoding && options.encoding !== 'buffer') { for (i = 0; i < result.output.length; i++) { if (!result.output[i]) continue; diff --git a/test/common.js b/test/common.js index 7a054fc167c9ab..0a7e0f82b31c39 100644 --- a/test/common.js +++ b/test/common.js @@ -237,6 +237,17 @@ exports.spawnPwd = function(options) { } }; + +exports.spawnSyncPwd = function(options) { + const spawnSync = require('child_process').spawnSync; + + if (exports.isWindows) { + return spawnSync('cmd.exe', ['/c', 'cd'], options); + } else { + return spawnSync('pwd', [], options); + } +}; + exports.platformTimeout = function(ms) { if (process.config.target_defaults.default_configuration === 'Debug') ms = 2 * ms; diff --git a/test/parallel/test-child-process-spawnsync.js b/test/parallel/test-child-process-spawnsync.js index 53e72c83ca7373..291d3287cff563 100644 --- a/test/parallel/test-child-process-spawnsync.js +++ b/test/parallel/test-child-process-spawnsync.js @@ -33,3 +33,17 @@ assert.deepEqual(ret_err.spawnargs, ['bar']); assert.strictEqual(response.stdout.toString().trim(), cwd); })(); + +{ + // Test the encoding option + const noEncoding = common.spawnSyncPwd(); + const bufferEncoding = common.spawnSyncPwd({encoding: 'buffer'}); + const utf8Encoding = common.spawnSyncPwd({encoding: 'utf8'}); + + assert.deepStrictEqual(noEncoding.output, bufferEncoding.output); + assert.deepStrictEqual([ + null, + noEncoding.stdout.toString(), + noEncoding.stderr.toString() + ], utf8Encoding.output); +} From ecf5c1cb25cfa8cbf16e28573e1e6437838aef54 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 23 May 2016 17:25:41 -0400 Subject: [PATCH 078/261] test: refactor spawnSync() cwd test This commit refactors test-child-process-spawnsync.js to use the reusable common.spawnSyncPwd(). PR-URL: https://github.com/nodejs/node/pull/6939 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis --- test/parallel/test-child-process-spawnsync.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync.js b/test/parallel/test-child-process-spawnsync.js index 291d3287cff563..3602b7e953beaf 100644 --- a/test/parallel/test-child-process-spawnsync.js +++ b/test/parallel/test-child-process-spawnsync.js @@ -18,21 +18,13 @@ assert.strictEqual(ret_err.syscall, 'spawnSync command_does_not_exist'); assert.strictEqual(ret_err.path, 'command_does_not_exist'); assert.deepEqual(ret_err.spawnargs, ['bar']); -// Verify that the cwd option works - GH #7824 -(function() { - var response; - var cwd; - - if (common.isWindows) { - cwd = 'c:\\'; - response = spawnSync('cmd.exe', ['/c', 'cd'], {cwd: cwd}); - } else { - cwd = '/'; - response = spawnSync('pwd', [], {cwd: cwd}); - } +{ + // Test the cwd option + const cwd = common.isWindows ? 'c:\\' : '/'; + const response = common.spawnSyncPwd({cwd}); assert.strictEqual(response.stdout.toString().trim(), cwd); -})(); +} { // Test the encoding option From 5b807ac791349255f1bed40d304bc1c4d17a27b6 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 5 Jun 2016 15:25:56 +0200 Subject: [PATCH 079/261] doc: specify how to link issues in commit log PR-URL: https://github.com/nodejs/node/pull/7161 Reviewed-By: Ben Noordhuis Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b761c79858225..efe83ccf204f36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -120,6 +120,12 @@ run `git shortlog` or `git log --oneline`. Check the output of `git log --oneline files_that_you_changed` to find out what subsystem (or subsystems) your changes touch. +If your patch fixes an open issue, you can add a reference to it at the end +of the log. Use the `Fixes:` prefix and the full issue URL. For example: + +``` +Fixes: https://github.com/nodejs/node/issues/1337 +``` ### Step 4: Rebase From 629a76f9fbb0de590ef83bd9c3dee674fa77eb8c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 6 Jun 2016 10:35:38 -0400 Subject: [PATCH 080/261] doc: remove cluster.setupMaster() myth cluster.setupMaster() can be called more than once. Core even has tests for this functionality. This commit removes an incorrect statement to the contrary from the documentation. Fixes: https://github.com/nodejs/node/issues/7156 PR-URL: https://github.com/nodejs/node/pull/7179 Reviewed-By: James M Snell Reviewed-By: Claudio Rodriguez --- doc/api/cluster.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 4c25d58516d309..104897660f7107 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -587,9 +587,6 @@ values are `"rr"` and `"none"`. After calling `.setupMaster()` (or `.fork()`) this settings object will contain the settings, including the default values. -It is effectively frozen after being set, because `.setupMaster()` can -only be called once. - This object is not supposed to be changed or set manually, by you. ## cluster.setupMaster([settings]) From ece428ea635a1d914c3fddda2290da53428ac972 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 4 Jun 2016 00:21:04 -0400 Subject: [PATCH 081/261] http: fix no dumping after `maybeReadMore` When `maybeReadMore` kicks in on a first bytes of incoming data, the `req.read(0)` will be invoked and the `req._consuming` will be set to `true`. This seemingly harmless property leads to a dire consequences: the server won't call `req._dump()` and the whole HTTP/1.1 pipeline will hang (single connection). PR-URL: https://github.com/nodejs/node/pull/7211 Reviewed-By: Ben Noordhuis Reviewed-By: Matteo Collina --- lib/_http_incoming.js | 9 ++++ test/parallel/test-http-no-read-no-dump.js | 51 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/parallel/test-http-no-read-no-dump.js diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js index 2a042cbee239f2..3f6ae86f07e211 100644 --- a/lib/_http_incoming.js +++ b/lib/_http_incoming.js @@ -20,6 +20,13 @@ exports.readStop = readStop; function IncomingMessage(socket) { Stream.Readable.call(this); + // Set this to `true` so that stream.Readable won't attempt to read more + // data on `IncomingMessage#push` (see `maybeReadMore` in + // `_stream_readable.js`). This is important for proper tracking of + // `IncomingMessage#_consuming` which is used to dump requests that users + // haven't attempted to read. + this._readableState.readingMore = true; + this.socket = socket; this.connection = socket; @@ -67,6 +74,8 @@ IncomingMessage.prototype.setTimeout = function(msecs, callback) { IncomingMessage.prototype.read = function(n) { + if (!this._consuming) + this._readableState.readingMore = false; this._consuming = true; this.read = Stream.Readable.prototype.read; return this.read(n); diff --git a/test/parallel/test-http-no-read-no-dump.js b/test/parallel/test-http-no-read-no-dump.js new file mode 100644 index 00000000000000..c509146c0a29d7 --- /dev/null +++ b/test/parallel/test-http-no-read-no-dump.js @@ -0,0 +1,51 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +let onPause = null; + +const server = http.createServer((req, res) => { + if (req.method === 'GET') + return res.end(); + + res.writeHead(200); + res.flushHeaders(); + + req.connection.on('pause', () => { + res.end(); + onPause(); + }); +}).listen(common.PORT, common.mustCall(() => { + const agent = new http.Agent({ + maxSockets: 1, + keepAlive: true + }); + + const post = http.request({ + agent: agent, + method: 'POST', + port: common.PORT, + }, common.mustCall((res) => { + res.resume(); + + post.write(Buffer.alloc(16 * 1024).fill('X')); + onPause = () => { + post.end('something'); + }; + })); + + /* What happens here is that the server `end`s the response before we send + * `something`, and the client thought that this is a green light for sending + * next GET request + */ + post.write('initial'); + + http.request({ + agent: agent, + method: 'GET', + port: common.PORT, + }, common.mustCall((res) => { + server.close(); + res.connection.end(); + })).end(); +})); From 6324723cc1f80c0c13a8bb74260297f2faa0ed3d Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 9 Jun 2016 11:45:40 +0200 Subject: [PATCH 082/261] doc,dgram: fix addMembership documentation Adding membership using `IP_ADD_MEMBERSHIP` with interface address set to `INADDR_ANY` for `IPv4` or as an index of `0` for `IPv6` leads to using only one interface selected by the operating system. Fixes: https://github.com/nodejs/node/issues/1692 PR-URL: https://github.com/nodejs/node/pull/7244 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- doc/api/dgram.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/api/dgram.md b/doc/api/dgram.md index ab0e5e5134c373..d47cfe22ebb735 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -75,10 +75,11 @@ socket.on('message', (msg, rinfo) => { * `multicastAddress` {String} * `multicastInterface` {String}, Optional -Tells the kernel to join a multicast group at the given `multicastAddress` -using the `IP_ADD_MEMBERSHIP` socket option. If the `multicastInterface` -argument is not specified, the operating system will try to add membership to -all valid networking interfaces. +Tells the kernel to join a multicast group at the given `multicastAddress` and +`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the +`multicastInterface` argument is not specified, the operating system will choose +one interface and will add membership to it. To add membership to every +available interface, call `addMembership` multiple times, once per interface. ### socket.address() From 0a859878991ece860b0b7c8636e5e53137df5507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Mon, 13 Jun 2016 11:24:53 +0100 Subject: [PATCH 083/261] doc: update build instructions for Windows The Visual C++ Build Tools are supported to build Node on Windows and already used in CI, so they should be included in the build instructions. Reviewed-By: Rod Vagg Reviewed-By: Colin Ihrig PR-URL: https://github.com/nodejs/node/pull/7285 --- BUILDING.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index a247a21a0e5f9d..fa5fbe2c050c81 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -89,8 +89,10 @@ $ node -e "console.log('Hello from Node.js ' + process.version)" Prerequisites: * [Python 2.6 or 2.7](https://www.python.org/downloads/) -* Visual Studio 2013 / 2015, all editions including the Community edition, or -* Visual Studio Express 2013 / 2015 for Desktop +* One of: + * [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) + * [Visual Studio](https://www.visualstudio.com/) 2013 / 2015, all editions including the Community edition + * [Visual Studio](https://www.visualstudio.com/) Express 2013 / 2015 for Desktop * Basic Unix tools required for some tests, [Git for Windows](http://git-scm.com/download/win) includes Git Bash and tools which can be included in the global `PATH`. @@ -107,8 +109,8 @@ To run the tests: To test if Node.js was built correctly: -``` -$ node -e "console.log('Hello from Node.js ' + process.version)" +```text +> Release\node -e "console.log('Hello from Node.js', process.version)" ``` ### Android / Android-based devices (e.g., Firefox OS) From 7d6acefbcc2829dc6d8b88d4ad3b434002db7802 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 2 Jul 2016 10:08:26 +0200 Subject: [PATCH 084/261] test: listen on and connect to 127.0.0.1 Avoid transient DNS issues in test sequential/test-net-GH-5504 by using the IP address instead of the 'localhost' host name. Fixes: https://github.com/nodejs/node/issues/6611 PR-URL: https://github.com/nodejs/node/pull/7524 Reviewed-By: Brian White Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Santiago Gimeno --- test/sequential/test-net-GH-5504.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index 179b3ae3c2e241..d6de00b3a1eb25 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -30,7 +30,7 @@ function server() { console.error('_socketEnd'); }); socket.write(content); - }).listen(common.PORT, function() { + }).listen(common.PORT, common.localhostIPv4, function() { console.log('listening'); }); } @@ -38,7 +38,7 @@ function server() { function client() { var net = require('net'); var client = net.connect({ - host: 'localhost', + host: common.localhostIPv4, port: common.PORT }, function() { client.destroy(); From 08cd81b05042f8d8c02d1109f5d1187c7346158a Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 22 Feb 2016 02:55:42 -0600 Subject: [PATCH 085/261] benchmark: add util.format benchmark PR-URL: https://github.com/nodejs/node/pull/5360 Reviewed-By: James M Snell --- benchmark/util/format.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 benchmark/util/format.js diff --git a/benchmark/util/format.js b/benchmark/util/format.js new file mode 100644 index 00000000000000..6a0b6c63dc1087 --- /dev/null +++ b/benchmark/util/format.js @@ -0,0 +1,40 @@ +'use strict'; + +const util = require('util'); +const common = require('../common'); +const v8 = require('v8'); +const bench = common.createBenchmark(main, { + n: [1e6] +, type: ['string', + 'number', + 'object', + 'unknown', + 'no-replace'] +}); + +const inputs = { + 'string': ['Hello, my name is %s', 'fred'], + 'number': ['Hi, I was born in %d', 1942], + 'object': ['An error occurred %j', {msg: 'This is an error', code: 'ERR'}], + 'unknown': ['hello %a', 'test'], + 'no-replace': [1, 2] +}; + +function main(conf) { + const n = conf.n | 0; + const type = conf.type; + + const input = inputs[type]; + + v8.setFlagsFromString('--allow_natives_syntax'); + + util.format(input[0], input[1]); + eval('%OptimizeFunctionOnNextCall(util.format)'); + util.format(input[0], input[1]); + + bench.start(); + for (var i = 0; i < n; i++) { + util.format(input[0], input[1]); + } + bench.end(n); +} From d1a0a146b3e70fdafba3d67159e5348b350bda1d Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Wed, 4 May 2016 17:58:46 -0400 Subject: [PATCH 086/261] doc: Add CTC meeting minutes for 2016-05-04 PR-URL: https://github.com/nodejs/node/pull/6579 Reviewed-By: Myles Borins Reviewed-By: James M Snell Reviewed-By: Evan Lucas Reviewed-By: thefourtheye - Sakthipriyan Vairamani --- doc/ctc-meetings/2016-05-04.md | 192 +++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 doc/ctc-meetings/2016-05-04.md diff --git a/doc/ctc-meetings/2016-05-04.md b/doc/ctc-meetings/2016-05-04.md new file mode 100644 index 00000000000000..3b5abb7ad98901 --- /dev/null +++ b/doc/ctc-meetings/2016-05-04.md @@ -0,0 +1,192 @@ +# Node Foundation CTC Meeting 2016-05-04 + +## Links + +* **Audio Recording**: https://www.youtube.com/watch?v=3M95wsWs7qQ +* **GitHub Issue**: https://github.com/nodejs/node/issues/6567 +* **Minutes Google Doc**: +* _Previous Minutes Google Doc: _ + +## Present + +* Bradley Farias @bmeck (observer/modules EPS/GoDaddy) +* Brian Terlson @bterlson (observer/modules EPS/tc39/Microsoft) +* Сковорода Никита Андреевич @ChALkeR (CTC) +* Colin Ihrig @cjihrig (CTC) +* Evan Lucas @evanlucas (CTC) +* Jeremiah Senkpiel @Fishrock123 (CTC) +* James M Snell @jasnell (CTC) +* Josh Gavant (observer/Microsoft) +* Michael Dawson @mhdawson (CTC) +* Brian White @mscdex (CTC) +* Rod Vagg @rvagg (CTC) +* Seth Thompson (observer/Google) +* Shigeki Ohtsu @shigeki (CTC) +* Steven R Loomis @srl295 (observer/IBM/ICU) +* Trevor Norris @trevnorris (CTC) +* Rich Trott @Trott (CTC) + + +## Agenda + +Extracted from **ctc-agenda** labelled issues and pull requests from the **nodejs org** prior to the meeting. + +### nodejs/node + +* Revert 5950 [#6537](https://github.com/nodejs/node/pull/6537) +* src: refactor constants, deprecate require('constants') [#6534](https://github.com/nodejs/node/pull/6534) +* doc: refactor the changelog by version [#6503](https://github.com/nodejs/node/pull/6503) +* Request for discussion of https://github.com/dherman/defense-of-dot-js vs EPS on modules + + + +## Standup + +* Сковорода Никита Андреевич: + * Nothing too significant, some comments (as usual). + +* Colin Ihrig: + * A few PRs + * Reviewing issues and PRs + +* Evan Lucas: + * Submitted a doc and util pr. + * Working on a http bug. + * Been trying to help some packages get updated to work with v6. + * Left some comments on a few issues. + * Have been working on a commit validator tool. + +* Jeremiah Senkpiel: + * v6 Breaking changes doc + * working on v6.1.0 release + * assorted PRs, Issues, EPs -- done a bunch of reviews + +* James M Snell: + * v6 Release + * Fixed 2 util.inspect bugs (proxy and array length) + * Helped troubleshoot buffer indexOf/lastIndexOf bug + * Troubleshooting 5950 issues + * Work on error code refactoring + * Work on constants refactoring + * Work on changelog refactoring + * Ongoing http implementation security / spec compliance review + * Working on compliance follow ups from vm summit + * Investigating possible alternative solutions for stdout/stderr + non-blocking issues + +* Josh Gavant: + * Testing use of trace-event macros, designing tracing module, reviewing AsyncWrap and alternatives. + +* Michael Dawson: + * Investigated ppc be release machine issues + * validating be build from nightly release job + * AsyncWrap EP review + * switched benchmarking vof v6 over to new v6 branch + * wrote/submitted stable ABI module EP + * misc reviews/lands + +* Brian White: + * Worked on http server code refactor and other http performance improvements + * Reviewed PRs/issues + +* Rod Vagg: + * Time off, now catching up + +* Seth Thompson: + * continue to work on getting v8 inspector to work with node + * meeting with Ali as he.s visiting in person + +* Shigeki Ohtsu: + * Upgrading openssl and reviewing one PR for GCM IV + +* Steven R Loomis: + * turn/rebase/clean ci for https://github.com/nodejs/node/pull/6088 ( checkin ICU into master ) and https://github.com/nodejs/node/pull/4253 ( v8BreakIterator to throw error rather than fatal crash + * opened Doodle poll to get Intl WG going again (monthly) https://github.com/nodejs/Intl/issues/33 + +* Trevor Norris: + * Don't abort on access of invalid pointer returned by Unwrap PR + * Tuning the AsyncWrap EP and writing patches as result + +* Rich Trott: + * Added undocumented-for-now -F flag to jslint.js to automatically fix lint issues. Dog-fooding it right now. Give it a shot if you.re brave. + * Open PR to have `known_issues` tests run via CI and `make test`. PTAL. https://github.com/nodejs/node/pull/6559 + * Assessments for long-dormant issues. + +* Bradley Farias: + * Investigated counter proposal details to node EP for modules + * Started test framework for modules EP + + +## Review of last meeting + + +* governance: add new collaborators XII [#6282](https://github.com/nodejs/node/issues/6282) +* doc: doc-only deprecation for util.log() [#6161](https://github.com/nodejs/node/pull/6161) +* Check (small) ICU into repo [#6088](https://github.com/nodejs/node/pull/6088) +* doc, tls: deprecate createSecurePair [#6063](https://github.com/nodejs/node/pull/6063) +* Planning for v6 [#5766](https://github.com/nodejs/node/issues/5766) +* Introduce staging branch for stable release streams [#6306](https://github.com/nodejs/node/issues/6306) +* ES6 Modules detection update / https://github.com/nodejs/node-eps/issues/13 + + +## Minutes + +### Revert 5950 [#6537](https://github.com/nodejs/node/pull/6537) +* James: Bug picked up in v6 for symlinked peer dependencies, our tests/CI didn.t pick it up unfortunately. Proposal is to revert the change and review it after adding some tests for this. +* Rod: there was some discussion about a revert being semver major +* Jeremiah: not optimal, reverting is technically a semver-major +* Rod: does anyone have an objection to a revert at this stage? +* Jeremiah: I believe some of the new behaviour was useful, is there a path to reintroducing it? +* James: least invasive route would be to add the new behaviour behind a flag, there are some other approaches being investigated. The folks who proposed this change in the first place are behind the reversion at this stage. + +### Request for discussion of https://github.com/dherman/defense-of-dot-js vs EPS on modules + + +* Bradley: we merged our proposal last week and afterward a counter-proposal (that we.ve been waiting on for many weeks) showed up. The proposal is a package.json-based solution. It does address all of the major use-cases of Node and it does this in slightly different ways than we.ve seen before. It.s still lacking some existing behaviour of CJS files (you can.t detect some filepaths for CJS), e.g. ~/.config.js. It introduces a path-expansion mechanism. You add a module.root to your package.json. I still have concerns about this but it.s much better than the previous ones based on package.json. I.ll be having a more in-depth conversation with Brian Terlson (TC39/Microsoft), if anyone wants to join. +* Jeremiah: is the main downside of the file extension about sharing files from servers that aren.t configured for it? +* Bradley: yes, the main concern is about firewalls and configs that block transmission of the new files. +* Rod: can you help us empathise with the sentimentality around the file extension, are there objective problems that we are not picking up on? +* Bradley: there.s a concern . _something about a lodash example_ . shell scripts not finding the new files with *.js. +* Brian Terlson: there.s an expectation that JavaScript is contained in a .js file and we.re in a nice place now that this is true with some minor exceptions. For TypeScript we.d have to add a .mts and .mtsx extension. +* Rod: _asking about the sentimentality again_ +* Brian Terlson: that.s a mischaracterisation of the defense of .js proposal +* Jeremiah: there will be developer friction either way +* Brian Terlson: but friction will be limited to node developers as opposed to all javascript developers +* Rod: what state is standard ? +* Bradley: Some pieces still have minor changes going on but mostly locked down. +* Brian Terlson: we have been thinking about all of these kinds of things during the whole process. I don.t think spec changes are off the table, TC39 could reconsider some aspects of the spec to improve matters. No promises, but don.t feel like you shouldn.t bring it up because we.re so late in process. +* Bradley: forward detection is the main problem. Have examples of specifics. As long as implicit strict mode is enforced we are going to have a hard time. +Rod: what.s the path forward ? On our side seems like strong preference is still on the file extension side. +* Bradley: Either way was ecosystem effects. Personally towards file extensions, most response on social media is either .better than nothing. or .don.t like file extension but not pushing for package.json either.. Will discuss further with Brian and others from Microsoft. +* Rod: EP does not mean it is final, but it does mean it is the preferred way forward and CTC members would have to be convinced otherwise. +* Bradley: likely need longer discussion in next week or so either way. + + +### src: refactor constants, deprecate require('constants') [#6534](https://github.com/nodejs/node/pull/6534) +* James: recent PR asking to add new constant. They are mentioned in the docs in a few places, but not well documented. Figured should take a run at documenting and refactoring to make it make more sense. Cleans up the structure and properly documents. Would it be semver major since we have never documented before ? +* Jeremiah: marked as semver major because it was deprecating existing constants. +* James: hard deprecation pretty much blows up everything as npm uses them ,etc. Thats why it is a soft deprecation. +* Jerimiah: we should find way to document +* James: add to release notes saying to use the new versions. +* Rich: Move discussion back to github +* Rod: Any objection to doing this, want consensus before we spend a lot of time doing it. + + +### doc: refactor the changelog by version [#6503](https://github.com/nodejs/node/pull/6503) + +* James: changelog grew to point where it is no longer visible/usable on github. To make it at least visible it was temporarily split out into an archive. This PR is to split it out by version instead. Each version release would link to the individual version change log. One at top level becomes an index to the version specific ones. Acceptable or do we need another approach? Archive for io.js release and before v.10. Should not add too much additional work to release process. +* Rod: maybe io.js ones should be in separate files as well instead archive. +* Jeremiah: io.js v1 has particularly large set of changes +* James: any major objections ? +* Rod: take it back to github, roll forward unless objections on github. + +### Q/A on public fora +* call for questions on public channels. +* no existing ones so far. +* will wait a few minutes to see if any come in +* ok moving on. + + +## Next Meeting + +2016-05-11 From 2ef08323c653dbdd5a791892d9bf7e25d1ea4160 Mon Sep 17 00:00:00 2001 From: Bradley Meck Date: Tue, 24 May 2016 23:50:18 -0500 Subject: [PATCH 087/261] doc: add bmeck to collaborators PR-URL: https://github.com/nodejs/node/pull/6962 Reviewed-By: Rich Trott --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8d697ca91778b1..76cc73df0b991d 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ information about the governance of the Node.js project, see * [AndreasMadsen](https://github.com/AndreasMadsen) - **Andreas Madsen** <amwebdk@gmail.com> * [bengl](https://github.com/bengl) - **Bryan English** <bryan@bryanenglish.com> * [benjamingr](https://github.com/benjamingr) - **Benjamin Gruenbaum** <benjamingr@gmail.com> +* [bmeck](https://github.com/bmeck) - **Bradley Farias** <bradley.meck@gmail.com> * [brendanashworth](https://github.com/brendanashworth) - **Brendan Ashworth** <brendan.ashworth@me.com> * [calvinmetcalf](https://github.com/calvinmetcalf) - **Calvin Metcalf** <calvin.metcalf@gmail.com> * [claudiorodriguez](https://github.com/claudiorodriguez) - **Claudio Rodriguez** <cjrodr@yahoo.com> From c5051ef643534ab5fdb5b4a1d7fa1a14109a9a35 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 24 May 2016 11:34:15 +0800 Subject: [PATCH 088/261] doc: add firedfox to collaborators PR-URL: https://github.com/nodejs/node/pull/6961 Reviewed-By: Rich Trott --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 76cc73df0b991d..fb54432ba0ef87 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ information about the governance of the Node.js project, see * [domenic](https://github.com/domenic) - **Domenic Denicola** <d@domenic.me> * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - **Robert Jefe Lindstaedt** <robert.lindstaedt@gmail.com> * [estliberitas](https://github.com/estliberitas) - **Alexander Makarenko** <estliberitas@gmail.com> +* [firedfox](https://github.com/firedfox) - **Daniel Wang** <wangyang0123@gmail.com> * [geek](https://github.com/geek) - **Wyatt Preul** <wpreul@gmail.com> * [iarna](https://github.com/iarna) - **Rebecca Turner** <me@re-becca.org> * [isaacs](https://github.com/isaacs) - **Isaac Z. Schlueter** <i@izs.me> From 8cba3b2f727c1aa323027ad5f1ebea1ecb702dc9 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 20 May 2016 15:05:02 -0400 Subject: [PATCH 089/261] cluster: guard against undefined message handlers cluster's internal message handling includes a cache of callback functions. Once the message for that callback is received, it is removed from the cache. If, for any reason, the same message ID is processed twice, the callback will be missing from the cache and cluster will try to call undefined as a function. This commit guards against this scenario. Refs: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6902 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- lib/cluster.js | 2 +- test/parallel/test-cluster-invalid-message.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-cluster-invalid-message.js diff --git a/lib/cluster.js b/lib/cluster.js index 62eb78eeba113e..72a3b79a93eec1 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -733,7 +733,7 @@ function internal(worker, cb) { return function(message, handle) { if (message.cmd !== 'NODE_CLUSTER') return; var fn = cb; - if (message.ack !== undefined) { + if (message.ack !== undefined && callbacks[message.ack] !== undefined) { fn = callbacks[message.ack]; delete callbacks[message.ack]; } diff --git a/test/parallel/test-cluster-invalid-message.js b/test/parallel/test-cluster-invalid-message.js new file mode 100644 index 00000000000000..006c80a7aae8fc --- /dev/null +++ b/test/parallel/test-cluster-invalid-message.js @@ -0,0 +1,22 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); + +if (cluster.isMaster) { + const worker = cluster.fork(); + + worker.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + })); + + worker.on('online', () => { + worker.send({ + cmd: 'NODE_CLUSTER', + ack: -1 + }, () => { + worker.disconnect(); + }); + }); +} From f395f6f5b2e8f00775ba77fc8ff287bcab57a124 Mon Sep 17 00:00:00 2001 From: Yazhong Liu Date: Fri, 27 May 2016 00:41:35 +0800 Subject: [PATCH 090/261] doc: add yorkie to collaborators PR-URL: https://github.com/nodejs/node/pull/7004 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fb54432ba0ef87..d7a1a9d3400f14 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ information about the governance of the Node.js project, see * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - **Vladimir Kurchatkin** <vladimir.kurchatkin@gmail.com> * [whitlockjc](https://github.com/whitlockjc) - **Jeremy Whitlock** <jwhitlock@apache.org> +* [yorkie](https://github.com/yorkie) - **Yorkie Liu** <yorkiefixer@gmail.com> * [yosuke-furukawa](https://github.com/yosuke-furukawa) - **Yosuke Furukawa** <yosuke.furukawa@gmail.com> * [zkat](https://github.com/zkat) - **Kat Marchán** <kzm@sykosomatic.org> From 8c412af7ac6719fc088531e45beae507c00906a4 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 26 May 2016 09:39:42 -0400 Subject: [PATCH 091/261] test: verify cluster worker exit test-cluster-disconnect-handles already includes logic that tries to cleanup any child processes when the test fails. This commit adds additional checks to verify that the child exited normally, and fails the test if that is not the case. Refs: https://github.com/nodejs/node/issues/6988 PR-URL: https://github.com/nodejs/node/pull/6993 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Santiago Gimeno --- test/parallel/test-cluster-disconnect-handles.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/parallel/test-cluster-disconnect-handles.js b/test/parallel/test-cluster-disconnect-handles.js index e2015254c5247b..e05733dbd9e953 100644 --- a/test/parallel/test-cluster-disconnect-handles.js +++ b/test/parallel/test-cluster-disconnect-handles.js @@ -31,6 +31,10 @@ if (cluster.isMaster) { // scanner but is ignored by atoi(3). Heinous hack. cluster.setupMaster({ execArgv: [`--debug=${common.PORT}.`] }); const worker = cluster.fork(); + worker.once('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0, 'worker did not exit normally'); + assert.strictEqual(signal, null, 'worker did not exit normally'); + })); worker.on('message', common.mustCall((message) => { assert.strictEqual(Array.isArray(message), true); assert.strictEqual(message[0], 'listening'); From e2e85ced1d7e7f75c4389fcd74ff6533398ce0b7 Mon Sep 17 00:00:00 2001 From: Bryan Hughes Date: Wed, 25 May 2016 10:32:37 -0700 Subject: [PATCH 092/261] doc: clarified use of sexual language in the CoC Clarifies the code of conduct by adding some wording discouraging the use of sexualized language. This PR was prompted by some moderation discussion, and we realized that there was some ambiguity around this topic in the current CoC PR-URL: https://github.com/nodejs/node/pull/6973 Reviewed-By: James M Snell Reviewed-By: Myles Borins Reviewed-By: Anna Henningsen Reviewed-By: Stephen Belanger Reviewed-By: Michael Dawson --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3d0f14d7201279..c250585b816f48 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -12,7 +12,7 @@ all. * Please be kind and courteous. There's no need to be mean or rude. * Respect that some individuals and cultures consider the casual use of - profanity offensive and off-putting. + profanity and sexualized language offensive and off-putting. * Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. From 649d201d63d013842d8b5c41d1274eac60bdc326 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 10:58:35 -0700 Subject: [PATCH 093/261] doc: improve `server.address()` doc text PR-URL: https://github.com/nodejs/node/pull/7001 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- doc/api/net.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index 976fd5677509fd..058f1257ce3f8d 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -37,10 +37,10 @@ Emitted when the server has been bound after calling `server.listen`. ### server.address() -Returns the bound address, the address family name and port of the server +Returns the bound address, the address family name, and port of the server as reported by the operating system. -Useful to find which port was assigned when giving getting an OS-assigned address. -Returns an object with three properties, e.g. +Useful to find which port was assigned when getting an OS-assigned address. +Returns an object with `port`, `family`, and `address` properties: `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` Example: From 72e8ee570a79c9371dbbd8f93f44d48c12625bf2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 10:54:19 -0700 Subject: [PATCH 094/261] doc: improve server.listen() documentation prose PR-URL: https://github.com/nodejs/node/pull/7000 Reviewed-By: Colin Ihrig Reviewed-By: Yuval Brik Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- doc/api/net.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index 058f1257ce3f8d..a140c4b5d95493 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -182,8 +182,8 @@ Begin accepting connections on the specified `port` and `hostname`. If the port value of zero will assign a random port. Backlog is the maximum length of the queue of pending connections. -The actual length will be determined by your OS through sysctl settings such as -`tcp_max_syn_backlog` and `somaxconn` on linux. The default value of this +The actual length will be determined by the OS through sysctl settings such as +`tcp_max_syn_backlog` and `somaxconn` on Linux. The default value of this parameter is 511 (not 512). This function is asynchronous. When the server has been bound, @@ -192,7 +192,7 @@ will be added as a listener for the [`'listening'`][] event. One issue some users run into is getting `EADDRINUSE` errors. This means that another server is already running on the requested port. One way of handling this -would be to wait a second and then try again. This can be done with +would be to wait a second and then try again: ```js server.on('error', (e) => { @@ -206,7 +206,7 @@ server.on('error', (e) => { }); ``` -(Note: All sockets in Node.js set `SO_REUSEADDR` already) +(Note: All sockets in Node.js are set `SO_REUSEADDR`.) ### server.maxConnections From 1c65f1e3f67b454871d54d1714b1148b4494e9f4 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Wed, 18 May 2016 09:27:14 -0400 Subject: [PATCH 095/261] doc: add info on what's used for fswatch on AIX Info is provided on for the other OS's. Add similar level of info for AIX. PR-URL: https://github.com/nodejs/node/pull/6837 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- doc/api/fs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index ed87141c07cc2d..0daf2e5f5d0879 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -821,6 +821,7 @@ to be notified of filesystem changes. * On OS X, this uses `kqueue` for files and 'FSEvents' for directories. * On SunOS systems (including Solaris and SmartOS), this uses `event ports`. * On Windows systems, this feature depends on `ReadDirectoryChangesW`. +* On Aix systems, this feature depends on `AHAFS`, which must be enabled. If the underlying functionality is not available for some reason, then `fs.watch` will not be able to function. For example, watching files or From cde3014f780b37cbc625de842d7a4d722895c296 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 25 May 2016 23:06:07 -0700 Subject: [PATCH 096/261] test: remove modifcation to common.PORT A possibly-buggy fixture server uses `common.PORT+1000` for its port rather than `common.PORT`. That could result in it clashing with other ports if tests are run in parallel. The test runner increments `common.PORT` by 100 for each running instance for tests. Change to use common.PORT and have the tests that use the fixture start with common.PORT+1 for anything they need. PR-URL: https://github.com/nodejs/node/pull/6990 Refs: https://github.com/nodejs/node/issues/6989 Reviewed-By: Myles Borins Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- test/fixtures/clustered-server/app.js | 2 +- test/parallel/test-debug-port-cluster.js | 2 +- test/parallel/test-debug-signal-cluster.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js index f89d70ee8f8ca6..cae204c25bd043 100644 --- a/test/fixtures/clustered-server/app.js +++ b/test/fixtures/clustered-server/app.js @@ -31,5 +31,5 @@ if (cluster.isMaster) { } } else { var server = http.createServer(handleRequest); - server.listen(common.PORT+1000); + server.listen(common.PORT); } diff --git a/test/parallel/test-debug-port-cluster.js b/test/parallel/test-debug-port-cluster.js index ba87a1ea3bff42..cc564b3ac1522c 100644 --- a/test/parallel/test-debug-port-cluster.js +++ b/test/parallel/test-debug-port-cluster.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -const PORT_MIN = common.PORT; +const PORT_MIN = common.PORT + 1; // The fixture uses common.PORT. const PORT_MAX = PORT_MIN + 2; const args = [ diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js index 7a950458b87271..e51cd9a50ab29f 100644 --- a/test/parallel/test-debug-signal-cluster.js +++ b/test/parallel/test-debug-signal-cluster.js @@ -3,7 +3,7 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var port = common.PORT + 42; +var port = common.PORT + 1; // The fixture uses common.PORT. var args = ['--debug-port=' + port, common.fixturesDir + '/clustered-server/app.js']; var options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] }; From fbdc16a8a407a0a44717164ac1cb9b010cc24b6c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 14:40:53 -0700 Subject: [PATCH 097/261] doc: update labels and CI info in onboarding doc PR-URL: https://github.com/nodejs/node/pull/7006 Reviewed-By: Robert Jefe Lindstaedt Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- doc/onboarding.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/doc/onboarding.md b/doc/onboarding.md index 1646080f3b3bbf..99fbc61935c84d 100644 --- a/doc/onboarding.md +++ b/doc/onboarding.md @@ -54,15 +54,13 @@ Ensure everyone is added to https://github.com/orgs/nodejs/teams/collaborators * Still need to follow the Code of Conduct. - * labels: - * generally sort issues by a concept of "subsystem" so that we know what part(s) of the codebase it touches, though there are also other useful labels. - * [**See "Labels"**](./onboarding-extras.md#labels) - * `ctc-agenda` if a topic is controversial or isn't coming to a conclusion after an extended time. + * Labels: + * There is [a bot](https://github.com/nodejs-github-bot/github-bot) that applies subsystem labels (for example, `doc`, `test`, `assert`, or `buffer`) so that we know what parts of the code base the pull request modifies. It is not perfect, of course. Feel free to apply relevant labels and remove irrelevant labels from pull requests and issues. + * [**See "Labels"**](./onboarding-extras.md#labels) + * Use the `ctc-agenda` if a topic is controversial or isn't coming to a conclusion after an extended time. * `semver-{minor,major}`: - * be conservative – that is, if a change has the remote *chance* of breaking something, go for `semver-major` - * when adding a semver label, add a comment explaining why you're adding it - * it's cached locally in your brain at that moment! - + * If a change has the remote *chance* of breaking something, use `semver-major` + * When adding a semver label, add a comment explaining why you're adding it. Do it right away so you don't forget! * Notifying humans * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) @@ -103,14 +101,17 @@ Ensure everyone is added to https://github.com/orgs/nodejs/teams/collaborators * also, things that cannot be done outside of core, or only with significant pain (example: async-wrap) - * CI testing: - * lives here: https://ci.nodejs.org/ - * not automatically run - some of the platforms we test do not have full sandboxing support so we need to ensure what we run on it isn't potentially malicious - * make sure to log in – we use github authentication so it should be seamless - * go to "node-test-pull-request" and "Build with parameters" - * fill in the pull request number without the `#`, and check the verification that you have reviewed the code for potential malice - * The other options shouldn't need to be adjusted in most cases. - * link to the CI run in the PR by commenting "CI: " + * Continuous Integration (CI) Testing: + * https://ci.nodejs.org/ + * It is not automatically run. You need to start it manually. + * Log in on CI is integrated with GitHub. Try to log in now! + * You will be using `node-test-pull-request` most of the time. Go there now! + * To get to the form to start a job, click on `Build with Parameters`. (If you don't see it, that probably means you are not logged in!) Click it now! + * To start CI testing from this screen, you need to fill in two elements on the form: + * The `CERTIFY_SAFE` box should be checked. By checking it, you are indicating that you have reviewed the code you are about to test and you are confident that it does not contain any malicious code. (We don't want people hijacking our CI hosts to attack other hosts on the internet, for example!) + * The `PR_ID` box should be filled in with the number identifying the pull request containing the code you wish to test. For example, if the URL for the pull request is https://github.com/nodejs/node/issues/7006, then put `7006` in the `PR_ID`. + * The remaining elements on the form are typically unchanged. + * There is a checkbox for `POST_STATUS_TO_PR`. At the time of this writing, that checkbox does not do anything, but that is likely to change soon. Until that functionality is working, you will want to go back to the PR you are testing and paste `CI: ` into a comment on the pull request. ### process for getting code in: From 694e34458b67812bca0975d37fddecc6b6ca1a88 Mon Sep 17 00:00:00 2001 From: Joao Andrade Date: Sat, 28 May 2016 03:09:49 +0100 Subject: [PATCH 098/261] doc: fix typos in WORKING_GROUPS.md PR-URL: https://github.com/nodejs/node/pull/7032 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- WORKING_GROUPS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKING_GROUPS.md b/WORKING_GROUPS.md index 451251320c1168..88f44fbe2d8a4a 100644 --- a/WORKING_GROUPS.md +++ b/WORKING_GROUPS.md @@ -179,7 +179,7 @@ content. ### [HTTP](https://github.com/nodejs/http) The HTTP working group is chartered for the support and improvement of the -HTTP implementation in Node. It's responsibilities are: +HTTP implementation in Node. Its responsibilities are: * Addressing HTTP issues on the Node.js issue tracker. * Authoring and editing HTTP documentation within the Node.js project. @@ -293,7 +293,7 @@ Its responsibilities are: The Node.js Testing Working Group's purpose is to extend and improve testing of the Node.js source code. -It's responsibilities are: +Its responsibilities are: * Coordinating an overall strategy for improving testing. * Documenting guidelines around tests. From 146cba1f6029899f180d7cfdc97103971b195f1f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 16:35:23 -0700 Subject: [PATCH 099/261] doc: improve debugger doc prose PR-URL: https://github.com/nodejs/node/pull/7007 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/debugger.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/doc/api/debugger.md b/doc/api/debugger.md index 2bbaf9049eb5fb..7b49c6e02d8db4 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -20,13 +20,11 @@ break in /home/indutny/Code/git/indutny/myscript.js:1 debug> ``` -Node.js's debugger client does not yet support the full range of commands, but -simple step and inspection are possible. +Node.js's debugger client is not a full-featured debugger, but simple step and +inspection are possible. Inserting the statement `debugger;` into the source code of a script will -enable a breakpoint at that position in the code. - -For example, suppose `myscript.js` is written as: +enable a breakpoint at that position in the code: ```js // myscript.js @@ -81,8 +79,7 @@ debug> quit ``` The `repl` command allows code to be evaluated remotely. The `next` command -steps over to the next line. Type `help` to see what other commands are -available. +steps to the next line. Type `help` to see what other commands are available. ## Watchers @@ -95,7 +92,7 @@ To begin watching an expression, type `watch('my_expression')`. The command `watchers` will print the active watchers. To remove a watcher, type `unwatch('my_expression')`. -## Commands reference +## Command reference ### Stepping @@ -142,7 +139,7 @@ break in test/fixtures/break-in-module/mod.js:23 debug> ``` -### Info +### Information * `backtrace`, `bt` - Print backtrace of current execution frame * `list(5)` - List scripts source code with 5 line context (5 lines before and @@ -171,7 +168,7 @@ An alternative way of enabling and accessing the debugger is to start Node.js with the `--debug` command-line flag or by signaling an existing Node.js process with `SIGUSR1`. -Once a process has been set in debug mode this way, it can be connected to +Once a process has been set in debug mode this way, it can be inspected using the Node.js debugger by either connecting to the `pid` of the running process or via URI reference to the listening debugger: From 644bfe14a6976b812b6fc4cc1307e0a9fe1dcb52 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sun, 29 May 2016 12:57:58 +0200 Subject: [PATCH 100/261] test: fix test-debug-port-numbers on OS X According to kill(2), kill returns `EPERM` error if when signalling a process group any of the members could not be signalled. PR-URL: https://github.com/nodejs/node/pull/7046 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- test/parallel/test-debug-port-numbers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-debug-port-numbers.js b/test/parallel/test-debug-port-numbers.js index c7bf1da5f64849..33cdf6035b449a 100644 --- a/test/parallel/test-debug-port-numbers.js +++ b/test/parallel/test-debug-port-numbers.js @@ -44,7 +44,9 @@ function kill(child) { try { process.kill(-child.pid); // Kill process group. } catch (e) { - assert.strictEqual(e.code, 'ESRCH'); // Already gone. + // Generally ESRCH is returned when the process group is already gone. On + // some platforms such as OS X it may be EPERM though. + assert.ok((e.code === 'EPERM') || (e.code === 'ESRCH')); } } From 15bb0beab2bd0de515cffc84cca3e1b48cd71176 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 26 May 2016 02:33:21 +0200 Subject: [PATCH 101/261] doc,test: add `How to write a Node.js test` guide PR-URL: https://github.com/nodejs/node/pull/6984 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Yorkie Liu --- CONTRIBUTING.md | 5 +- doc/guides/writing_tests.md | 186 ++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 doc/guides/writing_tests.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efe83ccf204f36..62f414832e508b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,8 +140,9 @@ $ git rebase upstream/master ### Step 5: Test Bug fixes and features **should come with tests**. Add your tests in the -test/parallel/ directory. Look at other tests to see how they should be -structured (license boilerplate, common includes, etc.). +`test/parallel/` directory. For guidance on how to write a test for the Node.js +project, see this [guide](./doc/guides/writing_tests.md). Looking at other tests +to see how they should be structured can also help. ```text $ ./configure && make -j8 test diff --git a/doc/guides/writing_tests.md b/doc/guides/writing_tests.md new file mode 100644 index 00000000000000..95a09540b47ee4 --- /dev/null +++ b/doc/guides/writing_tests.md @@ -0,0 +1,186 @@ +# How to write a test for the Node.js project + +## What is a test? + +A test must be a node script that exercises a specific functionality provided +by node and checks that it behaves as expected. It should return 0 on success, +otherwise it will fail. A test will fail if: + +- It exits by calling `process.exit(code)` where `code != 0` +- It exits due to an uncaught exception. +- It never exits. In this case, the test runner will terminate the test because + it sets a maximum time limit. + +Tests can be added for multiple reasons: + +- When adding new functionality. +- When fixing regressions and bugs. +- When expanding test coverage. + + +## Test structure + +Let's analyze this very basic test from the Node.js test suite: + +```javascript +1 'use strict'; +2 const common = require('../common'); +3 const http = require('http'); +4 const assert = require('assert'); +5 +6 const server = http.createServer(common.mustCall((req, res) => { +7 res.end('ok'); +8 })); +9 server.listen(common.PORT, () => { +10 http.get({ +11 port: common.PORT, +12 headers: {'Test': 'Düsseldorf'} +13 }, common.mustCall((res) => { +14 assert.equal(res.statusCode, 200); +15 server.close(); +16 })); +17 }); +``` + +**Lines 1-2** + +```javascript +'use strict'; +const common = require('../common'); +``` + +These two lines are mandatory and should be included on every test. +The `common` module is a helper module that provides useful tools for the tests. +If for some reason, no functionality from `common` is used, it should still be +included like this: + +```javascript +require('../common'); +``` + +Why? It checks for leaks of globals. + +**Lines 3-4** + +```javascript +const http = require('http'); +const assert = require('assert'); +``` + +These modules are required for the test to run. Except for special cases, these +modules should only include core modules. +The `assert` module is used by most of the tests to check that the assumptions +for the test are met. + +**Lines 6-17** + +This is the body of the test. This test is quite simple, it just tests that an +HTTP server accepts `non-ASCII` characters in the headers of an incoming +request. Interesting things to notice: + +- The use of `common.PORT` as the listening port. Always use `common.PORT` + instead of using an arbitrary value, as it allows to run tests in parallel + safely, as they are not trying to reuse the same port another test is already + using. +- The use of `common.mustCall` to check that some callbacks/listeners are + called. +- The HTTP server is closed once all the checks have run. This way, the test can + exit gracefully. Remember that for a test to succeed, it must exit with a + status code of 0. + +## General recommendations + +### Timers + +The use of timers is discouraged, unless timers are being tested. There are +multiple reasons for this. Mainly, they are a source of flakiness. For a thorough +explanation go [here](https://github.com/nodejs/testing/issues/27). + +In the event a timer is needed, it's recommended using the +`common.platformTimeout()` method, that allows setting specific timeouts +depending on the platform. For example: + +```javascript +const timer = setTimeout(fail, common.platformTimeout(4000)); +``` + +will create a 4-seconds timeout, except for some platforms where the delay will +be multiplied for some factor. + +### The *common* API + +Make use of the helpers from the `common` module as much as possible. + +One interesting case is `common.mustCall`. The use of `common.mustCall` may +avoid the use of extra variables and the corresponding assertions. Let's explain +this with a real test from the test suite. + +```javascript +'use strict'; +var common = require('../common'); +var assert = require('assert'); +var http = require('http'); + +var request = 0; +var response = 0; +process.on('exit', function() { + assert.equal(request, 1, 'http server "request" callback was not called'); + assert.equal(response, 1, 'http request "response" callback was not called'); +}); + +var server = http.createServer(function(req, res) { + request++; + res.end(); +}).listen(common.PORT, function() { + var options = { + agent: null, + port: this.address().port + }; + http.get(options, function(res) { + response++; + res.resume(); + server.close(); + }); +}); +``` + +This test could be greatly simplified by using `common.mustCall` like this: + +```javascript +'use strict'; +var common = require('../common'); +var assert = require('assert'); +var http = require('http'); + +var server = http.createServer(common.mustCall(function(req, res) { + res.end(); +})).listen(common.PORT, function() { + var options = { + agent: null, + port: this.address().port + }; + http.get(options, common.mustCall(function(res) { + res.resume(); + server.close(); + })); +}); + +``` + +### Flags + +Some tests will require running Node.js with specific command line flags set. To +accomplish this, a `// Flags: ` comment should be added in the preamble of the +test followed by the flags. For example, to allow a test to require some of the +`internal/*` modules, the `--expose-internals` flag should be added. +A test that would require `internal/freelist` could start like this: + +```javascript +'use strict'; + +// Flags: --expose-internals + +require('../common'); +const assert = require('assert'); +const freelist = require('internal/freelist'); +``` From 44228dfdef9d50bfe77ed0abfad5e322315cc918 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 20:49:51 -0700 Subject: [PATCH 102/261] test: remove `common.PORT` from gc tests Allow the operating system to provide an arbitrary available port rather than using `common.PORT`, as `common.PORT` makes it likely that a test will fail with `EADDRINUSE` as a side effect of an earlier test. PR-URL: https://github.com/nodejs/node/pull/7013 Reviewed-By: Brian White Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis --- test/gc/test-http-client-connaborted.js | 7 +++---- test/gc/test-http-client-onerror.js | 7 +++---- test/gc/test-http-client-timeout.js | 7 +++---- test/gc/test-http-client.js | 7 +++---- test/gc/test-net-timeout.js | 7 +++---- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 074457a7511fc5..3442effc56b5a1 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -8,9 +8,8 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const common = require('../common'); +require('../common'); const assert = require('assert'); -const PORT = common.PORT; const todo = 500; let done = 0; let count = 0; @@ -19,7 +18,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); var server = http.createServer(serverHandler); -server.listen(PORT, getall); +server.listen(0, getall); function getall() { if (count >= todo) @@ -34,7 +33,7 @@ function getall() { var req = http.get({ hostname: 'localhost', pathname: '/', - port: PORT + port: server.address().port }, cb).on('error', cb); count++; diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index 2e5ef6a54288d4..1490513b6c177b 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -10,9 +10,8 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const common = require('../common'); +require('../common'); const assert = require('assert'); -const PORT = common.PORT; const todo = 500; let done = 0; let count = 0; @@ -21,7 +20,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); var server = http.createServer(serverHandler); -server.listen(PORT, runTest); +server.listen(0, runTest); function getall() { if (count >= todo) @@ -40,7 +39,7 @@ function getall() { var req = http.get({ hostname: 'localhost', pathname: '/', - port: PORT + port: server.address().port }, cb).on('error', onerror); count++; diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index d80cf9cdee1532..722f995229c2ca 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -12,9 +12,8 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const common = require('../common'); +require('../common'); const assert = require('assert'); -const PORT = common.PORT; const todo = 550; let done = 0; let count = 0; @@ -23,7 +22,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); var server = http.createServer(serverHandler); -server.listen(PORT, getall); +server.listen(0, getall); function getall() { if (count >= todo) @@ -39,7 +38,7 @@ function getall() { var req = http.get({ hostname: 'localhost', pathname: '/', - port: PORT + port: server.address().port }, cb); req.on('error', cb); req.setTimeout(10, function() { diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 73f284a042c37a..2f519c1b12486c 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -8,9 +8,8 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const common = require('../common'); +require('../common'); const assert = require('assert'); -const PORT = common.PORT; const todo = 500; let done = 0; let count = 0; @@ -19,7 +18,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); var server = http.createServer(serverHandler); -server.listen(PORT, getall); +server.listen(0, getall); function getall() { @@ -37,7 +36,7 @@ function getall() { var req = http.get({ hostname: 'localhost', pathname: '/', - port: PORT + port: server.address().port }, cb); count++; diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 24671a647e0eac..7d580f8f2356a4 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -19,9 +19,8 @@ function serverHandler(sock) { const net = require('net'); const weak = require('weak'); -const common = require('../common'); +require('../common'); const assert = require('assert'); -const PORT = common.PORT; const todo = 500; let done = 0; let count = 0; @@ -30,14 +29,14 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); var server = net.createServer(serverHandler); -server.listen(PORT, getall); +server.listen(0, getall); function getall() { if (count >= todo) return; (function() { - var req = net.connect(PORT, '127.0.0.1'); + var req = net.connect(server.address().port, server.address().address); req.resume(); req.setTimeout(10, function() { //console.log('timeout (expected)') From 6ece2a03226c18f2e9e391a8da93c3bc6fc8ab07 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 29 May 2016 14:02:22 -0400 Subject: [PATCH 103/261] cluster: rewrite debug ports consistently When debug flags are passed to clustered applications, the debug port is rewritten for each worker process to avoid collisions. Prior to this commit, each debug flag would get a unique value. This commit reworks the logic to assign the same port value to all debug flags for a single worker. PR-URL: https://github.com/nodejs/node/pull/7050 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- lib/cluster.js | 8 ++++++-- test/parallel/test-cluster-debug-port.js | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/cluster.js b/lib/cluster.js index 72a3b79a93eec1..da57f5cd08b30a 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -286,6 +286,7 @@ function masterInit() { function createWorkerProcess(id, env) { var workerEnv = util._extend({}, process.env); var execArgv = cluster.settings.execArgv.slice(); + var debugPort = 0; workerEnv = util._extend(workerEnv, env); workerEnv.NODE_UNIQUE_ID = '' + id; @@ -294,8 +295,11 @@ function masterInit() { var match = execArgv[i].match(/^(--debug|--debug-(brk|port))(=\d+)?$/); if (match) { - const debugPort = process.debugPort + debugPortOffset; - ++debugPortOffset; + if (debugPort === 0) { + debugPort = process.debugPort + debugPortOffset; + ++debugPortOffset; + } + execArgv[i] = match[1] + '=' + debugPort; } } diff --git a/test/parallel/test-cluster-debug-port.js b/test/parallel/test-cluster-debug-port.js index 076a59108b09de..efc3fae62e58a4 100644 --- a/test/parallel/test-cluster-debug-port.js +++ b/test/parallel/test-cluster-debug-port.js @@ -23,6 +23,11 @@ if (cluster.isMaster) { portSet: process.debugPort + 1 }).on('exit', checkExitCode); + cluster.setupMaster({ + execArgv: [`--debug-port=${process.debugPort}`, + `--debug=${process.debugPort}`] + }); + console.log('forked worker should have --debug-port, with offset = 2'); cluster.fork({ portSet: process.debugPort + 2 From 5b1f54678b7a39aaa11cb7511d57abb422f30c30 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 29 May 2016 13:57:41 -0700 Subject: [PATCH 104/261] test: remove non-incremental common.PORT changes Remove uses of `common.PORT + 1337` where `common.PORT` suffices. PR-URL: https://github.com/nodejs/node/pull/7055 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Refs: https://github.com/nodejs/node/pull/6990 --- test/debugger/helper-debugger-repl.js | 2 +- test/debugger/test-debugger-client.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js index 20cd341165042d..766c6566f7e4c0 100644 --- a/test/debugger/helper-debugger-repl.js +++ b/test/debugger/helper-debugger-repl.js @@ -4,7 +4,7 @@ var common = require('../common'); var assert = require('assert'); var spawn = require('child_process').spawn; -var port = common.PORT + 1337; +var port = common.PORT; var child; var buffer = ''; diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index fe65405c8583ce..da2c2b839282b5 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -4,7 +4,7 @@ var common = require('../common'); var assert = require('assert'); var debug = require('_debugger'); -var debugPort = common.PORT + 1337; +var debugPort = common.PORT; debug.port = debugPort; var spawn = require('child_process').spawn; From 96de3f88202b025eaf25db906f0656b00623e0e0 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Tue, 17 May 2016 16:26:18 -0400 Subject: [PATCH 105/261] doc: Add CII Best Practices badge to README.md Node.js has earned the Linux Foundation Core Infrastructure Initiative (CII) best practices badge. This change lets people see that, including a link for more information. The badge lets users and potential users of Node.js know that Node.js follows best practices. It may also help spur other projects to follow Node.js's lead. My thanks to Rod Vagg, who did the work to see that Node.js earned the badge. PR-URL: https://github.com/nodejs/node/pull/6819 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Rod Vagg Reviewed-By: Myles Borins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7a1a9d3400f14..847ffc886196d4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Node.js ======= -[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/nodejs/node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/nodejs/node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/29/badge)](https://bestpractices.coreinfrastructure.org/projects/29) Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and From 77325d585e1bd432a8983c6438966d4f06e08a96 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 31 May 2016 15:23:31 -0700 Subject: [PATCH 106/261] test: remove disabled eio race test The project does not use libeio anymore. Remove disabled libeio-specific test. PR-URL: https://github.com/nodejs/node/pull/7083 Reviewed-By: Colin Ihrig Reviewed-By: Brian White Reviewed-By: Ben Noordhuis --- test/disabled/test-eio-race.js | 64 ---------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 test/disabled/test-eio-race.js diff --git a/test/disabled/test-eio-race.js b/test/disabled/test-eio-race.js deleted file mode 100644 index 32585894d0d7c3..00000000000000 --- a/test/disabled/test-eio-race.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var count = 100; -var fs = require('fs'); - -// person.jpg is 57kb. We just need some file that is sufficiently large. -var filename = require('path').join(common.fixturesDir, 'person.jpg'); - -function tryToKillEventLoop() { - console.log('trying to kill event loop ...'); - - fs.stat(__filename, function(err) { - if (err) { - throw new Exception('first fs.stat failed'); - } else { - fs.stat(__filename, function(err) { - if (err) { - throw new Exception('second fs.stat failed'); - } else { - console.log('could not kill event loop, retrying...'); - - setTimeout(function() { - if (--count) { - tryToKillEventLoop(); - } else { - console.log('done trying to kill event loop'); - process.exit(0); - } - }, 1); - } - }); - } - }); -} - -// Generate a lot of thread pool events -var pos = 0; -fs.open(filename, 'r', 0o666, function(err, fd) { - if (err) throw err; - - function readChunk() { - fs.read(fd, 1024, 0, 'binary', function(err, chunk, bytesRead) { - if (err) throw err; - if (chunk) { - pos += bytesRead; - //console.log(pos); - readChunk(); - } else { - fs.closeSync(fd); - throw new Exception("Shouldn't get EOF"); - } - }); - } - readChunk(); -}); - -tryToKillEventLoop(); - -process.on('exit', function() { - console.log('done with test'); - assert.ok(pos > 10000); -}); From 1bd62c7c3438107a17095ca82bf218afe887c5ad Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 29 May 2016 22:19:02 +0200 Subject: [PATCH 107/261] benchmark: add benchmark for Buffer.concat PR-URL: https://github.com/nodejs/node/pull/7054 Reviewed-By: James M Snell Reviewed-By: Brian White --- benchmark/buffers/buffer-concat.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 benchmark/buffers/buffer-concat.js diff --git a/benchmark/buffers/buffer-concat.js b/benchmark/buffers/buffer-concat.js new file mode 100644 index 00000000000000..a27e132193ef41 --- /dev/null +++ b/benchmark/buffers/buffer-concat.js @@ -0,0 +1,26 @@ +'use strict'; +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + pieces: [1, 4, 16], + pieceSize: [1, 16, 256], + withTotalLength: [0, 1], + n: [1024] +}); + +function main(conf) { + const n = +conf.n; + const size = +conf.pieceSize; + const pieces = +conf.pieces; + + const list = new Array(pieces); + list.fill(Buffer.allocUnsafe(size)); + + const totalLength = conf.withTotalLength ? pieces * size : undefined; + + bench.start(); + for (var i = 0; i < n * 1024; i++) { + Buffer.concat(list, totalLength); + } + bench.end(n); +} From 0013af61de0c415f39cb9a6d8e778c94a0468a65 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 3 Jun 2016 12:49:44 -0700 Subject: [PATCH 108/261] doc: fix header depth of util.isSymbol PR-URL: https://github.com/nodejs/node/pull/7138 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- doc/api/util.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/util.md b/doc/api/util.md index 1083eb03568823..3f9165f02110af 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -498,7 +498,7 @@ util.isString(5) // false ``` -## util.isSymbol(object) +### util.isSymbol(object) Stability: 0 - Deprecated From 2a59e4e73d3f06820df894a58553fb2f638e2466 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 16 May 2016 13:55:11 -0700 Subject: [PATCH 109/261] test: improve debug-break-on-uncaught reliability Running the test through CI reveals unreliability due to a race condition. These changes mitigate the race condition, but do not eliminate it. PR-URL: https://github.com/nodejs/node/pull/6793 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Claudio Rodriguez --- test/debugger/test-debug-break-on-uncaught.js | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index 8a5af3abea8a58..4a63751aaf2857 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/test/debugger/test-debug-break-on-uncaught.js @@ -1,22 +1,22 @@ 'use strict'; -var path = require('path'); -var assert = require('assert'); -var spawn = require('child_process').spawn; -var common = require('../common'); -var debug = require('_debugger'); +const path = require('path'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const common = require('../common'); +const debug = require('_debugger'); -addScenario('global.js', null, 2); -addScenario('timeout.js', null, 2); +var scenarios = []; + +addScenario('global.js', 2); +addScenario('timeout.js', 2); run(); /***************** IMPLEMENTATION *****************/ -var scenarios; -function addScenario(scriptName, throwsInFile, throwsOnLine) { - if (!scenarios) scenarios = []; +function addScenario(scriptName, throwsOnLine) { scenarios.push( - runScenario.bind(null, scriptName, throwsInFile, throwsOnLine, run) + runScenario.bind(null, scriptName, throwsOnLine, run) ); } @@ -25,10 +25,10 @@ function run() { if (next) next(); } -function runScenario(scriptName, throwsInFile, throwsOnLine, next) { +function runScenario(scriptName, throwsOnLine, next) { console.log('**[ %s ]**', scriptName); var asserted = false; - var port = common.PORT + 1337; + var port = common.PORT; var testScript = path.join( common.fixturesDir, @@ -44,7 +44,18 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { var exceptions = []; - setTimeout(setupClient.bind(null, runTest), 200); + var stderr = ''; + + function stderrListener(data) { + stderr += data; + if (stderr.includes('Debugger listening on port')) { + setTimeout(setupClient.bind(null, runTest), 200); + child.stderr.removeListener('data', stderrListener); + } + } + + child.stderr.setEncoding('utf8'); + child.stderr.on('data', stderrListener); function setupClient(callback) { var client = new debug.Client(); @@ -88,11 +99,11 @@ function runScenario(scriptName, throwsInFile, throwsOnLine, next) { } function assertHasPaused(client) { + assert(exceptions.length, 'no exceptions thrown, race condition in test?'); assert.equal(exceptions.length, 1, 'debugger did not pause on exception'); assert.equal(exceptions[0].uncaught, true); - assert.equal(exceptions[0].script.name, throwsInFile || testScript); - if (throwsOnLine != null) - assert.equal(exceptions[0].sourceLine + 1, throwsOnLine); + assert.equal(exceptions[0].script.name, testScript); + assert.equal(exceptions[0].sourceLine + 1, throwsOnLine); asserted = true; client.reqContinue(assert.ifError); } From 8eb18e42898e567e6932c70bc4e31c030b8c2df6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 14 May 2016 15:24:34 -0700 Subject: [PATCH 110/261] child_process: measure buffer length in bytes This change fixes a known issue where `maxBuffer` limits by characters rather than bytes. Benchmark added to confirm no performance regression occurs with this change. PR-URL: https://github.com/nodejs/node/pull/6764 Fixes: https://github.com/nodejs/node/issues/1901 Reviewed-By: Brian White --- .../child-process-exec-stdout.js | 30 ++++++++ benchmark/child_process/child-process-read.js | 18 ++--- lib/child_process.js | 71 +++++++++++-------- .../test-child-process-maxBuffer-stderr.js | 15 ++++ .../test-child-process-maxBuffer-stdout.js} | 3 +- 5 files changed, 96 insertions(+), 41 deletions(-) create mode 100644 benchmark/child_process/child-process-exec-stdout.js create mode 100644 test/parallel/test-child-process-maxBuffer-stderr.js rename test/{known_issues/test-child-process-max-buffer.js => parallel/test-child-process-maxBuffer-stdout.js} (75%) diff --git a/benchmark/child_process/child-process-exec-stdout.js b/benchmark/child_process/child-process-exec-stdout.js new file mode 100644 index 00000000000000..79efb6fadf2aeb --- /dev/null +++ b/benchmark/child_process/child-process-exec-stdout.js @@ -0,0 +1,30 @@ +'use strict'; +const common = require('../common.js'); +const bench = common.createBenchmark(main, { + len: [64, 256, 1024, 4096, 32768], + dur: [5] +}); + +const exec = require('child_process').exec; +function main(conf) { + bench.start(); + + const dur = +conf.dur; + const len = +conf.len; + + const msg = `"${'.'.repeat(len)}"`; + msg.match(/./); + const options = {'stdio': ['ignore', 'pipe', 'ignore']}; + // NOTE: Command below assumes bash shell. + const child = exec(`while\n echo ${msg}\ndo :; done\n`, options); + + var bytes = 0; + child.stdout.on('data', function(msg) { + bytes += msg.length; + }); + + setTimeout(function() { + child.kill(); + bench.end(bytes); + }, dur * 1000); +} diff --git a/benchmark/child_process/child-process-read.js b/benchmark/child_process/child-process-read.js index c1a7474aae32c1..33c268390fd5c3 100644 --- a/benchmark/child_process/child-process-read.js +++ b/benchmark/child_process/child-process-read.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common.js'); -var bench = common.createBenchmark(main, { +const common = require('../common.js'); +const bench = common.createBenchmark(main, { len: [64, 256, 1024, 4096, 32768], dur: [5] }); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; function main(conf) { bench.start(); - var dur = +conf.dur; - var len = +conf.len; + const dur = +conf.dur; + const len = +conf.len; - var msg = '"' + Array(len).join('.') + '"'; - var options = { 'stdio': ['ignore', 'ipc', 'ignore'] }; - var child = spawn('yes', [msg], options); + const msg = '"' + Array(len).join('.') + '"'; + const options = {'stdio': ['ignore', 'ipc', 'ignore']}; + const child = spawn('yes', [msg], options); var bytes = 0; child.on('message', function(msg) { @@ -23,7 +23,7 @@ function main(conf) { setTimeout(function() { child.kill(); - var gbits = (bytes * 8) / (1024 * 1024 * 1024); + const gbits = (bytes * 8) / (1024 * 1024 * 1024); bench.end(gbits); }, dur * 1000); } diff --git a/lib/child_process.js b/lib/child_process.js index e43093ace1fa0d..7728b89bdb5fba 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -157,15 +157,13 @@ exports.execFile = function(file /*, args, options, callback*/) { }); var encoding; - var _stdout; - var _stderr; + var stdoutState; + var stderrState; + var _stdout = []; + var _stderr = []; if (options.encoding !== 'buffer' && Buffer.isEncoding(options.encoding)) { encoding = options.encoding; - _stdout = ''; - _stderr = ''; } else { - _stdout = []; - _stderr = []; encoding = null; } var stdoutLen = 0; @@ -187,16 +185,23 @@ exports.execFile = function(file /*, args, options, callback*/) { if (!callback) return; - // merge chunks - var stdout; - var stderr; - if (!encoding) { - stdout = Buffer.concat(_stdout); - stderr = Buffer.concat(_stderr); - } else { - stdout = _stdout; - stderr = _stderr; - } + var stdout = Buffer.concat(_stdout, stdoutLen); + var stderr = Buffer.concat(_stderr, stderrLen); + + var stdoutEncoding = encoding; + var stderrEncoding = encoding; + + if (stdoutState && stdoutState.decoder) + stdoutEncoding = stdoutState.decoder.encoding; + + if (stderrState && stderrState.decoder) + stderrEncoding = stderrState.decoder.encoding; + + if (stdoutEncoding) + stdout = stdout.toString(stdoutEncoding); + + if (stderrEncoding) + stderr = stderr.toString(stderrEncoding); if (ex) { // Will be handled later @@ -256,39 +261,45 @@ exports.execFile = function(file /*, args, options, callback*/) { } if (child.stdout) { - if (encoding) - child.stdout.setEncoding(encoding); + stdoutState = child.stdout._readableState; child.stdout.addListener('data', function(chunk) { - stdoutLen += chunk.length; + // If `child.stdout.setEncoding()` happened in userland, convert string to + // Buffer. + if (stdoutState.decoder) { + chunk = Buffer.from(chunk, stdoutState.decoder.encoding); + } + + stdoutLen += chunk.byteLength; if (stdoutLen > options.maxBuffer) { ex = new Error('stdout maxBuffer exceeded'); + stdoutLen -= chunk.byteLength; kill(); } else { - if (!encoding) - _stdout.push(chunk); - else - _stdout += chunk; + _stdout.push(chunk); } }); } if (child.stderr) { - if (encoding) - child.stderr.setEncoding(encoding); + stderrState = child.stderr._readableState; child.stderr.addListener('data', function(chunk) { - stderrLen += chunk.length; + // If `child.stderr.setEncoding()` happened in userland, convert string to + // Buffer. + if (stderrState.decoder) { + chunk = Buffer.from(chunk, stderrState.decoder.encoding); + } + + stderrLen += chunk.byteLength; if (stderrLen > options.maxBuffer) { ex = new Error('stderr maxBuffer exceeded'); + stderrLen -= chunk.byteLength; kill(); } else { - if (!encoding) - _stderr.push(chunk); - else - _stderr += chunk; + _stderr.push(chunk); } }); } diff --git a/test/parallel/test-child-process-maxBuffer-stderr.js b/test/parallel/test-child-process-maxBuffer-stderr.js new file mode 100644 index 00000000000000..ecaea8b152a0ca --- /dev/null +++ b/test/parallel/test-child-process-maxBuffer-stderr.js @@ -0,0 +1,15 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const unicode = '中文测试'; // Length = 4, Byte length = 13 + +if (process.argv[2] === 'child') { + console.error(unicode); +} else { + const cmd = `${process.execPath} ${__filename} child`; + + cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err.message, 'stderr maxBuffer exceeded'); + })); +} diff --git a/test/known_issues/test-child-process-max-buffer.js b/test/parallel/test-child-process-maxBuffer-stdout.js similarity index 75% rename from test/known_issues/test-child-process-max-buffer.js rename to test/parallel/test-child-process-maxBuffer-stdout.js index 14a344c7062a5a..122dc499f462bf 100644 --- a/test/known_issues/test-child-process-max-buffer.js +++ b/test/parallel/test-child-process-maxBuffer-stdout.js @@ -1,5 +1,4 @@ 'use strict'; -// Refs: https://github.com/nodejs/node/issues/1901 const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); @@ -10,7 +9,7 @@ if (process.argv[2] === 'child') { } else { const cmd = `${process.execPath} ${__filename} child`; - cp.exec(cmd, { maxBuffer: 10 }, common.mustCall((err, stdout, stderr) => { + cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => { assert.strictEqual(err.message, 'stdout maxBuffer exceeded'); })); } From 9d13337183b84e51dea998cc9e37cc26b1bf4730 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 3 Jun 2016 23:59:04 -0400 Subject: [PATCH 111/261] http: wait for both prefinish/end to keepalive When `free`ing the socket to be reused in keep-alive Agent wait for both `prefinish` and `end` events. Otherwise the next request may be written before the previous one has finished sending the body, leading to a parser errors. PR-URL: https://github.com/nodejs/node/pull/7149 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- lib/_http_client.js | 27 +++++++++++-- ...client-keep-alive-release-before-finish.js | 38 +++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-http-client-keep-alive-release-before-finish.js diff --git a/lib/_http_client.js b/lib/_http_client.js index 3e3b9966c275bf..c07589e9c5da6f 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -156,6 +156,8 @@ function ClientRequest(options, cb) { self._flush(); self = null; }); + + this._ended = false; } util.inherits(ClientRequest, OutgoingMessage); @@ -427,6 +429,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) { // add our listener first, so that we guarantee socket cleanup res.on('end', responseOnEnd); + req.on('prefinish', requestOnPrefinish); var handled = req.emit('response', res); // If the user did not listen for the 'response' event, then they @@ -439,9 +442,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) { } // client -function responseOnEnd() { - var res = this; - var req = res.req; +function responseKeepAlive(res, req) { var socket = req.socket; if (!req.shouldKeepAlive) { @@ -465,6 +466,26 @@ function responseOnEnd() { } } +function responseOnEnd() { + const res = this; + const req = this.req; + + req._ended = true; + if (!req.shouldKeepAlive || req.finished) + responseKeepAlive(res, req); +} + +function requestOnPrefinish() { + const req = this; + const res = this.res; + + if (!req.shouldKeepAlive) + return; + + if (req._ended) + responseKeepAlive(res, req); +} + function emitFreeNT(socket) { socket.emit('free'); } diff --git a/test/parallel/test-http-client-keep-alive-release-before-finish.js b/test/parallel/test-http-client-keep-alive-release-before-finish.js new file mode 100644 index 00000000000000..374bacba3e5362 --- /dev/null +++ b/test/parallel/test-http-client-keep-alive-release-before-finish.js @@ -0,0 +1,38 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +const server = http.createServer((req, res) => { + res.end(); +}).listen(common.PORT, common.mustCall(() => { + const agent = new http.Agent({ + maxSockets: 1, + keepAlive: true + }); + + const post = http.request({ + agent: agent, + method: 'POST', + port: common.PORT, + }, common.mustCall((res) => { + res.resume(); + })); + + /* What happens here is that the server `end`s the response before we send + * `something`, and the client thought that this is a green light for sending + * next GET request + */ + post.write(Buffer.alloc(16 * 1024, 'X')); + setTimeout(() => { + post.end('something'); + }, 100); + + http.request({ + agent: agent, + method: 'GET', + port: common.PORT, + }, common.mustCall((res) => { + server.close(); + res.connection.end(); + })).end(); +})); From 042e858dfb487085d191179577565c69a5f46a44 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 27 May 2016 20:00:55 -0700 Subject: [PATCH 112/261] test: make test-child-process-fork-net more robust test-child-process-fork-net will sometimes fail in CI with EADDRINUSE because an earlier test failed to free common.PORT. Have the operating system provide an available port instead. PR-URL: https://github.com/nodejs/node/pull/7033 Reviewed-By: Brian White Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-child-process-fork-net.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index f815f76a664d9f..1b12e1e173b92a 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -1,6 +1,6 @@ 'use strict'; const assert = require('assert'); -const common = require('../common'); +require('../common'); const fork = require('child_process').fork; const net = require('net'); @@ -91,7 +91,7 @@ if (process.argv[2] === 'child') { console.log('PARENT: server listening'); child.send({what: 'server'}, server); }); - server.listen(common.PORT); + server.listen(0); // handle client messages var messageHandlers = function(msg) { @@ -100,7 +100,7 @@ if (process.argv[2] === 'child') { // make connections var socket; for (var i = 0; i < 4; i++) { - socket = net.connect(common.PORT, function() { + socket = net.connect(server.address().port, function() { console.log('CLIENT: connected'); }); socket.on('close', function() { @@ -143,9 +143,9 @@ if (process.argv[2] === 'child') { // // An isolated test for this would be lovely, but for now, this // will have to do. - server.listen(common.PORT + 1, function() { + server.listen(0, function() { console.error('testSocket, listening'); - var connect = net.connect(common.PORT + 1); + var connect = net.connect(server.address().port); var store = ''; connect.on('data', function(chunk) { store += chunk; From 8724c442f3d7870e244bd2b64c024ff5988eebd1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 31 May 2016 15:55:08 -0700 Subject: [PATCH 113/261] test: add test for uid/gid setting in spawn Remove a disabled test in favor of one that expects an error. This validates (somewhat) that the underlying code is calling the correct system call for setting UID and GID. Unlike the formerly disabled test, it does not try to validate that the system UID/GID setting works. PR-URL: https://github.com/nodejs/node/pull/7084 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- test/disabled/test-child-process-uid-gid.js | 60 --------------------- test/parallel/test-child-process-uid-gid.js | 14 +++++ 2 files changed, 14 insertions(+), 60 deletions(-) delete mode 100644 test/disabled/test-child-process-uid-gid.js create mode 100644 test/parallel/test-child-process-uid-gid.js diff --git a/test/disabled/test-child-process-uid-gid.js b/test/disabled/test-child-process-uid-gid.js deleted file mode 100644 index 90708bc2ca4016..00000000000000 --- a/test/disabled/test-child-process-uid-gid.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; -var fs = require('fs'); - -var myUid = process.getuid(); -var myGid = process.getgid(); - -if (myUid != 0) { - console.error('must be run as root, otherwise the gid/uid setting will' + - ' fail.'); - process.exit(1); -} - -// get a different user. -// don't care who it is, as long as it's not root -var passwd = fs.readFileSync('/etc/passwd', 'utf8'); -passwd = passwd.trim().split(/\n/); - -for (var i = 0, l = passwd.length; i < l; i++) { - if (passwd[i].charAt(0) === '#') continue; - passwd[i] = passwd[i].split(':'); - var otherName = passwd[i][0]; - var otherUid = +passwd[i][2]; - var otherGid = +passwd[i][3]; - if (otherUid && otherUid !== myUid && - otherGid && otherGid !== myGid && - otherUid > 0) { - break; - } -} -if (!otherUid && !otherGid) throw new Error('failed getting passwd info.'); - -console.error('name, id, gid = %j', [otherName, otherUid, otherGid]); - -var whoNumber = spawn('id', [], { uid: otherUid, gid: otherGid }); -var whoName = spawn('id', [], { uid: otherName, gid: otherGid }); - -whoNumber.stdout.buf = 'byNumber:'; -whoName.stdout.buf = 'byName:'; -whoNumber.stdout.on('data', onData); -whoName.stdout.on('data', onData); -function onData(c) { this.buf += c; } - -whoNumber.on('exit', onExit); -whoName.on('exit', onExit); - -function onExit(code) { - var buf = this.stdout.buf; - console.log(buf); - var expr = new RegExp('^(byName|byNumber):uid=' + - otherUid + - '\\(' + - otherName + - '\\) gid=' + - otherGid + - '\\('); - assert.ok(buf.match(expr), 'uid and gid should match ' + otherName); -} diff --git a/test/parallel/test-child-process-uid-gid.js b/test/parallel/test-child-process-uid-gid.js new file mode 100644 index 00000000000000..220cae633e112f --- /dev/null +++ b/test/parallel/test-child-process-uid-gid.js @@ -0,0 +1,14 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; + +const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/; + +assert.throws(() => { + spawn('echo', ['fhqwhgads'], {uid: 0}); +}, expectedError); + +assert.throws(() => { + spawn('echo', ['fhqwhgads'], {gid: 0}); +}, expectedError); From c9ef04a1b2650418aa9a1a367c9935bb74a6d0fb Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 17 Jun 2016 10:25:28 -0700 Subject: [PATCH 114/261] doc: fix events typo This commit removes an extraneous word. PR-URL: https://github.com/nodejs/node/pull/7329 Reviewed-By: Colin Ihrig Reviewed-By: Brian White --- doc/api/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/events.md b/doc/api/events.md index 464a0f61570113..6bbb2be9480609 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -430,7 +430,7 @@ added for a particular event. This is a useful default that helps finding memory leaks. Obviously, not all events should be limited to just 10 listeners. The `emitter.setMaxListeners()` method allows the limit to be modified for this specific `EventEmitter` instance. The value can be set to `Infinity` (or `0`) -for to indicate an unlimited number of listeners. +to indicate an unlimited number of listeners. Returns a reference to the `EventEmitter` so calls can be chained. From ef37a2e80f94cfc3266acbd5927176a9a6ff19f3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 12 Jun 2016 12:20:19 -0700 Subject: [PATCH 115/261] doc: add internal link in GOVERNANCE.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/7279 Reviewed-By: Rod Vagg Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Colin Ihrig --- GOVERNANCE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 2337353cb7b4f7..06cec91e7db8b6 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -46,7 +46,7 @@ responsibility for the change. In the case of pull requests proposed by an existing Collaborator, an additional Collaborator is required for sign-off. Consensus should be sought if additional Collaborators participate and there is disagreement around a particular -modification. See _Consensus Seeking Process_ below for further detail +modification. See [Consensus Seeking Process](#consensus-seeking-process) below for further detail on the consensus model used for governance. Collaborators may opt to elevate significant or controversial From 96ed883d2fcea73a843368fa19aede9ca5387df6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 3 Jun 2016 16:08:30 -0700 Subject: [PATCH 116/261] test: enable test-debug-brk-no-arg Fix issues with disabled test-debug-brk-no-arg and re-enable the test. PR-URL: https://github.com/nodejs/node/pull/7143 Reviewed-By: Fedor Indutny --- test/disabled/test-debug-brk-no-arg.js | 15 --------------- test/parallel/test-debug-brk-no-arg.js | 13 +++++++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 test/disabled/test-debug-brk-no-arg.js create mode 100644 test/parallel/test-debug-brk-no-arg.js diff --git a/test/disabled/test-debug-brk-no-arg.js b/test/disabled/test-debug-brk-no-arg.js deleted file mode 100644 index 7e678a76dfc8f8..00000000000000 --- a/test/disabled/test-debug-brk-no-arg.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; - -var child = spawn(process.execPath, ['--debug-brk=' + common.PORT]); -child.stderr.once('data', function(c) { - console.error('%j', c.toString()); - child.stdin.end(); -}); - -child.on('exit', function(c) { - assert(c === 0); - console.log('ok'); -}); diff --git a/test/parallel/test-debug-brk-no-arg.js b/test/parallel/test-debug-brk-no-arg.js new file mode 100644 index 00000000000000..e2ba80cd7700ef --- /dev/null +++ b/test/parallel/test-debug-brk-no-arg.js @@ -0,0 +1,13 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; + +const child = spawn(process.execPath, ['--debug-brk=' + common.PORT, '-i']); +child.stderr.once('data', common.mustCall(function() { + child.stdin.end('.exit'); +})); + +child.on('exit', common.mustCall(function(c) { + assert.strictEqual(c, 0); +})); From 65b5cccee90885dc468f67d08affa6cebd84234f Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 29 May 2016 12:21:02 -0400 Subject: [PATCH 117/261] test: fix spawn on windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most Windows systems do not have an external `echo` program installed, so any attempts to spawn `echo` as a child process will fail with `ENOENT`. This commit forces the use of the built-in `echo` provided by `cmd.exe`. PR-URL: https://github.com/nodejs/node/pull/7049 Reviewed-By: Colin Ihrig Reviewed-By: João Reis Reviewed-By: Anna Henningsen --- test/parallel/test-child-process-flush-stdio.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js index dacc1226f30d03..c2cae2069a8ce5 100644 --- a/test/parallel/test-child-process-flush-stdio.js +++ b/test/parallel/test-child-process-flush-stdio.js @@ -3,7 +3,11 @@ const cp = require('child_process'); const common = require('../common'); const assert = require('assert'); -const p = cp.spawn('echo'); +// Windows' `echo` command is a built-in shell command and not an external +// executable like on *nix +const opts = { shell: common.isWindows }; + +const p = cp.spawn('echo', [], opts); p.on('close', common.mustCall(function(code, signal) { assert.strictEqual(code, 0); @@ -15,7 +19,7 @@ p.stdout.read(); function spawnWithReadable() { const buffer = []; - const p = cp.spawn('echo', ['123']); + const p = cp.spawn('echo', ['123'], opts); p.on('close', common.mustCall(function(code, signal) { assert.strictEqual(code, 0); assert.strictEqual(signal, null); From 57ba51ec46d8f2e3efcd5b05f1cc6bed836d79aa Mon Sep 17 00:00:00 2001 From: Ilkka Myller Date: Wed, 8 Jun 2016 07:19:47 +0300 Subject: [PATCH 118/261] doc: fix IRC link PR-URL: https://github.com/nodejs/node/pull/7210 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Myles Borins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 847ffc886196d4..5098135b307444 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you need help using or installing Node.js, please use the * [Website](https://nodejs.org/en/) * [Contributing to the project](./CONTRIBUTING.md) * IRC (general questions): [#node.js on chat.freenode.net](https://webchat.freenode.net?channels=node.js&uio=d4) -* IRC (node core development): [#node-dev on chat.reenode.net](https://webchat.freenode.net?channels=node-dev&uio=d4) +* IRC (node core development): [#node-dev on chat.freenode.net](https://webchat.freenode.net?channels=node-dev&uio=d4) ## Release Types From 85f70b36e48fecc16201210d54a72b931ed78ed0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 7 Jun 2016 15:54:07 -0700 Subject: [PATCH 119/261] doc: clarify use of `0` port value Clarify that using a port value of `0` will result in the operating system identifying an available port for use. PR-URL: https://github.com/nodejs/node/pull/7206 Reviewed-By: James M Snell Reviewed-By: cjihrig - Colin Ihrig Reviewed-By: Anna Henningsen --- doc/api/http.md | 4 ++-- doc/api/net.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 888cfecca2e8a3..aba2d7e4041c8b 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -532,8 +532,8 @@ a listener for the `'listening'` event. See also [`net.Server.listen(path)`][]. Begin accepting connections on the specified `port` and `hostname`. If the `hostname` is omitted, the server will accept connections on any IPv6 address -(`::`) when IPv6 is available, or any IPv4 address (`0.0.0.0`) otherwise. A -port value of zero will assign a random port. +(`::`) when IPv6 is available, or any IPv4 address (`0.0.0.0`) otherwise. Use a +port value of zero to have the operating system assign an available port. To listen to a unix socket, supply a filename instead of port and hostname. diff --git a/doc/api/net.md b/doc/api/net.md index a140c4b5d95493..4cd003daecd53e 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -178,8 +178,8 @@ The parameter `backlog` behaves the same as in Begin accepting connections on the specified `port` and `hostname`. If the `hostname` is omitted, the server will accept connections on any IPv6 address -(`::`) when IPv6 is available, or any IPv4 address (`0.0.0.0`) otherwise. A -port value of zero will assign a random port. +(`::`) when IPv6 is available, or any IPv4 address (`0.0.0.0`) otherwise. Use a +port value of `0` to have the operating system assign an available port. Backlog is the maximum length of the queue of pending connections. The actual length will be determined by the OS through sysctl settings such as From 4a7e333287bdc7a9f0f82333e609982d8dfe4082 Mon Sep 17 00:00:00 2001 From: kimown Date: Sun, 12 Jun 2016 12:44:25 +0800 Subject: [PATCH 120/261] doc: use `Buffer.byteLength` for Content-Length As the description in http.md: > If the body contains higher coded characters then Buffer.byteLength() should be used to determine the number of bytes in a given encoding. PR-URL: https://github.com/nodejs/node/pull/7274 Reviewed-By: Brian White Reviewed-By: Anna Henningsen Reviewed-By: Jackson Tian --- doc/api/http.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index aba2d7e4041c8b..b06886f09d2738 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -809,7 +809,7 @@ Example: ```js var body = 'hello world'; response.writeHead(200, { - 'Content-Length': body.length, + 'Content-Length': Buffer.byteLength(body), 'Content-Type': 'text/plain' }); ``` @@ -1119,7 +1119,7 @@ var options = { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', - 'Content-Length': postData.length + 'Content-Length': Buffer.byteLength(postData) } }; From 7182f5f87616c08c30b5724227da389308ce8d48 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 2 Jun 2016 17:14:37 -0700 Subject: [PATCH 121/261] tools: fix license builder to work with icu-small Currently the license builder is expecting the ICU package to be found at `deps/icu`. ICU is now included by default and found at `deps/icu-small`. This commit adds logic to find the license at the new location. This could likely be done in a more elegant way, but it works! PR-URL: https://github.com/nodejs/node/pull/7119 Reviewed-By: James M Snell Reviewed-By: Steven R Loomis --- tools/license-builder.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 3d587227b41ae4..eb3980e7d027cd 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -22,7 +22,7 @@ $(echo -e "$3" | sed -e 's/^/ /' -e 's/^ $//' -e 's/ *$//' | sed -e '/./,$ } -if ! [ -d "${rootdir}/deps/icu/" ]; then +if ! [ -d "${rootdir}/deps/icu/" ] && ! [ -d "${rootdir}/deps/icu-small/" ]; then echo "ICU not installed, run configure to download it, e.g. ./configure --with-intl=small-icu --download=icu" exit 1 fi @@ -42,6 +42,16 @@ elif [ -f "${rootdir}/deps/icu/license.html" ]; then addlicense "ICU" "deps/icu" \ "$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a \ -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/]*>//g;s/ / /g;s/ +$//;/ Date: Thu, 9 Jun 2016 11:07:21 -0700 Subject: [PATCH 122/261] benchmark: add benchmark for url.format() PR-URL: https://github.com/nodejs/node/pull/7250 Reviewed-By: Brian White --- benchmark/url/url-format.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 benchmark/url/url-format.js diff --git a/benchmark/url/url-format.js b/benchmark/url/url-format.js new file mode 100644 index 00000000000000..3f7df8a0bc4536 --- /dev/null +++ b/benchmark/url/url-format.js @@ -0,0 +1,33 @@ +'use strict'; +const common = require('../common.js'); +const url = require('url'); +const v8 = require('v8'); + +const bench = common.createBenchmark(main, { + type: 'one two'.split(' '), + n: [25e6] +}); + +function main(conf) { + const type = conf.type; + const n = conf.n | 0; + + const inputs = { + one: {slashes: true, host: 'localhost'}, + two: {protocol: 'file:', pathname: '/foo'}, + }; + const input = inputs[type] || ''; + + // Force-optimize url.format() so that the benchmark doesn't get + // disrupted by the optimizer kicking in halfway through. + for (const name in inputs) + url.format(inputs[name]); + + v8.setFlagsFromString('--allow_natives_syntax'); + eval('%OptimizeFunctionOnNextCall(url.format)'); + + bench.start(); + for (var i = 0; i < n; i += 1) + url.format(input); + bench.end(n); +} From 79b45886c155fd1c7af526509b168df9157257e1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 10 Jun 2016 09:27:15 +0200 Subject: [PATCH 123/261] test: add tests for some stream.Readable uses * test: check invalid chunk error for readable.push Test that passing invalid chunks to readable.push() in non-object mode throw errors. * test: add simple object mode + decoder stream test * test: add test for readable stream lacking _read Check that using a readable stream without a _read method will throw an error. * test: add basic test for piping to multiple dests Add a simple test for piping and unpiping from a readable stream to multiple writable streams. PR-URL: https://github.com/nodejs/node/pull/7260 Reviewed-By: Matteo Collina --- .../test-stream-decoder-objectmode.js | 19 +++++++ .../test-stream-pipe-multiple-pipes.js | 51 +++++++++++++++++++ .../test-stream-readable-invalid-chunk.js | 12 +++++ ...tream-readable-with-unimplemented-_read.js | 8 +++ 4 files changed, 90 insertions(+) create mode 100644 test/parallel/test-stream-decoder-objectmode.js create mode 100644 test/parallel/test-stream-pipe-multiple-pipes.js create mode 100644 test/parallel/test-stream-readable-invalid-chunk.js create mode 100644 test/parallel/test-stream-readable-with-unimplemented-_read.js diff --git a/test/parallel/test-stream-decoder-objectmode.js b/test/parallel/test-stream-decoder-objectmode.js new file mode 100644 index 00000000000000..d6b0784430d137 --- /dev/null +++ b/test/parallel/test-stream-decoder-objectmode.js @@ -0,0 +1,19 @@ +'use strict'; +require('../common'); +const stream = require('stream'); +const assert = require('assert'); + +const readable = new stream.Readable({ + read: () => {}, + encoding: 'utf16le', + objectMode: true +}); + +readable.push(Buffer.from('abc', 'utf16le')); +readable.push(Buffer.from('def', 'utf16le')); +readable.push(null); + +// Without object mode, these would be concatenated into a single chunk. +assert.strictEqual(readable.read(), 'abc'); +assert.strictEqual(readable.read(), 'def'); +assert.strictEqual(readable.read(), null); diff --git a/test/parallel/test-stream-pipe-multiple-pipes.js b/test/parallel/test-stream-pipe-multiple-pipes.js new file mode 100644 index 00000000000000..fb2e9f4a54e94f --- /dev/null +++ b/test/parallel/test-stream-pipe-multiple-pipes.js @@ -0,0 +1,51 @@ +'use strict'; +const common = require('../common'); +const stream = require('stream'); +const assert = require('assert'); + +const readable = new stream.Readable({ + read: () => {} +}); + +const writables = []; + +for (let i = 0; i < 5; i++) { + const target = new stream.Writable({ + write: common.mustCall((chunk, encoding, callback) => { + target.output.push(chunk); + callback(); + }, 1) + }); + target.output = []; + + target.on('pipe', common.mustCall(() => {})); + readable.pipe(target); + + + writables.push(target); +} + +const input = Buffer.from([1, 2, 3, 4, 5]); + +readable.push(input); + +// The pipe() calls will postpone emission of the 'resume' event using nextTick, +// so no data will be available to the writable streams until then. +process.nextTick(common.mustCall(() => { + for (const target of writables) { + assert.deepStrictEqual(target.output, [input]); + + target.on('unpipe', common.mustCall(() => {})); + readable.unpipe(target); + } + + readable.push('something else'); // This does not get through. + readable.push(null); + readable.resume(); // Make sure the 'end' event gets emitted. +})); + +readable.on('end', common.mustCall(() => { + for (const target of writables) { + assert.deepStrictEqual(target.output, [input]); + } +})); diff --git a/test/parallel/test-stream-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js new file mode 100644 index 00000000000000..d845b6114c5f94 --- /dev/null +++ b/test/parallel/test-stream-readable-invalid-chunk.js @@ -0,0 +1,12 @@ +'use strict'; +require('../common'); +const stream = require('stream'); +const assert = require('assert'); + +const readable = new stream.Readable({ + read: () => {} +}); + +assert.throws(() => readable.push([]), /Invalid non-string\/buffer chunk/); +assert.throws(() => readable.push({}), /Invalid non-string\/buffer chunk/); +assert.throws(() => readable.push(0), /Invalid non-string\/buffer chunk/); diff --git a/test/parallel/test-stream-readable-with-unimplemented-_read.js b/test/parallel/test-stream-readable-with-unimplemented-_read.js new file mode 100644 index 00000000000000..ce325c0823e29c --- /dev/null +++ b/test/parallel/test-stream-readable-with-unimplemented-_read.js @@ -0,0 +1,8 @@ +'use strict'; +require('../common'); +const stream = require('stream'); +const assert = require('assert'); + +const readable = new stream.Readable(); + +assert.throws(() => readable.read(), /not implemented/); From 3be5cdcd439c5c4f96fc88e8a7c37402a4f36d48 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 4 Jun 2016 11:24:14 -0700 Subject: [PATCH 124/261] debugger: remove obsolete setTimeout Remove obsolete `setTimeout()` introduced in 3148f1400. The fix for the problem is in b266074347. (For the record, I mostly don't know what I'm talking about here but am summarizing from an IRC #node-dev conversation with @indutny on 04-Jun-2016.) PR-URL: https://github.com/nodejs/node/pull/7154 Reviewed-By: Fedor Indutny Reviewed-By: Colin Ihrig --- lib/_debugger.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index a5d3f6e87262c5..6d1043dda9d9d3 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -825,13 +825,7 @@ function Interface(stdin, stdout, args) { // Run script automatically this.pause(); - // XXX Need to figure out why we need this delay - setTimeout(function() { - - self.run(function() { - self.resume(); - }); - }, 10); + setImmediate(() => { this.run(); }); } From f8fe4748256e854ec49597d22c19db2048d7ab41 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 29 Jun 2016 20:38:40 +0200 Subject: [PATCH 125/261] doc: fixing minor typo in AtExit hooks section PR-URL: https://github.com/nodejs/node/pull/7485 Reviewed-By: Brian White Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- doc/api/addons.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index c330217beffa4d..9650329b0a5604 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -1003,7 +1003,7 @@ console.log(result); // 30 ### AtExit hooks An "AtExit" hook is a function that is invoked after the Node.js event loop -has ended by before the JavaScript VM is terminated and Node.js shuts down. +has ended but before the JavaScript VM is terminated and Node.js shuts down. "AtExit" hooks are registered using the `node::AtExit` API. #### void AtExit(callback, args) From 5129f3f2cddd0f47b72236ffe4b000134341b049 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 21 Jun 2016 22:41:39 -0700 Subject: [PATCH 126/261] test: mark test-vm-timeout flaky on windows PR-URL: https://github.com/nodejs/node/pull/7359 Refs: https://github.com/nodejs/node/issues/6727 Reviewed-By: Brian White Reviewed-By: Joao Reis Reviewed-By: Santiago Gimeno --- test/parallel/parallel.status | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 2cdc5b7b07cb64..16556cb20c3fcf 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -7,7 +7,8 @@ prefix parallel [true] # This section applies to all platforms [$system==win32] -test-tick-processor : PASS,FLAKY +test-tick-processor : PASS,FLAKY +test-vm-timeout : PASS,FLAKY [$system==linux] test-tick-processor : PASS,FLAKY From 868af29f2b09db80dad9db5568064447fb10bc4b Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Wed, 22 Jun 2016 18:31:02 +0100 Subject: [PATCH 127/261] doc: add RReverser to collaborators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-By: Rich Trott Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Myles Borins PR-URL: https://github.com/nodejs/node/pull/7370 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5098135b307444..50e84e0e7fc37c 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ information about the governance of the Node.js project, see * [robertkowalski](https://github.com/robertkowalski) - **Robert Kowalski** <rok@kowalski.gd> * [romankl](https://github.com/romankl) - **Roman Klauke** <romaaan.git@gmail.com> * [ronkorving](https://github.com/ronkorving) - **Ron Korving** <ron@ronkorving.nl> +* [RReverser](https://github.com/RReverser) - **Ingvar Stepanyan** <me@rreverser.com> * [saghul](https://github.com/saghul) - **Saúl Ibarra Corretgé** <saghul@gmail.com> * [sam-github](https://github.com/sam-github) - **Sam Roberts** <vieuxtech@gmail.com> * [santigimeno](https://github.com/santigimeno) - **Santiago Gimeno** <santiago.gimeno@gmail.com> From ccb278d330826def6a4c26e150da3875d27f2775 Mon Sep 17 00:00:00 2001 From: "Kyle E. Mitchell" Date: Fri, 10 Jun 2016 15:41:36 -0700 Subject: [PATCH 128/261] doc: mention http request "aborted" events Fixes: https://github.com/nodejs/node/issues/6925 PR-URL: https://github.com/nodejs/node/pull/7270 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- doc/api/http.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index b06886f09d2738..b7a9c1960f9f1c 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -207,6 +207,13 @@ The request implements the [Writable Stream][] interface. This is an Emitted when the request has been aborted by the client. This event is only emitted on the first call to `abort()`. +### Event: 'aborted' + +`function () { }` + +Emitted when the request has been aborted by the server and the network +socket has closed. + ### Event: 'connect' `function (response, socket, head) { }` @@ -853,6 +860,13 @@ headers and data. It implements the [Readable Stream][] interface, as well as the following additional events, methods, and properties. +### Event: 'aborted' + +`function () { }` + +Emitted when the request has been aborted by the client and the network +socket has closed. + ### Event: 'close' `function () { }` From 9122b3b665c7cc544f8f89956d9e80b9735cccd5 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 11 May 2016 12:38:04 -0400 Subject: [PATCH 129/261] doc: update "who to cc in issues" chart Refs: https://github.com/nodejs/node/issues/6655 PR-URL: https://github.com/nodejs/node/pull/6694 Reviewed-By: Myles Borins Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Ingvar Stepanyan --- doc/onboarding-extras.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index 55db6107350951..be9b48b449e565 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -2,23 +2,30 @@ | subsystem | maintainers | | --- | --- | -| `lib/buffer` | @trevnorris | -| `lib/child_process` | @cjihrig, @bnoordhuis | -| `lib/cluster` | @cjihrig, @bnoordhuis | +| `lib/assert` | @nodejs/testing | +| `lib/buffer` | @nodejs/buffer | +| `lib/child_process` | @bnoordhuis, @cjihrig | +| `lib/cluster` | @bnoordhuis, @cjihrig, @mcollina | | `lib/{crypto,tls,https}` | @nodejs/crypto | | `lib/domains` | @misterdjules | -| `lib/{_}http{*}` | @indutny, @bnoordhuis, @mscdex, @nodejs/http | -| `lib/net` | @indutny, @bnoordhuis, @nodejs/streams | +| `lib/fs`, `src/{fs|file}` | @nodejs/fs | +| `lib/{_}http{*}` | @nodejs/http | +| `lib/net` | @bnoordhuis, @indutny, @nodejs/streams | | `lib/{_}stream{s|*}` | @nodejs/streams | -| `lib/repl` | @fishrock123 | +| `lib/repl` | @addaleax, @fishrock123 | | `lib/timers` | @fishrock123, @misterdjules | -| `lib/zlib` | @indutny, @bnoordhuis | +| `lib/util` | @bnoordhuis, @cjihrig, @evanlucas | +| `lib/zlib` | @addaleax, @bnoordhuis, @indutny | +| `bootstrap_node.js` | @fishrock123 | | `src/async-wrap.*` | @trevnorris | | `src/node_crypto.*` | @nodejs/crypto | | `test/*` | @nodejs/testing | | `tools/eslint`, `.eslintrc` | @silverwind, @trott | -| upgrading v8 | @bnoordhuis, @targos, @ofrobots | -| upgrading npm | @thealphanerd, @fishrock123 | +| upgrading V8 | @nodejs/v8, @nodejs/post-mortem | +| upgrading npm | @fishrock123, @thealphanerd | +| upgrading c-ares | @jbergstroem | +| upgrading http-parser | @jbergstroem, @nodejs/http | +| upgrading libuv | @saghul | When things need extra attention, are controversial, or `semver-major`: @nodejs/ctc From 13d60cab7cf4e7c97a470f8bace58eacc88a0843 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Fri, 24 Jun 2016 13:04:31 -0400 Subject: [PATCH 130/261] doc: add lance to collaborators Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig PR-URL: https://github.com/nodejs/node/pull/7407 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 50e84e0e7fc37c..baceb16d7fe4c9 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,7 @@ information about the governance of the Node.js project, see * [joaocgreis](https://github.com/joaocgreis) - **João Reis** <reis@janeasystems.com> * [julianduque](https://github.com/julianduque) - **Julian Duque** <julianduquej@gmail.com> * [JungMinu](https://github.com/JungMinu) - **Minwoo Jung** <jmwsoft@gmail.com> +* [lance](https://github.com/lance) - **Lance Ball** <lball@redhat.com> * [lxe](https://github.com/lxe) - **Aleksey Smolenchuk** <lxe@lxe.co> * [matthewloring](https://github.com/matthewloring) - **Matthew Loring** <mattloring@google.com> * [mcollina](https://github.com/mcollina) - **Matteo Collina** <matteo.collina@gmail.com> From 71ef71cff89e3879524d8b77985fafb75a094404 Mon Sep 17 00:00:00 2001 From: Josh Gavant Date: Thu, 16 Jun 2016 08:37:11 -0700 Subject: [PATCH 131/261] doc: add CTC meeting minutes 2016-06-15 PR-URL: https://github.com/nodejs/node/pull/7320 Reviewed-By: Rich Trott Reviewed-By: Rod Vagg --- doc/ctc-meetings/2016-06-15.md | 174 +++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 doc/ctc-meetings/2016-06-15.md diff --git a/doc/ctc-meetings/2016-06-15.md b/doc/ctc-meetings/2016-06-15.md new file mode 100644 index 00000000000000..87fc0dc243d3a2 --- /dev/null +++ b/doc/ctc-meetings/2016-06-15.md @@ -0,0 +1,174 @@ +# Node Foundation CTC Meeting 2016-06-15 + +## Links + +* **Audio Recording**: https://www.youtube.com/watch?v=qWX8i9SKatQ +* **GitHub Issue**: https://github.com/nodejs/node/issues/7307 +* **Minutes Google Doc**: +* _Previous Minutes Google Doc: _ + +## Present + +* Bradley Meck @bmeck (observer/GoDaddy) +* Сковорода Никита Андреевич @ChALkeR (CTC) +* Chris Dickinson @chrisdickinson (CTC) +* Evan Lucas @evanlucas (CTC) +* Jeremiah Senkpiel @Fishrock123 (CTC) +* John-David Dalton @jdalton (observer/Microsoft) +* Josh Gavant @joshgav (observer/Microsoft) +* Michael Dawson @mhdawson (CTC) +* Brian White @mscdex (CTC) +* Ali Ijaz Sheikh @ofrobots (CTC) +* Alexis Campailla @orangemocha (CTC) +* Rod Vagg @rvagg (CTC) +* Rich Trott @Trott (CTC) +* Trevor Norris @trevnorris (CTC) + +## Agenda + +Extracted from **ctc-agenda** labelled issues and pull requests from the **nodejs org** prior to the meeting. + +### nodejs/node + +* url: return valid file: urls fom url.format() [#7234](https://github.com/nodejs/node/pull/7234) +* http: don't inherit from Object.prototype [#6102](https://github.com/nodejs/node/pull/6102) + +### Standup + +* Bradley Meck @bmeck + * fleshing out a proposal for if we could disambiguate the grammars for Script and Module. + +* Сковорода Никита Андреевич @ChALkeR (CTC) + * some issue/PRs reviews + +* Chris Dickinson @chrisdickinson (CTC) + * NodeConf + * modules.guide + +* Evan Lucas @evanlucas (CTC) + * Preparing for security release + +* Jeremiah Senkpiel @Fishrock123 (CTC) + * (Previous week: fixed the primary OS X stdio bug) + * NodeConf + +* Fedor Indutny @indutny (CTC) + * fixing bugs, reviewing PRs, working on llnode + +* Josh Gavant @joshgav + * debug protocol stuff + +* Michael Dawson @mhdawson (CTC) + * Still chasing PPC machine issues + * AIX/malloc(0) issue + * ABI stable module API work with Stefan/Ian, filling in Nan examples + * Input on some benchmarking related PRs + * Other misc reviews/lands + * Keeping up with issues + +* Brian White @mscdex (CTC) + * Landed some old PRs + * Submitting PRs to fix some regressions + * Reviewed PRs and issues + +* Ali Ijaz Sheikh @ofrobots (CTC) + * More work on v8_inspector + * Starting to look at backporting some V8 fixes for LTS + +* Alexis Campailla @orangemocha (CTC) + * Landed a fix for node-gyp, broke with VS update 3 + +* Rod Vagg @rvagg (CTC) + * Alpine Linux in CI + * Security release hoo haa + * Reviews & discussions + * Electron / Node relationship + * New CTC repo + * Jenkins upkeep + +* Rich Trott @Trott (CTC) + * Setting up the next onboarding + * Facilitated a session on releases at NodeConf. Will share notes with Build WG, LTS WG, and people who can sign releases. + +* Trevor Norris @trevnorris (CTC) + * Finished updating AsyncWrap EP and now investigating proposed implementation. + * Helping identify old issue in Atom editor in regards to writing to disk. + + +### Review of last meeting +* Tracking issue: stdio problems [#6980](https://github.com/nodejs/node/issues/6980) +* module: expose `Module._runInThisContext` [#6288](https://github.com/nodejs/node/pull/6288) + + +## Minutes + + +### url: return valid file: urls from url.format() [#7234](https://github.com/nodejs/node/pull/7234) + +@trott: semver-major change, needs approval from CTC. +Real fix will be @jasnell’s HTTP compliance work. + +In browsers `file:/home/joshgav/myfile.txt` is auto-corrected to `file:///home/joshgav/myfile.txt` (i.e. slashes are prepended to the path and hostname is an empty string). This change institutes the same in Node.js. + +Are there other protocols which require additional slashes (`//`) if hostname isn’t specified? Yes, but hard to heuristically determine if needed. + + +### http: don't inherit from Object.prototype [#6102](https://github.com/nodejs/node/pull/6102) + +Replace headers object ({}) in req/res with StorageObject, which doesn’t delegate to Object.prototype. But this will break anyone using regular `Object` methods on header props. + +@trevnorris: Why don’t we intercept calls to properties with checks to an internal dictionary of actual headers? If the key isn’t there, then try to call Object.prototype. + +How would that effect perf? + +It’s the right decision because otherwise can’t use headers with certain names like `__proto__`. + +Better to do a deprecation cycle. How? Insert something (proxy) between actual call to property, would issue deprecation warning first. This would be temporary, eventually this interceptor/proxy would go away. + + +### ES6 Modules [node-eps/002-es6-modules.md](https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md) + +Need to disambiguate ES6 modules and regular scripts (which include CJS modules). Cannot determine if file is module, script, etc. from code itself. For this reason Node decided to use `.mjs` extension for ES6 modules. + +New proposal: If `import` or `export` keywords are in module code, then use module goal. So no need for extra metadata or file extension. But would have to parse file to check for presence of these keywords. + +https://github.com/bmeck/UnambiguousJavaScriptGrammar +replaces https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md#51-determining-if-source-is-an-es-module + +This would be part of ECMA262 so browsers would do the same, but needs to be ironed out in TC39. On [agenda][TC39 Agenda] for 7/26 TC39 meeting. + +[TC39 Agenda]: https://github.com/tc39/agendas/blob/master/2016/07.md + +What if nothing is imported or exported? Could do `export default null` to export nothing. + +Starting off, preferred goal when preparing code would be CommonJS/script, later on could change to ES6/module. + +Caching is more feasible. + +Provides more seamless flow from CJS to ES6 in the future. + +Will packaging tools need to implement parsing logic too to package properly? Yes, but there are possibilities listed in the repo. + +What other differences between scripts and modules? +- `await` keyword only in modules according to ECMA262 +- `modules.root` in package.json is intended to allow mirrored directory structure for use with ES6; but technically all it does is redirect file system calls and it could be used for other purposes, so it’s not reliable. + +Purpose of modules.root - allows redirection within a module, e.g. `module/file.js` doesn’t necessarily resolve to `./file.js` within the directory, could be redirected to `${module.root}/file.js`. This allows side-by-side CJS and ES6 among other things. + +What about for human reading? How can people differentiate at a glance between CJS and ES6? +- `import`’s are generally at the top, `export`s at the bottom. If you see `import` it’s an ES6 module. + +How are browsers dealing with this? Older browsers which encounter ` - - - -``` +If not using `xregexp-all.js`, first include the Unicode Base script and then one or more of the addons for Unicode blocks, categories, properties, or scripts. Then you can do this: @@ -118,14 +120,7 @@ XRegExp uses Unicode 8.0.0. ### XRegExp.build -In browsers, first include the script: - -```html - - -``` - -You can then build regular expressions using named subpatterns, for readability and pattern reuse: +Build regular expressions using named subpatterns, for readability and pattern reuse: ```js var time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', { @@ -146,14 +141,7 @@ See also: *[Creating Grammatical Regexes Using XRegExp.build](http://blog.steven ### XRegExp.matchRecursive -In browsers, first include the script: - -```html - - -``` - -You can then match recursive constructs using XRegExp pattern strings as left and right delimiters: +Match recursive constructs using XRegExp pattern strings as left and right delimiters: ```js var str = '(t((e))s)t()(ing)'; @@ -196,13 +184,7 @@ XRegExp.matchRecursive(str, '<', '>', 'gy'); ## Installation and usage -In browsers: - -```html - -``` - -Or, to bundle XRegExp with all of its addons: +In browsers (bundle XRegExp with all of its addons): ```html @@ -232,12 +214,8 @@ require({paths: {xregexp: 'xregexp-all'}}, ['xregexp'], function(XRegExp) { XRegExp copyright 2007-2016 by [Steven Levithan](http://stevenlevithan.com/). -Tools: Unicode range generators by [Mathias Bynens](http://mathiasbynens.be/), and adapted from his [unicode-data](https://github.com/mathiasbynens/unicode-data) project. - -Tests: Uses [Jasmine](http://jasmine.github.io/) for unit tests, and [Benchmark.js](http://benchmarkjs.com) for performance tests. - -Prior art: `XRegExp.build` inspired by [Lea Verou](http://lea.verou.me/)'s [RegExp.create](http://lea.verou.me/2011/03/create-complex-regexps-more-easily/). `XRegExp.union` inspired by [Ruby](http://www.ruby-lang.org/). XRegExp's syntax extensions and flags come from [Perl](http://www.perl.org/), [.NET](http://www.microsoft.com/net), etc. +Unicode range generators by [Mathias Bynens](http://mathiasbynens.be/), and adapted from his [unicode-data](https://github.com/mathiasbynens/unicode-data) project. Uses [Jasmine](http://jasmine.github.io/) for unit tests, and [Benchmark.js](http://benchmarkjs.com) for performance tests. `XRegExp.build` inspired by [RegExp.create](http://lea.verou.me/2011/03/create-complex-regexps-more-easily/) by [Lea Verou](http://lea.verou.me/). `XRegExp.union` inspired by [Ruby](http://www.ruby-lang.org/). XRegExp's syntax extensions and flags come from [Perl](http://www.perl.org/), [.NET](http://www.microsoft.com/net), etc. -All code, including addons, tools, and tests, is released under the terms of the [MIT](http://mit-license.org/) license. +All code, including addons, tools, and tests, is released under the terms of the [MIT License](http://mit-license.org/). Fork me to show support, fix, and extend. diff --git a/tools/eslint/node_modules/xregexp/package.json b/tools/eslint/node_modules/xregexp/package.json index 76cb517195c525..8fe0d7f5027066 100644 --- a/tools/eslint/node_modules/xregexp/package.json +++ b/tools/eslint/node_modules/xregexp/package.json @@ -6,14 +6,14 @@ ] ], "_from": "xregexp@>=3.0.0 <4.0.0", - "_id": "xregexp@3.1.0", + "_id": "xregexp@3.1.1", "_inCache": true, "_installable": true, "_location": "/xregexp", "_nodeVersion": "3.3.1", "_npmOperationalInternal": { - "host": "packages-9-west.internal.npmjs.com", - "tmp": "tmp/xregexp-3.1.0.tgz_1456271836601_0.7557942552957684" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/xregexp-3.1.1.tgz_1463265906533_0.49629145418293774" }, "_npmUser": { "email": "steves_list@hotmail.com", @@ -32,8 +32,8 @@ "_requiredBy": [ "/table" ], - "_resolved": "https://registry.npmjs.org/xregexp/-/xregexp-3.1.0.tgz", - "_shasum": "14d8461e0bdd38224bfee5039a0898fc42fcd336", + "_resolved": "https://registry.npmjs.org/xregexp/-/xregexp-3.1.1.tgz", + "_shasum": "8ee18d75ef5c7cb3f9967f8d29414a6ca5b1a184", "_shrinkwrap": null, "_spec": "xregexp@^3.0.0", "_where": "/Users/trott/io.js/tools/node_modules/table", @@ -51,17 +51,19 @@ }, "directories": {}, "dist": { - "shasum": "14d8461e0bdd38224bfee5039a0898fc42fcd336", - "tarball": "https://registry.npmjs.org/xregexp/-/xregexp-3.1.0.tgz" + "shasum": "8ee18d75ef5c7cb3f9967f8d29414a6ca5b1a184", + "tarball": "https://registry.npmjs.org/xregexp/-/xregexp-3.1.1.tgz" }, "files": [ "src" ], - "gitHead": "bbd5b1c2f759bdf278192be5df70af16342ffa4d", + "gitHead": "37413619ea9f03638bfa92e038e4b4c15645d446", "homepage": "http://xregexp.com/", "keywords": [ "regex", - "regexp" + "regexp", + "regular expression", + "unicode" ], "license": "MIT", "main": "./src/index.js", @@ -81,5 +83,5 @@ "scripts": { "build": "browserify src/index.js --standalone XRegExp > xregexp-all.js" }, - "version": "3.1.0" + "version": "3.1.1" } diff --git a/tools/eslint/node_modules/xregexp/src/addons/build.js b/tools/eslint/node_modules/xregexp/src/addons/build.js index 221cb26fa940cf..843d4a9c962612 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/build.js +++ b/tools/eslint/node_modules/xregexp/src/addons/build.js @@ -1,5 +1,5 @@ /*! - * XRegExp.build 3.1.0 + * XRegExp.build 3.1.1 * * Steven Levithan (c) 2012-2016 MIT License * Inspired by Lea Verou's RegExp.create @@ -8,17 +8,16 @@ module.exports = function(XRegExp) { 'use strict'; - var REGEX_DATA = 'xregexp', - subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*]/g, - parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g'); + var REGEX_DATA = 'xregexp'; + var subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*]/g; + var parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g'); -/** - * Strips a leading `^` and trailing unescaped `$`, if both are present. - * - * @private - * @param {String} pattern Pattern to process. - * @returns {String} Pattern with edge anchors removed. - */ + /** + * Strips a leading `^` and trailing unescaped `$`, if both are present. + * + * @param {String} pattern Pattern to process. + * @returns {String} Pattern with edge anchors removed. + */ function deanchor(pattern) { // Allow any number of empty noncapturing groups before/after anchors, because regexes // built/generated by XRegExp sometimes include them @@ -37,13 +36,12 @@ module.exports = function(XRegExp) { return pattern; } -/** - * Converts the provided value to an XRegExp. Native RegExp flags are not preserved. - * - * @private - * @param {String|RegExp} value Value to convert. - * @returns {RegExp} XRegExp object with XRegExp syntax applied. - */ + /** + * Converts the provided value to an XRegExp. Native RegExp flags are not preserved. + * + * @param {String|RegExp} value Value to convert. + * @returns {RegExp} XRegExp object with XRegExp syntax applied. + */ function asXRegExp(value) { return XRegExp.isRegExp(value) ? (value[REGEX_DATA] && value[REGEX_DATA].captureNames ? @@ -56,31 +54,30 @@ module.exports = function(XRegExp) { XRegExp(value); } -/** - * Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in the - * outer pattern and provided subpatterns are automatically renumbered to work correctly. Native - * flags used by provided subpatterns are ignored in favor of the `flags` argument. - * - * @memberOf XRegExp - * @param {String} pattern XRegExp pattern using `{{name}}` for embedded subpatterns. Allows - * `({{name}})` as shorthand for `(?{{name}})`. Patterns cannot be embedded within - * character classes. - * @param {Object} subs Lookup object for named subpatterns. Values can be strings or regexes. A - * leading `^` and trailing unescaped `$` are stripped from subpatterns, if both are present. - * @param {String} [flags] Any combination of XRegExp flags. - * @returns {RegExp} Regex with interpolated subpatterns. - * @example - * - * var time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', { - * hours: XRegExp.build('{{h12}} : | {{h24}}', { - * h12: /1[0-2]|0?[1-9]/, - * h24: /2[0-3]|[01][0-9]/ - * }, 'x'), - * minutes: /^[0-5][0-9]$/ - * }); - * time.test('10:59'); // -> true - * XRegExp.exec('10:59', time).minutes; // -> '59' - */ + /** + * Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in + * the outer pattern and provided subpatterns are automatically renumbered to work correctly. + * Native flags used by provided subpatterns are ignored in favor of the `flags` argument. + * + * @param {String} pattern XRegExp pattern using `{{name}}` for embedded subpatterns. Allows + * `({{name}})` as shorthand for `(?{{name}})`. Patterns cannot be embedded within + * character classes. + * @param {Object} subs Lookup object for named subpatterns. Values can be strings or regexes. A + * leading `^` and trailing unescaped `$` are stripped from subpatterns, if both are present. + * @param {String} [flags] Any combination of XRegExp flags. + * @returns {RegExp} Regex with interpolated subpatterns. + * @example + * + * var time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', { + * hours: XRegExp.build('{{h12}} : | {{h24}}', { + * h12: /1[0-2]|0?[1-9]/, + * h24: /2[0-3]|[01][0-9]/ + * }, 'x'), + * minutes: /^[0-5][0-9]$/ + * }); + * time.test('10:59'); // -> true + * XRegExp.exec('10:59', time).minutes; // -> '59' + */ XRegExp.build = function(pattern, subs, flags) { var inlineFlags = /^\(\?([\w$]+)\)/.exec(pattern), data = {}, diff --git a/tools/eslint/node_modules/xregexp/src/addons/matchrecursive.js b/tools/eslint/node_modules/xregexp/src/addons/matchrecursive.js index 1de3bdc5579cea..6a51b56b732614 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/matchrecursive.js +++ b/tools/eslint/node_modules/xregexp/src/addons/matchrecursive.js @@ -1,5 +1,5 @@ /*! - * XRegExp.matchRecursive 3.1.0 + * XRegExp.matchRecursive 3.1.1 * * Steven Levithan (c) 2009-2016 MIT License */ @@ -7,11 +7,9 @@ module.exports = function(XRegExp) { 'use strict'; -/** - * Returns a match detail object composed of the provided values. - * - * @private - */ + /** + * Returns a match detail object composed of the provided values. + */ function row(name, value, start, end) { return { name: name, @@ -21,56 +19,55 @@ module.exports = function(XRegExp) { }; } -/** - * Returns an array of match strings between outermost left and right delimiters, or an array of - * objects with detailed match parts and position data. An error is thrown if delimiters are - * unbalanced within the data. - * - * @memberOf XRegExp - * @param {String} str String to search. - * @param {String} left Left delimiter as an XRegExp pattern. - * @param {String} right Right delimiter as an XRegExp pattern. - * @param {String} [flags] Any native or XRegExp flags, used for the left and right delimiters. - * @param {Object} [options] Lets you specify `valueNames` and `escapeChar` options. - * @returns {Array} Array of matches, or an empty array. - * @example - * - * // Basic usage - * var str = '(t((e))s)t()(ing)'; - * XRegExp.matchRecursive(str, '\\(', '\\)', 'g'); - * // -> ['t((e))s', '', 'ing'] - * - * // Extended information mode with valueNames - * str = 'Here is
an
example'; - * XRegExp.matchRecursive(str, '', '', 'gi', { - * valueNames: ['between', 'left', 'match', 'right'] - * }); - * // -> [ - * // {name: 'between', value: 'Here is ', start: 0, end: 8}, - * // {name: 'left', value: '
', start: 8, end: 13}, - * // {name: 'match', value: '
an
', start: 13, end: 27}, - * // {name: 'right', value: '
', start: 27, end: 33}, - * // {name: 'between', value: ' example', start: 33, end: 41} - * // ] - * - * // Omitting unneeded parts with null valueNames, and using escapeChar - * str = '...{1}.\\{{function(x,y){return {y:x}}}'; - * XRegExp.matchRecursive(str, '{', '}', 'g', { - * valueNames: ['literal', null, 'value', null], - * escapeChar: '\\' - * }); - * // -> [ - * // {name: 'literal', value: '...', start: 0, end: 3}, - * // {name: 'value', value: '1', start: 4, end: 5}, - * // {name: 'literal', value: '.\\{', start: 6, end: 9}, - * // {name: 'value', value: 'function(x,y){return {y:x}}', start: 10, end: 37} - * // ] - * - * // Sticky mode via flag y - * str = '<1><<<2>>><3>4<5>'; - * XRegExp.matchRecursive(str, '<', '>', 'gy'); - * // -> ['1', '<<2>>', '3'] - */ + /** + * Returns an array of match strings between outermost left and right delimiters, or an array of + * objects with detailed match parts and position data. An error is thrown if delimiters are + * unbalanced within the data. + * + * @param {String} str String to search. + * @param {String} left Left delimiter as an XRegExp pattern. + * @param {String} right Right delimiter as an XRegExp pattern. + * @param {String} [flags] Any native or XRegExp flags, used for the left and right delimiters. + * @param {Object} [options] Lets you specify `valueNames` and `escapeChar` options. + * @returns {Array} Array of matches, or an empty array. + * @example + * + * // Basic usage + * var str = '(t((e))s)t()(ing)'; + * XRegExp.matchRecursive(str, '\\(', '\\)', 'g'); + * // -> ['t((e))s', '', 'ing'] + * + * // Extended information mode with valueNames + * str = 'Here is
an
example'; + * XRegExp.matchRecursive(str, '', '', 'gi', { + * valueNames: ['between', 'left', 'match', 'right'] + * }); + * // -> [ + * // {name: 'between', value: 'Here is ', start: 0, end: 8}, + * // {name: 'left', value: '
', start: 8, end: 13}, + * // {name: 'match', value: '
an
', start: 13, end: 27}, + * // {name: 'right', value: '
', start: 27, end: 33}, + * // {name: 'between', value: ' example', start: 33, end: 41} + * // ] + * + * // Omitting unneeded parts with null valueNames, and using escapeChar + * str = '...{1}.\\{{function(x,y){return {y:x}}}'; + * XRegExp.matchRecursive(str, '{', '}', 'g', { + * valueNames: ['literal', null, 'value', null], + * escapeChar: '\\' + * }); + * // -> [ + * // {name: 'literal', value: '...', start: 0, end: 3}, + * // {name: 'value', value: '1', start: 4, end: 5}, + * // {name: 'literal', value: '.\\{', start: 6, end: 9}, + * // {name: 'value', value: 'function(x,y){return {y:x}}', start: 10, end: 37} + * // ] + * + * // Sticky mode via flag y + * str = '<1><<<2>>><3>4<5>'; + * XRegExp.matchRecursive(str, '<', '>', 'gy'); + * // -> ['1', '<<2>>', '3'] + */ XRegExp.matchRecursive = function(str, left, right, flags, options) { flags = flags || ''; options = options || {}; diff --git a/tools/eslint/node_modules/xregexp/src/addons/unicode-base.js b/tools/eslint/node_modules/xregexp/src/addons/unicode-base.js index 2a323041b60e3e..011a384405e149 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/unicode-base.js +++ b/tools/eslint/node_modules/xregexp/src/addons/unicode-base.js @@ -1,56 +1,44 @@ /*! - * XRegExp Unicode Base 3.1.0 + * XRegExp Unicode Base 3.1.1 * * Steven Levithan (c) 2008-2016 MIT License */ -/** - * Adds base support for Unicode matching: - * - Adds syntax `\p{..}` for matching Unicode tokens. Tokens can be inverted using `\P{..}` or - * `\p{^..}`. Token names ignore case, spaces, hyphens, and underscores. You can omit the braces - * for token names that are a single letter (e.g. `\pL` or `PL`). - * - Adds flag A (astral), which enables 21-bit Unicode support. - * - Adds the `XRegExp.addUnicodeData` method used by other addons to provide character data. - * - * Unicode Base relies on externally provided Unicode character data. Official addons are available - * to provide data for Unicode categories, scripts, blocks, and properties. - * - * @requires XRegExp - */ module.exports = function(XRegExp) { 'use strict'; -// Storage for Unicode data + /** + * Adds base support for Unicode matching: + * - Adds syntax `\p{..}` for matching Unicode tokens. Tokens can be inverted using `\P{..}` or + * `\p{^..}`. Token names ignore case, spaces, hyphens, and underscores. You can omit the + * braces for token names that are a single letter (e.g. `\pL` or `PL`). + * - Adds flag A (astral), which enables 21-bit Unicode support. + * - Adds the `XRegExp.addUnicodeData` method used by other addons to provide character data. + * + * Unicode Base relies on externally provided Unicode character data. Official addons are + * available to provide data for Unicode categories, scripts, blocks, and properties. + * + * @requires XRegExp + */ + + // ==--------------------------== + // Private stuff + // ==--------------------------== + + // Storage for Unicode data var unicode = {}; -/* ============================== - * Private functions - * ============================== */ + // Reuse utils + var dec = XRegExp._dec; + var hex = XRegExp._hex; + var pad4 = XRegExp._pad4; -// Generates a token lookup name: lowercase, with hyphens, spaces, and underscores removed + // Generates a token lookup name: lowercase, with hyphens, spaces, and underscores removed function normalize(name) { return name.replace(/[- _]+/g, '').toLowerCase(); } -// Adds leading zeros if shorter than four characters - function pad4(str) { - while (str.length < 4) { - str = '0' + str; - } - return str; - } - -// Converts a hexadecimal number to decimal - function dec(hex) { - return parseInt(hex, 16); - } - -// Converts a decimal number to hexadecimal - function hex(dec) { - return parseInt(dec, 10).toString(16); - } - -// Gets the decimal code of a literal code unit, \xHH, \uHHHH, or a backslash-escaped literal + // Gets the decimal code of a literal code unit, \xHH, \uHHHH, or a backslash-escaped literal function charCode(chr) { var esc = /^\\[xu](.+)/.exec(chr); return esc ? @@ -58,21 +46,24 @@ module.exports = function(XRegExp) { chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0); } -// Inverts a list of ordered BMP characters and ranges + // Inverts a list of ordered BMP characters and ranges function invertBmp(range) { - var output = '', - lastEnd = -1, - start; - XRegExp.forEach(range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function(m) { - start = charCode(m[1]); - if (start > (lastEnd + 1)) { - output += '\\u' + pad4(hex(lastEnd + 1)); - if (start > (lastEnd + 2)) { - output += '-\\u' + pad4(hex(start - 1)); + var output = ''; + var lastEnd = -1; + XRegExp.forEach( + range, + /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, + function(m) { + var start = charCode(m[1]); + if (start > (lastEnd + 1)) { + output += '\\u' + pad4(hex(lastEnd + 1)); + if (start > (lastEnd + 2)) { + output += '-\\u' + pad4(hex(start - 1)); + } } + lastEnd = charCode(m[2] || m[1]); } - lastEnd = charCode(m[2] || m[1]); - }); + ); if (lastEnd < 0xFFFF) { output += '\\u' + pad4(hex(lastEnd + 1)); if (lastEnd < 0xFFFE) { @@ -82,7 +73,7 @@ module.exports = function(XRegExp) { return output; } -// Generates an inverted BMP range on first use + // Generates an inverted BMP range on first use function cacheInvertedBmp(slug) { var prop = 'b!'; return unicode[slug][prop] || ( @@ -90,7 +81,7 @@ module.exports = function(XRegExp) { ); } -// Combines and optionally negates BMP and astral data + // Combines and optionally negates BMP and astral data function buildAstral(slug, isNegated) { var item = unicode[slug], combined = ''; @@ -109,7 +100,7 @@ module.exports = function(XRegExp) { '(?:' + combined + ')'; } -// Builds a complete astral pattern on first use + // Builds a complete astral pattern on first use function cacheAstral(slug, isNegated) { var prop = isNegated ? 'a!' : 'a='; return unicode[slug][prop] || ( @@ -117,13 +108,13 @@ module.exports = function(XRegExp) { ); } -/* ============================== - * Core functionality - * ============================== */ + // ==--------------------------== + // Core functionality + // ==--------------------------== -/* - * Add Unicode token syntax: \p{..}, \P{..}, \p{^..}. Also add astral mode (flag A). - */ + /* + * Add Unicode token syntax: \p{..}, \P{..}, \p{^..}. Also add astral mode (flag A). + */ XRegExp.addToken( // Use `*` instead of `+` to avoid capturing `^` as the token name in `\p{^}` /\\([pP])(?:{(\^?)([^}]*)}|([A-Za-z]))/, @@ -181,33 +172,33 @@ module.exports = function(XRegExp) { } ); -/** - * Adds to the list of Unicode tokens that XRegExp regexes can match via `\p` or `\P`. - * - * @memberOf XRegExp - * @param {Array} data Objects with named character ranges. Each object may have properties `name`, - * `alias`, `isBmpLast`, `inverseOf`, `bmp`, and `astral`. All but `name` are optional, although - * one of `bmp` or `astral` is required (unless `inverseOf` is set). If `astral` is absent, the - * `bmp` data is used for BMP and astral modes. If `bmp` is absent, the name errors in BMP mode - * but works in astral mode. If both `bmp` and `astral` are provided, the `bmp` data only is used - * in BMP mode, and the combination of `bmp` and `astral` data is used in astral mode. - * `isBmpLast` is needed when a token matches orphan high surrogates *and* uses surrogate pairs - * to match astral code points. The `bmp` and `astral` data should be a combination of literal - * characters and `\xHH` or `\uHHHH` escape sequences, with hyphens to create ranges. Any regex - * metacharacters in the data should be escaped, apart from range-creating hyphens. The `astral` - * data can additionally use character classes and alternation, and should use surrogate pairs to - * represent astral code points. `inverseOf` can be used to avoid duplicating character data if a - * Unicode token is defined as the exact inverse of another token. - * @example - * - * // Basic use - * XRegExp.addUnicodeData([{ - * name: 'XDigit', - * alias: 'Hexadecimal', - * bmp: '0-9A-Fa-f' - * }]); - * XRegExp('\\p{XDigit}:\\p{Hexadecimal}+').test('0:3D'); // -> true - */ + /** + * Adds to the list of Unicode tokens that XRegExp regexes can match via `\p` or `\P`. + * + * @param {Array} data Objects with named character ranges. Each object may have properties + * `name`, `alias`, `isBmpLast`, `inverseOf`, `bmp`, and `astral`. All but `name` are + * optional, although one of `bmp` or `astral` is required (unless `inverseOf` is set). If + * `astral` is absent, the `bmp` data is used for BMP and astral modes. If `bmp` is absent, + * the name errors in BMP mode but works in astral mode. If both `bmp` and `astral` are + * provided, the `bmp` data only is used in BMP mode, and the combination of `bmp` and + * `astral` data is used in astral mode. `isBmpLast` is needed when a token matches orphan + * high surrogates *and* uses surrogate pairs to match astral code points. The `bmp` and + * `astral` data should be a combination of literal characters and `\xHH` or `\uHHHH` escape + * sequences, with hyphens to create ranges. Any regex metacharacters in the data should be + * escaped, apart from range-creating hyphens. The `astral` data can additionally use + * character classes and alternation, and should use surrogate pairs to represent astral code + * points. `inverseOf` can be used to avoid duplicating character data if a Unicode token is + * defined as the exact inverse of another token. + * @example + * + * // Basic use + * XRegExp.addUnicodeData([{ + * name: 'XDigit', + * alias: 'Hexadecimal', + * bmp: '0-9A-Fa-f' + * }]); + * XRegExp('\\p{XDigit}:\\p{Hexadecimal}+').test('0:3D'); // -> true + */ XRegExp.addUnicodeData = function(data) { var ERR_NO_NAME = 'Unicode token requires name', ERR_NO_DATA = 'Unicode token has no character data ', diff --git a/tools/eslint/node_modules/xregexp/src/addons/unicode-blocks.js b/tools/eslint/node_modules/xregexp/src/addons/unicode-blocks.js index 918dc9d5c45742..97cc71fbb1a6d8 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/unicode-blocks.js +++ b/tools/eslint/node_modules/xregexp/src/addons/unicode-blocks.js @@ -1,21 +1,23 @@ /*! - * XRegExp Unicode Blocks 3.1.0 + * XRegExp Unicode Blocks 3.1.1 * * Steven Levithan (c) 2010-2016 MIT License * Unicode data by Mathias Bynens */ -/** - * Adds support for all Unicode blocks. Block names use the prefix 'In'. E.g., `\p{InBasicLatin}`. - * Token names are case insensitive, and any spaces, hyphens, and underscores are ignored. - * - * Uses Unicode 8.0.0. - * - * @requires XRegExp, Unicode Base - */ module.exports = function(XRegExp) { 'use strict'; + /** + * Adds support for all Unicode blocks. Block names use the prefix 'In'. E.g., + * `\p{InBasicLatin}`. Token names are case insensitive, and any spaces, hyphens, and + * underscores are ignored. + * + * Uses Unicode 8.0.0. + * + * @requires XRegExp, Unicode Base + */ + if (!XRegExp.addUnicodeData) { throw new ReferenceError('Unicode Base must be loaded before Unicode Blocks'); } diff --git a/tools/eslint/node_modules/xregexp/src/addons/unicode-categories.js b/tools/eslint/node_modules/xregexp/src/addons/unicode-categories.js index 6da732f505abcc..4e201cb95c5050 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/unicode-categories.js +++ b/tools/eslint/node_modules/xregexp/src/addons/unicode-categories.js @@ -1,22 +1,23 @@ /*! - * XRegExp Unicode Categories 3.1.0 + * XRegExp Unicode Categories 3.1.1 * * Steven Levithan (c) 2010-2016 MIT License * Unicode data by Mathias Bynens */ -/** - * Adds support for Unicode's general categories. E.g., `\p{Lu}` or `\p{Uppercase Letter}`. See - * category descriptions in UAX #44 . Token names - * are case insensitive, and any spaces, hyphens, and underscores are ignored. - * - * Uses Unicode 8.0.0. - * - * @requires XRegExp, Unicode Base - */ module.exports = function(XRegExp) { 'use strict'; + /** + * Adds support for Unicode's general categories. E.g., `\p{Lu}` or `\p{Uppercase Letter}`. See + * category descriptions in UAX #44 . Token + * names are case insensitive, and any spaces, hyphens, and underscores are ignored. + * + * Uses Unicode 8.0.0. + * + * @requires XRegExp, Unicode Base + */ + if (!XRegExp.addUnicodeData) { throw new ReferenceError('Unicode Base must be loaded before Unicode Categories'); } diff --git a/tools/eslint/node_modules/xregexp/src/addons/unicode-properties.js b/tools/eslint/node_modules/xregexp/src/addons/unicode-properties.js index 92a041b4f85839..725a77050ea781 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/unicode-properties.js +++ b/tools/eslint/node_modules/xregexp/src/addons/unicode-properties.js @@ -1,51 +1,52 @@ /*! - * XRegExp Unicode Properties 3.1.0 + * XRegExp Unicode Properties 3.1.1 * * Steven Levithan (c) 2012-2016 MIT License * Unicode data by Mathias Bynens */ -/** - * Adds properties to meet the UTS #18 Level 1 RL1.2 requirements for Unicode regex support. See - * . Following are definitions of these properties from UAX - * #44 : - * - * - Alphabetic - * Characters with the Alphabetic property. Generated from: Lowercase + Uppercase + Lt + Lm + Lo + - * Nl + Other_Alphabetic. - * - * - Default_Ignorable_Code_Point - * For programmatic determination of default ignorable code points. New characters that should be - * ignored in rendering (unless explicitly supported) will be assigned in these ranges, permitting - * programs to correctly handle the default rendering of such characters when not otherwise - * supported. - * - * - Lowercase - * Characters with the Lowercase property. Generated from: Ll + Other_Lowercase. - * - * - Noncharacter_Code_Point - * Code points permanently reserved for internal use. - * - * - Uppercase - * Characters with the Uppercase property. Generated from: Lu + Other_Uppercase. - * - * - White_Space - * Spaces, separator characters and other control characters which should be treated by - * programming languages as "white space" for the purpose of parsing elements. - * - * The properties ASCII, Any, and Assigned are also included but are not defined in UAX #44. UTS #18 - * RL1.2 additionally requires support for Unicode scripts and general categories. These are - * included in XRegExp's Unicode Categories and Unicode Scripts addons. - * - * Token names are case insensitive, and any spaces, hyphens, and underscores are ignored. - * - * Uses Unicode 8.0.0. - * - * @requires XRegExp, Unicode Base - */ module.exports = function(XRegExp) { 'use strict'; + /** + * Adds properties to meet the UTS #18 Level 1 RL1.2 requirements for Unicode regex support. See + * . Following are definitions of these properties from + * UAX #44 : + * + * - Alphabetic + * Characters with the Alphabetic property. Generated from: Lowercase + Uppercase + Lt + Lm + + * Lo + Nl + Other_Alphabetic. + * + * - Default_Ignorable_Code_Point + * For programmatic determination of default ignorable code points. New characters that should + * be ignored in rendering (unless explicitly supported) will be assigned in these ranges, + * permitting programs to correctly handle the default rendering of such characters when not + * otherwise supported. + * + * - Lowercase + * Characters with the Lowercase property. Generated from: Ll + Other_Lowercase. + * + * - Noncharacter_Code_Point + * Code points permanently reserved for internal use. + * + * - Uppercase + * Characters with the Uppercase property. Generated from: Lu + Other_Uppercase. + * + * - White_Space + * Spaces, separator characters and other control characters which should be treated by + * programming languages as "white space" for the purpose of parsing elements. + * + * The properties ASCII, Any, and Assigned are also included but are not defined in UAX #44. UTS + * #18 RL1.2 additionally requires support for Unicode scripts and general categories. These are + * included in XRegExp's Unicode Categories and Unicode Scripts addons. + * + * Token names are case insensitive, and any spaces, hyphens, and underscores are ignored. + * + * Uses Unicode 8.0.0. + * + * @requires XRegExp, Unicode Base + */ + if (!XRegExp.addUnicodeData) { throw new ReferenceError('Unicode Base must be loaded before Unicode Properties'); } diff --git a/tools/eslint/node_modules/xregexp/src/addons/unicode-scripts.js b/tools/eslint/node_modules/xregexp/src/addons/unicode-scripts.js index bb28ec36a09b31..06983d6a821baf 100644 --- a/tools/eslint/node_modules/xregexp/src/addons/unicode-scripts.js +++ b/tools/eslint/node_modules/xregexp/src/addons/unicode-scripts.js @@ -1,21 +1,22 @@ /*! - * XRegExp Unicode Scripts 3.1.0 + * XRegExp Unicode Scripts 3.1.1 * * Steven Levithan (c) 2010-2016 MIT License * Unicode data by Mathias Bynens */ -/** - * Adds support for all Unicode scripts. E.g., `\p{Latin}`. Token names are case insensitive, and - * any spaces, hyphens, and underscores are ignored. - * - * Uses Unicode 8.0.0. - * - * @requires XRegExp, Unicode Base - */ module.exports = function(XRegExp) { 'use strict'; + /** + * Adds support for all Unicode scripts. E.g., `\p{Latin}`. Token names are case insensitive, + * and any spaces, hyphens, and underscores are ignored. + * + * Uses Unicode 8.0.0. + * + * @requires XRegExp, Unicode Base + */ + if (!XRegExp.addUnicodeData) { throw new ReferenceError('Unicode Base must be loaded before Unicode Scripts'); } diff --git a/tools/eslint/node_modules/xregexp/src/xregexp.js b/tools/eslint/node_modules/xregexp/src/xregexp.js index 91c60b640660f6..4cedd851778466 100644 --- a/tools/eslint/node_modules/xregexp/src/xregexp.js +++ b/tools/eslint/node_modules/xregexp/src/xregexp.js @@ -1,9 +1,11 @@ /*! - * XRegExp 3.1.0 + * XRegExp 3.1.1 * * Steven Levithan (c) 2007-2016 MIT License */ +'use strict'; + /** * XRegExp provides augmented, extensible regular expressions. You get additional regex syntax and * flags, beyond what browsers support natively. XRegExp is also a regex utility belt with tools to @@ -11,85 +13,87 @@ * cross-browser inconsistencies. */ - 'use strict'; - -/* ============================== - * Private stuff - * ============================== */ - - // Property name used for extended regex instance data - var REGEX_DATA = 'xregexp'; - // Optional features that can be installed and uninstalled - var features = { - astral: false, - natives: false - }; - // Native methods to use and restore ('native' is an ES3 reserved keyword) - var nativ = { - exec: RegExp.prototype.exec, - test: RegExp.prototype.test, - match: String.prototype.match, - replace: String.prototype.replace, - split: String.prototype.split - }; - // Storage for fixed/extended native methods - var fixed = {}; - // Storage for regexes cached by `XRegExp.cache` - var regexCache = {}; - // Storage for pattern details cached by the `XRegExp` constructor - var patternCache = {}; - // Storage for regex syntax tokens added internally or by `XRegExp.addToken` - var tokens = []; - // Token scopes - var defaultScope = 'default'; - var classScope = 'class'; - // Regexes that match native regex syntax, including octals - var nativeTokens = { - // Any native multicharacter token in default scope, or any single character - 'default': /\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/, - // Any native multicharacter token in character class scope, or any single character - 'class': /\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/ - }; - // Any backreference or dollar-prefixed character in replacement strings - var replacementToken = /\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g; - // Check for correct `exec` handling of nonparticipating capturing groups - var correctExecNpcg = nativ.exec.call(/()??/, '')[1] === undefined; - // Check for ES6 `flags` prop support - var hasFlagsProp = /x/.flags !== undefined; - // Shortcut to `Object.prototype.toString` - var toString = {}.toString; - - function hasNativeFlag(flag) { - // Can't check based on the presense of properties/getters since - // browsers might support such properties even when don't support the - // corresponding flag in regex construction (tested in Chrome 48, where - // `'unicode' in /x/` is true but trying to construct a regex with flag - // `u` throws an error). - var isSupported = true; - try { - new RegExp('', flag); - } catch (exception) { - isSupported = false; - } - return isSupported; +// ==--------------------------== +// Private stuff +// ==--------------------------== + +// Property name used for extended regex instance data +var REGEX_DATA = 'xregexp'; +// Optional features that can be installed and uninstalled +var features = { + astral: false, + natives: false +}; +// Native methods to use and restore ('native' is an ES3 reserved keyword) +var nativ = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split +}; +// Storage for fixed/extended native methods +var fixed = {}; +// Storage for regexes cached by `XRegExp.cache` +var regexCache = {}; +// Storage for pattern details cached by the `XRegExp` constructor +var patternCache = {}; +// Storage for regex syntax tokens added internally or by `XRegExp.addToken` +var tokens = []; +// Token scopes +var defaultScope = 'default'; +var classScope = 'class'; +// Regexes that match native regex syntax, including octals +var nativeTokens = { + // Any native multicharacter token in default scope, or any single character + 'default': /\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/, + // Any native multicharacter token in character class scope, or any single character + 'class': /\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/ +}; +// Any backreference or dollar-prefixed character in replacement strings +var replacementToken = /\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g; +// Check for correct `exec` handling of nonparticipating capturing groups +var correctExecNpcg = nativ.exec.call(/()??/, '')[1] === undefined; +// Check for ES6 `flags` prop support +var hasFlagsProp = /x/.flags !== undefined; +// Shortcut to `Object.prototype.toString` +var toString = {}.toString; + +function hasNativeFlag(flag) { + // Can't check based on the presense of properties/getters since browsers might support such + // properties even when they don't support the corresponding flag in regex construction (tested + // in Chrome 48, where `'unicode' in /x/` is true but trying to construct a regex with flag `u` + // throws an error) + var isSupported = true; + try { + // Can't use regex literals for testing even in a `try` because regex literals with + // unsupported flags cause a compilation error in IE + new RegExp('', flag); + } catch (exception) { + isSupported = false; } - // Check for ES6 `u` flag support - var hasNativeU = hasNativeFlag('u'); - // Check for ES6 `y` flag support - var hasNativeY = hasNativeFlag('y'); - // Tracker for known flags, including addon flags - var registeredFlags = { - g: true, - i: true, - m: true, - u: hasNativeU, - y: hasNativeY - }; + if (isSupported && flag === 'y') { + // Work around Safari 9.1.1 bug + return new RegExp('aa|.', 'y').test('b'); + } + return isSupported; +} +// Check for ES6 `u` flag support +var hasNativeU = hasNativeFlag('u'); +// Check for ES6 `y` flag support +var hasNativeY = hasNativeFlag('y'); +// Tracker for known flags, including addon flags +var registeredFlags = { + g: true, + i: true, + m: true, + u: hasNativeU, + y: hasNativeY +}; /** * Attaches extended data and `XRegExp.prototype` properties to a regex object. * - * @private * @param {RegExp} regex Regex to augment. * @param {Array} captureNames Array with capture names, or `null`. * @param {String} xSource XRegExp pattern used to generate `regex`, or `null` if N/A. @@ -99,53 +103,51 @@ * skipping some operations like attaching `XRegExp.prototype` properties. * @returns {RegExp} Augmented regex. */ - function augment(regex, captureNames, xSource, xFlags, isInternalOnly) { - var p; +function augment(regex, captureNames, xSource, xFlags, isInternalOnly) { + var p; - regex[REGEX_DATA] = { - captureNames: captureNames - }; + regex[REGEX_DATA] = { + captureNames: captureNames + }; - if (isInternalOnly) { - return regex; - } + if (isInternalOnly) { + return regex; + } - // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value - if (regex.__proto__) { - regex.__proto__ = XRegExp.prototype; - } else { - for (p in XRegExp.prototype) { - // An `XRegExp.prototype.hasOwnProperty(p)` check wouldn't be worth it here, since - // this is performance sensitive, and enumerable `Object.prototype` or - // `RegExp.prototype` extensions exist on `regex.prototype` anyway - regex[p] = XRegExp.prototype[p]; - } + // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value + if (regex.__proto__) { + regex.__proto__ = XRegExp.prototype; + } else { + for (p in XRegExp.prototype) { + // An `XRegExp.prototype.hasOwnProperty(p)` check wouldn't be worth it here, since this + // is performance sensitive, and enumerable `Object.prototype` or `RegExp.prototype` + // extensions exist on `regex.prototype` anyway + regex[p] = XRegExp.prototype[p]; } + } - regex[REGEX_DATA].source = xSource; - // Emulate the ES6 `flags` prop by ensuring flags are in alphabetical order - regex[REGEX_DATA].flags = xFlags ? xFlags.split('').sort().join('') : xFlags; + regex[REGEX_DATA].source = xSource; + // Emulate the ES6 `flags` prop by ensuring flags are in alphabetical order + regex[REGEX_DATA].flags = xFlags ? xFlags.split('').sort().join('') : xFlags; - return regex; - } + return regex; +} /** * Removes any duplicate characters from the provided string. * - * @private * @param {String} str String to remove duplicate characters from. * @returns {String} String with any duplicate characters removed. */ - function clipDuplicates(str) { - return nativ.replace.call(str, /([\s\S])(?=[\s\S]*\1)/g, ''); - } +function clipDuplicates(str) { + return nativ.replace.call(str, /([\s\S])(?=[\s\S]*\1)/g, ''); +} /** * Copies a regex object while preserving extended data and augmenting with `XRegExp.prototype` * properties. The copy has a fresh `lastIndex` property (set to zero). Allows adding and removing * flags g and y while copying the regex. * - * @private * @param {RegExp} regex Regex to copy. * @param {Object} [options] Options object with optional properties: *
  • `addG` {Boolean} Add flag g while copying the regex. @@ -157,256 +159,243 @@ * skipping some operations like attaching `XRegExp.prototype` properties. * @returns {RegExp} Copy of the provided regex, possibly with modified flags. */ - function copyRegex(regex, options) { - if (!XRegExp.isRegExp(regex)) { - throw new TypeError('Type RegExp expected'); - } +function copyRegex(regex, options) { + if (!XRegExp.isRegExp(regex)) { + throw new TypeError('Type RegExp expected'); + } - var xData = regex[REGEX_DATA] || {}, - flags = getNativeFlags(regex), - flagsToAdd = '', - flagsToRemove = '', - xregexpSource = null, - xregexpFlags = null; + var xData = regex[REGEX_DATA] || {}, + flags = getNativeFlags(regex), + flagsToAdd = '', + flagsToRemove = '', + xregexpSource = null, + xregexpFlags = null; - options = options || {}; + options = options || {}; - if (options.removeG) {flagsToRemove += 'g';} - if (options.removeY) {flagsToRemove += 'y';} - if (flagsToRemove) { - flags = nativ.replace.call(flags, new RegExp('[' + flagsToRemove + ']+', 'g'), ''); - } + if (options.removeG) {flagsToRemove += 'g';} + if (options.removeY) {flagsToRemove += 'y';} + if (flagsToRemove) { + flags = nativ.replace.call(flags, new RegExp('[' + flagsToRemove + ']+', 'g'), ''); + } - if (options.addG) {flagsToAdd += 'g';} - if (options.addY) {flagsToAdd += 'y';} - if (flagsToAdd) { - flags = clipDuplicates(flags + flagsToAdd); - } + if (options.addG) {flagsToAdd += 'g';} + if (options.addY) {flagsToAdd += 'y';} + if (flagsToAdd) { + flags = clipDuplicates(flags + flagsToAdd); + } - if (!options.isInternalOnly) { - if (xData.source !== undefined) { - xregexpSource = xData.source; - } - // null or undefined; don't want to add to `flags` if the previous value was null, since - // that indicates we're not tracking original precompilation flags - if (xData.flags != null) { - // Flags are only added for non-internal regexes by `XRegExp.globalize`. Flags are - // never removed for non-internal regexes, so don't need to handle it - xregexpFlags = flagsToAdd ? clipDuplicates(xData.flags + flagsToAdd) : xData.flags; - } + if (!options.isInternalOnly) { + if (xData.source !== undefined) { + xregexpSource = xData.source; + } + // null or undefined; don't want to add to `flags` if the previous value was null, since + // that indicates we're not tracking original precompilation flags + if (xData.flags != null) { + // Flags are only added for non-internal regexes by `XRegExp.globalize`. Flags are never + // removed for non-internal regexes, so don't need to handle it + xregexpFlags = flagsToAdd ? clipDuplicates(xData.flags + flagsToAdd) : xData.flags; } + } - // Augment with `XRegExp.prototype` properties, but use the native `RegExp` constructor to - // avoid searching for special tokens. That would be wrong for regexes constructed by - // `RegExp`, and unnecessary for regexes constructed by `XRegExp` because the regex has - // already undergone the translation to native regex syntax - regex = augment( - new RegExp(regex.source, flags), - hasNamedCapture(regex) ? xData.captureNames.slice(0) : null, - xregexpSource, - xregexpFlags, - options.isInternalOnly - ); + // Augment with `XRegExp.prototype` properties, but use the native `RegExp` constructor to avoid + // searching for special tokens. That would be wrong for regexes constructed by `RegExp`, and + // unnecessary for regexes constructed by `XRegExp` because the regex has already undergone the + // translation to native regex syntax + regex = augment( + new RegExp(regex.source, flags), + hasNamedCapture(regex) ? xData.captureNames.slice(0) : null, + xregexpSource, + xregexpFlags, + options.isInternalOnly + ); - return regex; - } + return regex; +} /** * Converts hexadecimal to decimal. * - * @private * @param {String} hex * @returns {Number} */ - function dec(hex) { - return parseInt(hex, 16); - } +function dec(hex) { + return parseInt(hex, 16); +} /** * Returns native `RegExp` flags used by a regex object. * - * @private * @param {RegExp} regex Regex to check. * @returns {String} Native flags in use. */ - function getNativeFlags(regex) { - return hasFlagsProp ? - regex.flags : - // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or - // concatenation with an empty string) allows this to continue working predictably when - // `XRegExp.proptotype.toString` is overriden - nativ.exec.call(/\/([a-z]*)$/i, RegExp.prototype.toString.call(regex))[1]; - } +function getNativeFlags(regex) { + return hasFlagsProp ? + regex.flags : + // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation + // with an empty string) allows this to continue working predictably when + // `XRegExp.proptotype.toString` is overriden + nativ.exec.call(/\/([a-z]*)$/i, RegExp.prototype.toString.call(regex))[1]; +} /** * Determines whether a regex has extended instance data used to track capture names. * - * @private * @param {RegExp} regex Regex to check. * @returns {Boolean} Whether the regex uses named capture. */ - function hasNamedCapture(regex) { - return !!(regex[REGEX_DATA] && regex[REGEX_DATA].captureNames); - } +function hasNamedCapture(regex) { + return !!(regex[REGEX_DATA] && regex[REGEX_DATA].captureNames); +} /** * Converts decimal to hexadecimal. * - * @private * @param {Number|String} dec * @returns {String} */ - function hex(dec) { - return parseInt(dec, 10).toString(16); - } +function hex(dec) { + return parseInt(dec, 10).toString(16); +} /** * Returns the first index at which a given value can be found in an array. * - * @private * @param {Array} array Array to search. * @param {*} value Value to locate in the array. * @returns {Number} Zero-based index at which the item is found, or -1. */ - function indexOf(array, value) { - var len = array.length, i; +function indexOf(array, value) { + var len = array.length, i; - for (i = 0; i < len; ++i) { - if (array[i] === value) { - return i; - } + for (i = 0; i < len; ++i) { + if (array[i] === value) { + return i; } - - return -1; } + return -1; +} + /** * Determines whether a value is of the specified type, by resolving its internal [[Class]]. * - * @private * @param {*} value Object to check. * @param {String} type Type to check for, in TitleCase. * @returns {Boolean} Whether the object matches the type. */ - function isType(value, type) { - return toString.call(value) === '[object ' + type + ']'; - } +function isType(value, type) { + return toString.call(value) === '[object ' + type + ']'; +} /** * Checks whether the next nonignorable token after the specified position is a quantifier. * - * @private * @param {String} pattern Pattern to search within. * @param {Number} pos Index in `pattern` to search at. * @param {String} flags Flags used by the pattern. * @returns {Boolean} Whether the next token is a quantifier. */ - function isQuantifierNext(pattern, pos, flags) { - return nativ.test.call( - flags.indexOf('x') > -1 ? - // Ignore any leading whitespace, line comments, and inline comments - /^(?:\s+|#.*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/ : - // Ignore any leading inline comments - /^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/, - pattern.slice(pos) - ); - } +function isQuantifierNext(pattern, pos, flags) { + return nativ.test.call( + flags.indexOf('x') > -1 ? + // Ignore any leading whitespace, line comments, and inline comments + /^(?:\s|#[^#\n]*|\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/ : + // Ignore any leading inline comments + /^(?:\(\?#[^)]*\))*(?:[?*+]|{\d+(?:,\d*)?})/, + pattern.slice(pos) + ); +} /** - * Pads the provided string with as many leading zeros as needed to get to length 4. Used to produce - * fixed-length hexadecimal values. + * Adds leading zeros if shorter than four characters. Used for fixed-length hexadecimal values. * - * @private * @param {String} str * @returns {String} */ - function pad4(str) { - while (str.length < 4) { - str = '0' + str; - } - return str; +function pad4(str) { + while (str.length < 4) { + str = '0' + str; } + return str; +} /** * Checks for flag-related errors, and strips/applies flags in a leading mode modifier. Offloads * the flag preparation logic from the `XRegExp` constructor. * - * @private * @param {String} pattern Regex pattern, possibly with a leading mode modifier. * @param {String} flags Any combination of flags. * @returns {Object} Object with properties `pattern` and `flags`. */ - function prepareFlags(pattern, flags) { - var i; - - // Recent browsers throw on duplicate flags, so copy this behavior for nonnative flags - if (clipDuplicates(flags) !== flags) { - throw new SyntaxError('Invalid duplicate regex flag ' + flags); - } +function prepareFlags(pattern, flags) { + var i; - // Strip and apply a leading mode modifier with any combination of flags except g or y - pattern = nativ.replace.call(pattern, /^\(\?([\w$]+)\)/, function($0, $1) { - if (nativ.test.call(/[gy]/, $1)) { - throw new SyntaxError('Cannot use flag g or y in mode modifier ' + $0); - } - // Allow duplicate flags within the mode modifier - flags = clipDuplicates(flags + $1); - return ''; - }); + // Recent browsers throw on duplicate flags, so copy this behavior for nonnative flags + if (clipDuplicates(flags) !== flags) { + throw new SyntaxError('Invalid duplicate regex flag ' + flags); + } - // Throw on unknown native or nonnative flags - for (i = 0; i < flags.length; ++i) { - if (!registeredFlags[flags.charAt(i)]) { - throw new SyntaxError('Unknown regex flag ' + flags.charAt(i)); - } + // Strip and apply a leading mode modifier with any combination of flags except g or y + pattern = nativ.replace.call(pattern, /^\(\?([\w$]+)\)/, function($0, $1) { + if (nativ.test.call(/[gy]/, $1)) { + throw new SyntaxError('Cannot use flag g or y in mode modifier ' + $0); + } + // Allow duplicate flags within the mode modifier + flags = clipDuplicates(flags + $1); + return ''; + }); + + // Throw on unknown native or nonnative flags + for (i = 0; i < flags.length; ++i) { + if (!registeredFlags[flags.charAt(i)]) { + throw new SyntaxError('Unknown regex flag ' + flags.charAt(i)); } - - return { - pattern: pattern, - flags: flags - }; } + return { + pattern: pattern, + flags: flags + }; +} + /** * Prepares an options object from the given value. * - * @private * @param {String|Object} value Value to convert to an options object. * @returns {Object} Options object. */ - function prepareOptions(value) { - var options = {}; +function prepareOptions(value) { + var options = {}; - if (isType(value, 'String')) { - XRegExp.forEach(value, /[^\s,]+/, function(match) { - options[match] = true; - }); - - return options; - } + if (isType(value, 'String')) { + XRegExp.forEach(value, /[^\s,]+/, function(match) { + options[match] = true; + }); - return value; + return options; } + return value; +} + /** * Registers a flag so it doesn't throw an 'unknown flag' error. * - * @private * @param {String} flag Single-character flag to register. */ - function registerFlag(flag) { - if (!/^[\w$]$/.test(flag)) { - throw new Error('Flag must be a single character A-Za-z0-9_$'); - } - - registeredFlags[flag] = true; +function registerFlag(flag) { + if (!/^[\w$]$/.test(flag)) { + throw new Error('Flag must be a single character A-Za-z0-9_$'); } + registeredFlags[flag] = true; +} + /** * Runs built-in and custom regex syntax tokens in reverse insertion order at the specified * position, until a match is found. * - * @private * @param {String} pattern Original pattern from which an XRegExp object is being built. * @param {String} flags Flags being used to construct the regex. * @param {Number} pos Position to search for tokens within `pattern`. @@ -414,87 +403,84 @@ * @param {Object} context Context object to use for token handler functions. * @returns {Object} Object with properties `matchLength`, `output`, and `reparse`; or `null`. */ - function runTokens(pattern, flags, pos, scope, context) { - var i = tokens.length, - leadChar = pattern.charAt(pos), - result = null, - match, - t; - - // Run in reverse insertion order - while (i--) { - t = tokens[i]; - if ( - (t.leadChar && t.leadChar !== leadChar) || - (t.scope !== scope && t.scope !== 'all') || - (t.flag && flags.indexOf(t.flag) === -1) - ) { - continue; - } - - match = XRegExp.exec(pattern, t.regex, pos, 'sticky'); - if (match) { - result = { - matchLength: match[0].length, - output: t.handler.call(context, match, scope, flags), - reparse: t.reparse - }; - // Finished with token tests - break; - } +function runTokens(pattern, flags, pos, scope, context) { + var i = tokens.length, + leadChar = pattern.charAt(pos), + result = null, + match, + t; + + // Run in reverse insertion order + while (i--) { + t = tokens[i]; + if ( + (t.leadChar && t.leadChar !== leadChar) || + (t.scope !== scope && t.scope !== 'all') || + (t.flag && flags.indexOf(t.flag) === -1) + ) { + continue; } - return result; + match = XRegExp.exec(pattern, t.regex, pos, 'sticky'); + if (match) { + result = { + matchLength: match[0].length, + output: t.handler.call(context, match, scope, flags), + reparse: t.reparse + }; + // Finished with token tests + break; + } } + return result; +} + /** * Enables or disables implicit astral mode opt-in. When enabled, flag A is automatically added to * all new regexes created by XRegExp. This causes an error to be thrown when creating regexes if * the Unicode Base addon is not available, since flag A is registered by that addon. * - * @private * @param {Boolean} on `true` to enable; `false` to disable. */ - function setAstral(on) { - features.astral = on; - } +function setAstral(on) { + features.astral = on; +} /** * Enables or disables native method overrides. * - * @private * @param {Boolean} on `true` to enable; `false` to disable. */ - function setNatives(on) { - RegExp.prototype.exec = (on ? fixed : nativ).exec; - RegExp.prototype.test = (on ? fixed : nativ).test; - String.prototype.match = (on ? fixed : nativ).match; - String.prototype.replace = (on ? fixed : nativ).replace; - String.prototype.split = (on ? fixed : nativ).split; - - features.natives = on; - } +function setNatives(on) { + RegExp.prototype.exec = (on ? fixed : nativ).exec; + RegExp.prototype.test = (on ? fixed : nativ).test; + String.prototype.match = (on ? fixed : nativ).match; + String.prototype.replace = (on ? fixed : nativ).replace; + String.prototype.split = (on ? fixed : nativ).split; + + features.natives = on; +} /** * Returns the object, or throws an error if it is `null` or `undefined`. This is used to follow * the ES5 abstract operation `ToObject`. * - * @private * @param {*} value Object to check and return. * @returns {*} The provided object. */ - function toObject(value) { - // null or undefined - if (value == null) { - throw new TypeError('Cannot convert null or undefined to object'); - } - - return value; +function toObject(value) { + // null or undefined + if (value == null) { + throw new TypeError('Cannot convert null or undefined to object'); } -/* ============================== - * Constructor - * ============================== */ + return value; +} + +// ==--------------------------== +// Constructor +// ==--------------------------== /** * Creates an extended regular expression object for matching text with a pattern. Differs from a @@ -530,124 +516,124 @@ * // have fresh `lastIndex` properties (set to zero). * XRegExp(/regex/); */ - function XRegExp(pattern, flags) { - var context = { - hasNamedCapture: false, - captureNames: [] - }, - scope = defaultScope, - output = '', - pos = 0, - result, - token, - generated, - appliedPattern, - appliedFlags; - - if (XRegExp.isRegExp(pattern)) { - if (flags !== undefined) { - throw new TypeError('Cannot supply flags when copying a RegExp'); - } - return copyRegex(pattern); +function XRegExp(pattern, flags) { + if (XRegExp.isRegExp(pattern)) { + if (flags !== undefined) { + throw new TypeError('Cannot supply flags when copying a RegExp'); } + return copyRegex(pattern); + } - // Copy the argument behavior of `RegExp` - pattern = pattern === undefined ? '' : String(pattern); - flags = flags === undefined ? '' : String(flags); + // Copy the argument behavior of `RegExp` + pattern = pattern === undefined ? '' : String(pattern); + flags = flags === undefined ? '' : String(flags); - if (XRegExp.isInstalled('astral') && flags.indexOf('A') === -1) { - // This causes an error to be thrown if the Unicode Base addon is not available - flags += 'A'; - } + if (XRegExp.isInstalled('astral') && flags.indexOf('A') === -1) { + // This causes an error to be thrown if the Unicode Base addon is not available + flags += 'A'; + } - if (!patternCache[pattern]) { - patternCache[pattern] = {}; - } + if (!patternCache[pattern]) { + patternCache[pattern] = {}; + } - if (!patternCache[pattern][flags]) { - // Check for flag-related errors, and strip/apply flags in a leading mode modifier - result = prepareFlags(pattern, flags); - appliedPattern = result.pattern; - appliedFlags = result.flags; - - // Use XRegExp's tokens to translate the pattern to a native regex pattern. - // `appliedPattern.length` may change on each iteration if tokens use `reparse` - while (pos < appliedPattern.length) { - do { - // Check for custom tokens at the current position - result = runTokens(appliedPattern, appliedFlags, pos, scope, context); - // If the matched token used the `reparse` option, splice its output into the - // pattern before running tokens again at the same position - if (result && result.reparse) { - appliedPattern = appliedPattern.slice(0, pos) + - result.output + - appliedPattern.slice(pos + result.matchLength); - } - } while (result && result.reparse); - - if (result) { - output += result.output; - pos += (result.matchLength || 1); - } else { - // Get the native token at the current position - token = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky')[0]; - output += token; - pos += token.length; - if (token === '[' && scope === defaultScope) { - scope = classScope; - } else if (token === ']' && scope === classScope) { - scope = defaultScope; - } + if (!patternCache[pattern][flags]) { + var context = { + hasNamedCapture: false, + captureNames: [] + }; + var scope = defaultScope; + var output = ''; + var pos = 0; + var result; + + // Check for flag-related errors, and strip/apply flags in a leading mode modifier + var applied = prepareFlags(pattern, flags); + var appliedPattern = applied.pattern; + var appliedFlags = applied.flags; + + // Use XRegExp's tokens to translate the pattern to a native regex pattern. + // `appliedPattern.length` may change on each iteration if tokens use `reparse` + while (pos < appliedPattern.length) { + do { + // Check for custom tokens at the current position + result = runTokens(appliedPattern, appliedFlags, pos, scope, context); + // If the matched token used the `reparse` option, splice its output into the + // pattern before running tokens again at the same position + if (result && result.reparse) { + appliedPattern = appliedPattern.slice(0, pos) + + result.output + + appliedPattern.slice(pos + result.matchLength); } - } + } while (result && result.reparse); - patternCache[pattern][flags] = { - pattern: output, - // Strip all but native flags - flags: nativ.replace.call(appliedFlags, /[^gimuy]+/g, ''), - // `context.captureNames` has an item for each capturing group, even if unnamed - captures: context.hasNamedCapture ? context.captureNames : null - }; + if (result) { + output += result.output; + pos += (result.matchLength || 1); + } else { + // Get the native token at the current position + var token = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky')[0]; + output += token; + pos += token.length; + if (token === '[' && scope === defaultScope) { + scope = classScope; + } else if (token === ']' && scope === classScope) { + scope = defaultScope; + } + } } - generated = patternCache[pattern][flags]; - return augment( - new RegExp(generated.pattern, generated.flags), - generated.captures, - pattern, - flags - ); - }; + patternCache[pattern][flags] = { + // Use basic cleanup to collapse repeated empty groups like `(?:)(?:)` to `(?:)`. Empty + // groups are sometimes inserted during regex transpilation in order to keep tokens + // separated. However, more than one empty group in a row is never needed. + pattern: nativ.replace.call(output, /(?:\(\?:\))+/g, '(?:)'), + // Strip all but native flags + flags: nativ.replace.call(appliedFlags, /[^gimuy]+/g, ''), + // `context.captureNames` has an item for each capturing group, even if unnamed + captures: context.hasNamedCapture ? context.captureNames : null + }; + } + + var generated = patternCache[pattern][flags]; + return augment( + new RegExp(generated.pattern, generated.flags), + generated.captures, + pattern, + flags + ); +} // Add `RegExp.prototype` to the prototype chain - XRegExp.prototype = new RegExp(); +XRegExp.prototype = new RegExp(); -/* ============================== - * Public properties - * ============================== */ +// ==--------------------------== +// Public properties +// ==--------------------------== /** * The XRegExp version number as a string containing three dot-separated parts. For example, * '2.0.0-beta-3'. * * @static - * @memberOf XRegExp * @type String */ - XRegExp.version = '3.1.0'; +XRegExp.version = '3.1.1'; -/* ============================== - * Public methods - * ============================== */ +// ==--------------------------== +// Public methods +// ==--------------------------== -// Intentionally undocumented - XRegExp._hasNativeFlag = hasNativeFlag; +// Intentionally undocumented; used in tests and addons +XRegExp._hasNativeFlag = hasNativeFlag; +XRegExp._dec = dec; +XRegExp._hex = hex; +XRegExp._pad4 = pad4; /** * Extends XRegExp syntax and allows custom flags. This is used internally and can be used to * create XRegExp addons. If more than one token can match the same string, the last added wins. * - * @memberOf XRegExp * @param {RegExp} regex Regex object that matches the new token. * @param {Function} handler Function that returns a new pattern string (using native regex syntax) * to replace the matched token within all future XRegExp regexes. Has access to persistent @@ -692,45 +678,44 @@ * XRegExp('a+', 'U').exec('aaa')[0]; // -> 'a' * XRegExp('a+?', 'U').exec('aaa')[0]; // -> 'aaa' */ - XRegExp.addToken = function(regex, handler, options) { - options = options || {}; - var optionalFlags = options.optionalFlags, i; +XRegExp.addToken = function(regex, handler, options) { + options = options || {}; + var optionalFlags = options.optionalFlags, i; - if (options.flag) { - registerFlag(options.flag); - } + if (options.flag) { + registerFlag(options.flag); + } - if (optionalFlags) { - optionalFlags = nativ.split.call(optionalFlags, ''); - for (i = 0; i < optionalFlags.length; ++i) { - registerFlag(optionalFlags[i]); - } + if (optionalFlags) { + optionalFlags = nativ.split.call(optionalFlags, ''); + for (i = 0; i < optionalFlags.length; ++i) { + registerFlag(optionalFlags[i]); } + } - // Add to the private list of syntax tokens - tokens.push({ - regex: copyRegex(regex, { - addG: true, - addY: hasNativeY, - isInternalOnly: true - }), - handler: handler, - scope: options.scope || defaultScope, - flag: options.flag, - reparse: options.reparse, - leadChar: options.leadChar - }); - - // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and - // flags might now produce different results - XRegExp.cache.flush('patterns'); - }; + // Add to the private list of syntax tokens + tokens.push({ + regex: copyRegex(regex, { + addG: true, + addY: hasNativeY, + isInternalOnly: true + }), + handler: handler, + scope: options.scope || defaultScope, + flag: options.flag, + reparse: options.reparse, + leadChar: options.leadChar + }); + + // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and flags + // might now produce different results + XRegExp.cache.flush('patterns'); +}; /** * Caches and returns the result of calling `XRegExp(pattern, flags)`. On any subsequent call with * the same pattern and flag combination, the cached copy of the regex is returned. * - * @memberOf XRegExp * @param {String} pattern Regex pattern string. * @param {String} [flags] Any combination of XRegExp flags. * @returns {RegExp} Cached XRegExp object. @@ -740,31 +725,30 @@ * // The regex is compiled once only * } */ - XRegExp.cache = function(pattern, flags) { - if (!regexCache[pattern]) { - regexCache[pattern] = {}; - } - return regexCache[pattern][flags] || ( - regexCache[pattern][flags] = XRegExp(pattern, flags) - ); - }; - -// Intentionally undocumented - XRegExp.cache.flush = function(cacheName) { - if (cacheName === 'patterns') { - // Flush the pattern cache used by the `XRegExp` constructor - patternCache = {}; - } else { - // Flush the regex cache populated by `XRegExp.cache` - regexCache = {}; - } - }; +XRegExp.cache = function(pattern, flags) { + if (!regexCache[pattern]) { + regexCache[pattern] = {}; + } + return regexCache[pattern][flags] || ( + regexCache[pattern][flags] = XRegExp(pattern, flags) + ); +}; + +// Intentionally undocumented; used in tests +XRegExp.cache.flush = function(cacheName) { + if (cacheName === 'patterns') { + // Flush the pattern cache used by the `XRegExp` constructor + patternCache = {}; + } else { + // Flush the regex cache populated by `XRegExp.cache` + regexCache = {}; + } +}; /** * Escapes any regular expression metacharacters, for use when matching literal strings. The result * can safely be used at any point within a regex that uses any flags. * - * @memberOf XRegExp * @param {String} str String to escape. * @returns {String} String with regex metacharacters escaped. * @example @@ -772,9 +756,9 @@ * XRegExp.escape('Escaped? <.>'); * // -> 'Escaped\?\ <\.>' */ - XRegExp.escape = function(str) { - return nativ.replace.call(toObject(str), /[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); - }; +XRegExp.escape = function(str) { + return nativ.replace.call(toObject(str), /[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); +}; /** * Executes a regex search in a specified string. Returns a match array or `null`. If the provided @@ -784,7 +768,6 @@ * used, but is updated for compatibility. Also fixes browser bugs compared to the native * `RegExp.prototype.exec` and can be used reliably cross-browser. * - * @memberOf XRegExp * @param {String} str String to search. * @param {RegExp} regex Regex to search with. * @param {Number} [pos=0] Zero-based index at which to start the search. @@ -805,51 +788,50 @@ * } * // result -> ['2', '3', '4'] */ - XRegExp.exec = function(str, regex, pos, sticky) { - var cacheKey = 'g', - addY = false, - match, - r2; - - addY = hasNativeY && !!(sticky || (regex.sticky && sticky !== false)); - if (addY) { - cacheKey += 'y'; - } +XRegExp.exec = function(str, regex, pos, sticky) { + var cacheKey = 'g', + addY = false, + match, + r2; + + addY = hasNativeY && !!(sticky || (regex.sticky && sticky !== false)); + if (addY) { + cacheKey += 'y'; + } - regex[REGEX_DATA] = regex[REGEX_DATA] || {}; + regex[REGEX_DATA] = regex[REGEX_DATA] || {}; - // Shares cached copies with `XRegExp.match`/`replace` - r2 = regex[REGEX_DATA][cacheKey] || ( - regex[REGEX_DATA][cacheKey] = copyRegex(regex, { - addG: true, - addY: addY, - removeY: sticky === false, - isInternalOnly: true - }) - ); + // Shares cached copies with `XRegExp.match`/`replace` + r2 = regex[REGEX_DATA][cacheKey] || ( + regex[REGEX_DATA][cacheKey] = copyRegex(regex, { + addG: true, + addY: addY, + removeY: sticky === false, + isInternalOnly: true + }) + ); - r2.lastIndex = pos = pos || 0; + r2.lastIndex = pos = pos || 0; - // Fixed `exec` required for `lastIndex` fix, named backreferences, etc. - match = fixed.exec.call(r2, str); + // Fixed `exec` required for `lastIndex` fix, named backreferences, etc. + match = fixed.exec.call(r2, str); - if (sticky && match && match.index !== pos) { - match = null; - } + if (sticky && match && match.index !== pos) { + match = null; + } - if (regex.global) { - regex.lastIndex = match ? r2.lastIndex : 0; - } + if (regex.global) { + regex.lastIndex = match ? r2.lastIndex : 0; + } - return match; - }; + return match; +}; /** * Executes a provided function once per regex match. Searches always start at the beginning of the * string and continue until the end, regardless of the state of the regex's `global` property and * initial `lastIndex`. * - * @memberOf XRegExp * @param {String} str String to search. * @param {RegExp} regex Regex to search with. * @param {Function} callback Function to execute for each match. Invoked with four arguments: @@ -866,30 +848,29 @@ * }); * // evens -> [2, 4] */ - XRegExp.forEach = function(str, regex, callback) { - var pos = 0, - i = -1, - match; - - while ((match = XRegExp.exec(str, regex, pos))) { - // Because `regex` is provided to `callback`, the function could use the deprecated/ - // nonstandard `RegExp.prototype.compile` to mutate the regex. However, since - // `XRegExp.exec` doesn't use `lastIndex` to set the search position, this can't lead - // to an infinite loop, at least. Actually, because of the way `XRegExp.exec` caches - // globalized versions of regexes, mutating the regex will not have any effect on the - // iteration or matched strings, which is a nice side effect that brings extra safety - callback(match, ++i, str, regex); - - pos = match.index + (match[0].length || 1); - } - }; +XRegExp.forEach = function(str, regex, callback) { + var pos = 0, + i = -1, + match; + + while ((match = XRegExp.exec(str, regex, pos))) { + // Because `regex` is provided to `callback`, the function could use the deprecated/ + // nonstandard `RegExp.prototype.compile` to mutate the regex. However, since `XRegExp.exec` + // doesn't use `lastIndex` to set the search position, this can't lead to an infinite loop, + // at least. Actually, because of the way `XRegExp.exec` caches globalized versions of + // regexes, mutating the regex will not have any effect on the iteration or matched strings, + // which is a nice side effect that brings extra safety. + callback(match, ++i, str, regex); + + pos = match.index + (match[0].length || 1); + } +}; /** * Copies a regex object and adds flag `g`. The copy maintains extended data, is augmented with * `XRegExp.prototype` properties, and has a fresh `lastIndex` property (set to zero). Native * regexes are not recompiled using XRegExp syntax. * - * @memberOf XRegExp * @param {RegExp} regex Regex to globalize. * @returns {RegExp} Copy of the provided regex with flag `g` added. * @example @@ -897,15 +878,14 @@ * var globalCopy = XRegExp.globalize(/regex/); * globalCopy.global; // -> true */ - XRegExp.globalize = function(regex) { - return copyRegex(regex, {addG: true}); - }; +XRegExp.globalize = function(regex) { + return copyRegex(regex, {addG: true}); +}; /** * Installs optional features according to the specified options. Can be undone using * `XRegExp.uninstall`. * - * @memberOf XRegExp * @param {Object|String} options Options object or string. * @example * @@ -921,22 +901,21 @@ * // With an options string * XRegExp.install('astral natives'); */ - XRegExp.install = function(options) { - options = prepareOptions(options); +XRegExp.install = function(options) { + options = prepareOptions(options); - if (!features.astral && options.astral) { - setAstral(true); - } + if (!features.astral && options.astral) { + setAstral(true); + } - if (!features.natives && options.natives) { - setNatives(true); - } - }; + if (!features.natives && options.natives) { + setNatives(true); + } +}; /** * Checks whether an individual optional feature is installed. * - * @memberOf XRegExp * @param {String} feature Name of the feature to check. One of: *
  • `astral` *
  • `natives` @@ -945,15 +924,14 @@ * * XRegExp.isInstalled('astral'); */ - XRegExp.isInstalled = function(feature) { - return !!(features[feature]); - }; +XRegExp.isInstalled = function(feature) { + return !!(features[feature]); +}; /** * Returns `true` if an object is a regex; `false` if it isn't. This works correctly for regexes * created in another frame, when `instanceof` and `constructor` checks would fail. * - * @memberOf XRegExp * @param {*} value Object to check. * @returns {Boolean} Whether the object is a `RegExp` object. * @example @@ -963,10 +941,10 @@ * XRegExp.isRegExp(RegExp('^', 'm')); // -> true * XRegExp.isRegExp(XRegExp('(?s).')); // -> true */ - XRegExp.isRegExp = function(value) { - return toString.call(value) === '[object RegExp]'; - //return isType(value, 'RegExp'); - }; +XRegExp.isRegExp = function(value) { + return toString.call(value) === '[object RegExp]'; + //return isType(value, 'RegExp'); +}; /** * Returns the first matched string, or in global mode, an array containing all matched strings. @@ -975,7 +953,6 @@ * and an empty array instead of `null` when no matches are found in match-all mode). It also lets * you override flag g and ignore `lastIndex`, and fixes browser bugs. * - * @memberOf XRegExp * @param {String} str String to search. * @param {RegExp} regex Regex to search with. * @param {String} [scope='one'] Use 'one' to return the first match as a string. Use 'all' to @@ -995,35 +972,35 @@ * XRegExp.match('abc', /\w/, 'all'); // -> ['a', 'b', 'c'] * XRegExp.match('abc', /x/, 'all'); // -> [] */ - XRegExp.match = function(str, regex, scope) { - var global = (regex.global && scope !== 'one') || scope === 'all', - cacheKey = ((global ? 'g' : '') + (regex.sticky ? 'y' : '')) || 'noGY', - result, - r2; +XRegExp.match = function(str, regex, scope) { + var global = (regex.global && scope !== 'one') || scope === 'all', + cacheKey = ((global ? 'g' : '') + (regex.sticky ? 'y' : '')) || 'noGY', + result, + r2; + + regex[REGEX_DATA] = regex[REGEX_DATA] || {}; + + // Shares cached copies with `XRegExp.exec`/`replace` + r2 = regex[REGEX_DATA][cacheKey] || ( + regex[REGEX_DATA][cacheKey] = copyRegex(regex, { + addG: !!global, + removeG: scope === 'one', + isInternalOnly: true + }) + ); - regex[REGEX_DATA] = regex[REGEX_DATA] || {}; + result = nativ.match.call(toObject(str), r2); - // Shares cached copies with `XRegExp.exec`/`replace` - r2 = regex[REGEX_DATA][cacheKey] || ( - regex[REGEX_DATA][cacheKey] = copyRegex(regex, { - addG: !!global, - removeG: scope === 'one', - isInternalOnly: true - }) + if (regex.global) { + regex.lastIndex = ( + (scope === 'one' && result) ? + // Can't use `r2.lastIndex` since `r2` is nonglobal in this case + (result.index + result[0].length) : 0 ); + } - result = nativ.match.call(toObject(str), r2); - - if (regex.global) { - regex.lastIndex = ( - (scope === 'one' && result) ? - // Can't use `r2.lastIndex` since `r2` is nonglobal in this case - (result.index + result[0].length) : 0 - ); - } - - return global ? (result || []) : (result && result[0]); - }; + return global ? (result || []) : (result && result[0]); +}; /** * Retrieves the matches from searching a string using a chain of regexes that successively search @@ -1031,7 +1008,6 @@ * `regex` and `backref` properties. When a backreference is specified, the named or numbered * backreference is passed forward to the next regex or returned. * - * @memberOf XRegExp * @param {String} str String to search. * @param {Array} chain Regexes that each search for matches within preceding results. * @returns {Array} Matches by the last regex in the chain, or an empty array. @@ -1053,38 +1029,37 @@ * ]); * // -> ['xregexp.com', 'www.google.com'] */ - XRegExp.matchChain = function(str, chain) { - return (function recurseChain(values, level) { - var item = chain[level].regex ? chain[level] : {regex: chain[level]}, - matches = [], - addMatch = function(match) { - if (item.backref) { - /* Safari 4.0.5 (but not 5.0.5+) inappropriately uses sparse arrays to hold - * the `undefined`s for backreferences to nonparticipating capturing - * groups. In such cases, a `hasOwnProperty` or `in` check on its own would - * inappropriately throw the exception, so also check if the backreference - * is a number that is within the bounds of the array. - */ - if (!(match.hasOwnProperty(item.backref) || +item.backref < match.length)) { - throw new ReferenceError('Backreference to undefined group: ' + item.backref); - } - - matches.push(match[item.backref] || ''); - } else { - matches.push(match[0]); - } - }, - i; +XRegExp.matchChain = function(str, chain) { + return (function recurseChain(values, level) { + var item = chain[level].regex ? chain[level] : {regex: chain[level]}; + var matches = []; + + function addMatch(match) { + if (item.backref) { + // Safari 4.0.5 (but not 5.0.5+) inappropriately uses sparse arrays to hold the + // `undefined`s for backreferences to nonparticipating capturing groups. In such + // cases, a `hasOwnProperty` or `in` check on its own would inappropriately throw + // the exception, so also check if the backreference is a number that is within the + // bounds of the array. + if (!(match.hasOwnProperty(item.backref) || +item.backref < match.length)) { + throw new ReferenceError('Backreference to undefined group: ' + item.backref); + } - for (i = 0; i < values.length; ++i) { - XRegExp.forEach(values[i], item.regex, addMatch); + matches.push(match[item.backref] || ''); + } else { + matches.push(match[0]); } + } - return ((level === chain.length - 1) || !matches.length) ? - matches : - recurseChain(matches, level + 1); - }([str], 0)); - }; + for (var i = 0; i < values.length; ++i) { + XRegExp.forEach(values[i], item.regex, addMatch); + } + + return ((level === chain.length - 1) || !matches.length) ? + matches : + recurseChain(matches, level + 1); + }([str], 0)); +}; /** * Returns a new string with one or all matches of a pattern replaced. The pattern can be a string @@ -1094,7 +1069,6 @@ * functions can use named backreferences via `arguments[0].name`. Also fixes browser bugs compared * to the native `String.prototype.replace` and can be used reliably cross-browser. * - * @memberOf XRegExp * @param {String} str String to search. * @param {RegExp|String} search Search pattern to be replaced. * @param {String|Function} replacement Replacement string or a function invoked to create it. @@ -1133,39 +1107,39 @@ * XRegExp.replace('RegExp builds RegExps', 'RegExp', 'XRegExp', 'all'); * // -> 'XRegExp builds XRegExps' */ - XRegExp.replace = function(str, search, replacement, scope) { - var isRegex = XRegExp.isRegExp(search), - global = (search.global && scope !== 'one') || scope === 'all', - cacheKey = ((global ? 'g' : '') + (search.sticky ? 'y' : '')) || 'noGY', - s2 = search, - result; - - if (isRegex) { - search[REGEX_DATA] = search[REGEX_DATA] || {}; - - // Shares cached copies with `XRegExp.exec`/`match`. Since a copy is used, `search`'s - // `lastIndex` isn't updated *during* replacement iterations - s2 = search[REGEX_DATA][cacheKey] || ( - search[REGEX_DATA][cacheKey] = copyRegex(search, { - addG: !!global, - removeG: scope === 'one', - isInternalOnly: true - }) - ); - } else if (global) { - s2 = new RegExp(XRegExp.escape(String(search)), 'g'); - } +XRegExp.replace = function(str, search, replacement, scope) { + var isRegex = XRegExp.isRegExp(search), + global = (search.global && scope !== 'one') || scope === 'all', + cacheKey = ((global ? 'g' : '') + (search.sticky ? 'y' : '')) || 'noGY', + s2 = search, + result; + + if (isRegex) { + search[REGEX_DATA] = search[REGEX_DATA] || {}; + + // Shares cached copies with `XRegExp.exec`/`match`. Since a copy is used, `search`'s + // `lastIndex` isn't updated *during* replacement iterations + s2 = search[REGEX_DATA][cacheKey] || ( + search[REGEX_DATA][cacheKey] = copyRegex(search, { + addG: !!global, + removeG: scope === 'one', + isInternalOnly: true + }) + ); + } else if (global) { + s2 = new RegExp(XRegExp.escape(String(search)), 'g'); + } - // Fixed `replace` required for named backreferences, etc. - result = fixed.replace.call(toObject(str), s2, replacement); + // Fixed `replace` required for named backreferences, etc. + result = fixed.replace.call(toObject(str), s2, replacement); - if (isRegex && search.global) { - // Fixes IE, Safari bug (last tested IE 9, Safari 5.1) - search.lastIndex = 0; - } + if (isRegex && search.global) { + // Fixes IE, Safari bug (last tested IE 9, Safari 5.1) + search.lastIndex = 0; + } - return result; - }; + return result; +}; /** * Performs batch processing of string replacements. Used like `XRegExp.replace`, but accepts an @@ -1174,7 +1148,6 @@ * replacement string or function, and an optional scope of 'one' or 'all'. Uses the XRegExp * replacement text syntax, which supports named backreference properties via `${name}`. * - * @memberOf XRegExp * @param {String} str String to search. * @param {Array} replacements Array of replacement detail arrays. * @returns {String} New string with all replacements. @@ -1191,16 +1164,16 @@ * }] * ]); */ - XRegExp.replaceEach = function(str, replacements) { - var i, r; +XRegExp.replaceEach = function(str, replacements) { + var i, r; - for (i = 0; i < replacements.length; ++i) { - r = replacements[i]; - str = XRegExp.replace(str, r[0], r[1], r[2]); - } + for (i = 0; i < replacements.length; ++i) { + r = replacements[i]; + str = XRegExp.replace(str, r[0], r[1], r[2]); + } - return str; - }; + return str; +}; /** * Splits a string into an array of strings using a regex or string separator. Matches of the @@ -1209,7 +1182,6 @@ * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably * cross-browser. * - * @memberOf XRegExp * @param {String} str String to split. * @param {RegExp|String} separator Regex or string to use for separating the string. * @param {Number} [limit] Maximum number of items to include in the result array. @@ -1228,9 +1200,9 @@ * XRegExp.split('..word1..', /([a-z]+)(\d+)/i); * // -> ['..', 'word', '1', '..'] */ - XRegExp.split = function(str, separator, limit) { - return fixed.split.call(toObject(str), separator, limit); - }; +XRegExp.split = function(str, separator, limit) { + return fixed.split.call(toObject(str), separator, limit); +}; /** * Executes a regex search in a specified string. Returns `true` or `false`. Optional `pos` and @@ -1239,7 +1211,6 @@ * updated for compatibility. Also fixes browser bugs compared to the native * `RegExp.prototype.test` and can be used reliably cross-browser. * - * @memberOf XRegExp * @param {String} str String to search. * @param {RegExp} regex Regex to search with. * @param {Number} [pos=0] Zero-based index at which to start the search. @@ -1255,16 +1226,15 @@ * XRegExp.test('abc', /c/, 0, 'sticky'); // -> false * XRegExp.test('abc', /c/, 2, 'sticky'); // -> true */ - XRegExp.test = function(str, regex, pos, sticky) { - // Do this the easy way :-) - return !!XRegExp.exec(str, regex, pos, sticky); - }; +XRegExp.test = function(str, regex, pos, sticky) { + // Do this the easy way :-) + return !!XRegExp.exec(str, regex, pos, sticky); +}; /** * Uninstalls optional features according to the specified options. All optional features start out * uninstalled, so this is used to undo the actions of `XRegExp.install`. * - * @memberOf XRegExp * @param {Object|String} options Options object or string. * @example * @@ -1280,17 +1250,17 @@ * // With an options string * XRegExp.uninstall('astral natives'); */ - XRegExp.uninstall = function(options) { - options = prepareOptions(options); +XRegExp.uninstall = function(options) { + options = prepareOptions(options); - if (features.astral && options.astral) { - setAstral(false); - } + if (features.astral && options.astral) { + setAstral(false); + } - if (features.natives && options.natives) { - setNatives(false); - } - }; + if (features.natives && options.natives) { + setNatives(false); + } +}; /** * Returns an XRegExp object that is the union of the given patterns. Patterns can be provided as @@ -1299,7 +1269,6 @@ * the larger combined pattern. Native flags used by provided regexes are ignored in favor of the * `flags` argument. * - * @memberOf XRegExp * @param {Array} patterns Regexes and strings to combine. * @param {String} [flags] Any combination of XRegExp flags. * @returns {RegExp} Union of the provided regexes and strings. @@ -1308,161 +1277,158 @@ * XRegExp.union(['a+b*c', /(dogs)\1/, /(cats)\1/], 'i'); * // -> /a\+b\*c|(dogs)\1|(cats)\2/i */ - XRegExp.union = function(patterns, flags) { - var parts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*]/g, - output = [], - numCaptures = 0, - numPriorCaptures, - captureNames, - pattern, - rewrite = function(match, paren, backref) { - var name = captureNames[numCaptures - numPriorCaptures]; - - // Capturing group - if (paren) { - ++numCaptures; - // If the current capture has a name, preserve the name - if (name) { - return '(?<' + name + '>'; - } - // Backreference - } else if (backref) { - // Rewrite the backreference - return '\\' + (+backref + numPriorCaptures); - } +XRegExp.union = function(patterns, flags) { + var numCaptures = 0; + var numPriorCaptures; + var captureNames; + + function rewrite(match, paren, backref) { + var name = captureNames[numCaptures - numPriorCaptures]; + + // Capturing group + if (paren) { + ++numCaptures; + // If the current capture has a name, preserve the name + if (name) { + return '(?<' + name + '>'; + } + // Backreference + } else if (backref) { + // Rewrite the backreference + return '\\' + (+backref + numPriorCaptures); + } - return match; - }, - i; + return match; + } - if (!(isType(patterns, 'Array') && patterns.length)) { - throw new TypeError('Must provide a nonempty array of patterns to merge'); - } + if (!(isType(patterns, 'Array') && patterns.length)) { + throw new TypeError('Must provide a nonempty array of patterns to merge'); + } - for (i = 0; i < patterns.length; ++i) { - pattern = patterns[i]; + var parts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*]/g; + var output = []; + var pattern; + for (var i = 0; i < patterns.length; ++i) { + pattern = patterns[i]; - if (XRegExp.isRegExp(pattern)) { - numPriorCaptures = numCaptures; - captureNames = (pattern[REGEX_DATA] && pattern[REGEX_DATA].captureNames) || []; + if (XRegExp.isRegExp(pattern)) { + numPriorCaptures = numCaptures; + captureNames = (pattern[REGEX_DATA] && pattern[REGEX_DATA].captureNames) || []; - // Rewrite backreferences. Passing to XRegExp dies on octals and ensures patterns - // are independently valid; helps keep this simple. Named captures are put back - output.push(nativ.replace.call(XRegExp(pattern.source).source, parts, rewrite)); - } else { - output.push(XRegExp.escape(pattern)); - } + // Rewrite backreferences. Passing to XRegExp dies on octals and ensures patterns are + // independently valid; helps keep this simple. Named captures are put back + output.push(nativ.replace.call(XRegExp(pattern.source).source, parts, rewrite)); + } else { + output.push(XRegExp.escape(pattern)); } + } - return XRegExp(output.join('|'), flags); - }; + return XRegExp(output.join('|'), flags); +}; -/* ============================== - * Fixed/extended native methods - * ============================== */ +// ==--------------------------== +// Fixed/extended native methods +// ==--------------------------== /** * Adds named capture support (with backreferences returned as `result.name`), and fixes browser * bugs in the native `RegExp.prototype.exec`. Calling `XRegExp.install('natives')` uses this to * override the native method. Use via `XRegExp.exec` without overriding natives. * - * @private * @param {String} str String to search. * @returns {Array} Match array with named backreference properties, or `null`. */ - fixed.exec = function(str) { - var origLastIndex = this.lastIndex, - match = nativ.exec.apply(this, arguments), - name, - r2, - i; - - if (match) { - // Fix browsers whose `exec` methods don't return `undefined` for nonparticipating - // capturing groups. This fixes IE 5.5-8, but not IE 9's quirks mode or emulation of - // older IEs. IE 9 in standards mode follows the spec - if (!correctExecNpcg && match.length > 1 && indexOf(match, '') > -1) { - r2 = copyRegex(this, { - removeG: true, - isInternalOnly: true - }); - // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed - // matching due to characters outside the match - nativ.replace.call(String(str).slice(match.index), r2, function() { - var len = arguments.length, i; - // Skip index 0 and the last 2 - for (i = 1; i < len - 2; ++i) { - if (arguments[i] === undefined) { - match[i] = undefined; - } - } - }); - } - - // Attach named capture properties - if (this[REGEX_DATA] && this[REGEX_DATA].captureNames) { - // Skip index 0 - for (i = 1; i < match.length; ++i) { - name = this[REGEX_DATA].captureNames[i - 1]; - if (name) { - match[name] = match[i]; +fixed.exec = function(str) { + var origLastIndex = this.lastIndex, + match = nativ.exec.apply(this, arguments), + name, + r2, + i; + + if (match) { + // Fix browsers whose `exec` methods don't return `undefined` for nonparticipating capturing + // groups. This fixes IE 5.5-8, but not IE 9's quirks mode or emulation of older IEs. IE 9 + // in standards mode follows the spec. + if (!correctExecNpcg && match.length > 1 && indexOf(match, '') > -1) { + r2 = copyRegex(this, { + removeG: true, + isInternalOnly: true + }); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + nativ.replace.call(String(str).slice(match.index), r2, function() { + var len = arguments.length, i; + // Skip index 0 and the last 2 + for (i = 1; i < len - 2; ++i) { + if (arguments[i] === undefined) { + match[i] = undefined; } } - } + }); + } - // Fix browsers that increment `lastIndex` after zero-length matches - if (this.global && !match[0].length && (this.lastIndex > match.index)) { - this.lastIndex = match.index; + // Attach named capture properties + if (this[REGEX_DATA] && this[REGEX_DATA].captureNames) { + // Skip index 0 + for (i = 1; i < match.length; ++i) { + name = this[REGEX_DATA].captureNames[i - 1]; + if (name) { + match[name] = match[i]; + } } } - if (!this.global) { - // Fixes IE, Opera bug (last tested IE 9, Opera 11.6) - this.lastIndex = origLastIndex; + // Fix browsers that increment `lastIndex` after zero-length matches + if (this.global && !match[0].length && (this.lastIndex > match.index)) { + this.lastIndex = match.index; } + } - return match; - }; + if (!this.global) { + // Fixes IE, Opera bug (last tested IE 9, Opera 11.6) + this.lastIndex = origLastIndex; + } + + return match; +}; /** * Fixes browser bugs in the native `RegExp.prototype.test`. Calling `XRegExp.install('natives')` * uses this to override the native method. * - * @private * @param {String} str String to search. * @returns {Boolean} Whether the regex matched the provided value. */ - fixed.test = function(str) { - // Do this the easy way :-) - return !!fixed.exec.call(this, str); - }; +fixed.test = function(str) { + // Do this the easy way :-) + return !!fixed.exec.call(this, str); +}; /** * Adds named capture support (with backreferences returned as `result.name`), and fixes browser * bugs in the native `String.prototype.match`. Calling `XRegExp.install('natives')` uses this to * override the native method. * - * @private * @param {RegExp|*} regex Regex to search with. If not a regex object, it is passed to `RegExp`. * @returns {Array} If `regex` uses flag g, an array of match strings or `null`. Without flag g, * the result of calling `regex.exec(this)`. */ - fixed.match = function(regex) { - var result; +fixed.match = function(regex) { + var result; - if (!XRegExp.isRegExp(regex)) { - // Use the native `RegExp` rather than `XRegExp` - regex = new RegExp(regex); - } else if (regex.global) { - result = nativ.match.apply(this, arguments); - // Fixes IE bug - regex.lastIndex = 0; + if (!XRegExp.isRegExp(regex)) { + // Use the native `RegExp` rather than `XRegExp` + regex = new RegExp(regex); + } else if (regex.global) { + result = nativ.match.apply(this, arguments); + // Fixes IE bug + regex.lastIndex = 0; - return result; - } + return result; + } - return fixed.exec.call(regex, toObject(this)); - }; + return fixed.exec.call(regex, toObject(this)); +}; /** * Adds support for `${n}` tokens for named and numbered backreferences in replacement text, and @@ -1473,212 +1439,210 @@ * that this doesn't support SpiderMonkey's proprietary third (`flags`) argument. Use via * `XRegExp.replace` without overriding natives. * - * @private * @param {RegExp|String} search Search pattern to be replaced. * @param {String|Function} replacement Replacement string or a function invoked to create it. * @returns {String} New string with one or all matches replaced. */ - fixed.replace = function(search, replacement) { - var isRegex = XRegExp.isRegExp(search), - origLastIndex, - captureNames, - result; - - if (isRegex) { - if (search[REGEX_DATA]) { - captureNames = search[REGEX_DATA].captureNames; - } - // Only needed if `search` is nonglobal - origLastIndex = search.lastIndex; - } else { - search += ''; // Type-convert +fixed.replace = function(search, replacement) { + var isRegex = XRegExp.isRegExp(search), + origLastIndex, + captureNames, + result; + + if (isRegex) { + if (search[REGEX_DATA]) { + captureNames = search[REGEX_DATA].captureNames; } + // Only needed if `search` is nonglobal + origLastIndex = search.lastIndex; + } else { + search += ''; // Type-convert + } - // Don't use `typeof`; some older browsers return 'function' for regex objects - if (isType(replacement, 'Function')) { - // Stringifying `this` fixes a bug in IE < 9 where the last argument in replacement - // functions isn't type-converted to a string - result = nativ.replace.call(String(this), search, function() { - var args = arguments, i; - if (captureNames) { - // Change the `arguments[0]` string primitive to a `String` object that can - // store properties. This really does need to use `String` as a constructor - args[0] = new String(args[0]); - // Store named backreferences on the first argument - for (i = 0; i < captureNames.length; ++i) { - if (captureNames[i]) { - args[0][captureNames[i]] = args[i + 1]; - } + // Don't use `typeof`; some older browsers return 'function' for regex objects + if (isType(replacement, 'Function')) { + // Stringifying `this` fixes a bug in IE < 9 where the last argument in replacement + // functions isn't type-converted to a string + result = nativ.replace.call(String(this), search, function() { + var args = arguments, i; + if (captureNames) { + // Change the `arguments[0]` string primitive to a `String` object that can store + // properties. This really does need to use `String` as a constructor + args[0] = new String(args[0]); + // Store named backreferences on the first argument + for (i = 0; i < captureNames.length; ++i) { + if (captureNames[i]) { + args[0][captureNames[i]] = args[i + 1]; } } - // Update `lastIndex` before calling `replacement`. Fixes IE, Chrome, Firefox, - // Safari bug (last tested IE 9, Chrome 17, Firefox 11, Safari 5.1) - if (isRegex && search.global) { - search.lastIndex = args[args.length - 2] + args[0].length; - } - // ES6 specs the context for replacement functions as `undefined` - return replacement.apply(undefined, args); - }); - } else { - // Ensure that the last value of `args` will be a string when given nonstring `this`, - // while still throwing on null or undefined context - result = nativ.replace.call(this == null ? this : String(this), search, function() { - // Keep this function's `arguments` available through closure - var args = arguments; - return nativ.replace.call(String(replacement), replacementToken, function($0, $1, $2) { - var n; - // Named or numbered backreference with curly braces - if ($1) { - // XRegExp behavior for `${n}`: - // 1. Backreference to numbered capture, if `n` is an integer. Use `0` for - // for the entire match. Any number of leading zeros may be used. - // 2. Backreference to named capture `n`, if it exists and is not an - // integer overridden by numbered capture. In practice, this does not - // overlap with numbered capture since XRegExp does not allow named - // capture to use a bare integer as the name. - // 3. If the name or number does not refer to an existing capturing group, - // it's an error. - n = +$1; // Type-convert; drop leading zeros - if (n <= args.length - 3) { - return args[n] || ''; - } - // Groups with the same name is an error, else would need `lastIndexOf` - n = captureNames ? indexOf(captureNames, $1) : -1; - if (n < 0) { - throw new SyntaxError('Backreference to undefined group ' + $0); - } - return args[n + 1] || ''; - } - // Else, special variable or numbered backreference without curly braces - if ($2 === '$') { // $$ - return '$'; - } - if ($2 === '&' || +$2 === 0) { // $&, $0 (not followed by 1-9), $00 - return args[0]; - } - if ($2 === '`') { // $` (left context) - return args[args.length - 1].slice(0, args[args.length - 2]); + } + // Update `lastIndex` before calling `replacement`. Fixes IE, Chrome, Firefox, Safari + // bug (last tested IE 9, Chrome 17, Firefox 11, Safari 5.1) + if (isRegex && search.global) { + search.lastIndex = args[args.length - 2] + args[0].length; + } + // ES6 specs the context for replacement functions as `undefined` + return replacement.apply(undefined, args); + }); + } else { + // Ensure that the last value of `args` will be a string when given nonstring `this`, + // while still throwing on null or undefined context + result = nativ.replace.call(this == null ? this : String(this), search, function() { + // Keep this function's `arguments` available through closure + var args = arguments; + return nativ.replace.call(String(replacement), replacementToken, function($0, $1, $2) { + var n; + // Named or numbered backreference with curly braces + if ($1) { + // XRegExp behavior for `${n}`: + // 1. Backreference to numbered capture, if `n` is an integer. Use `0` for the + // entire match. Any number of leading zeros may be used. + // 2. Backreference to named capture `n`, if it exists and is not an integer + // overridden by numbered capture. In practice, this does not overlap with + // numbered capture since XRegExp does not allow named capture to use a bare + // integer as the name. + // 3. If the name or number does not refer to an existing capturing group, it's + // an error. + n = +$1; // Type-convert; drop leading zeros + if (n <= args.length - 3) { + return args[n] || ''; } - if ($2 === "'") { // $' (right context) - return args[args.length - 1].slice(args[args.length - 2] + args[0].length); + // Groups with the same name is an error, else would need `lastIndexOf` + n = captureNames ? indexOf(captureNames, $1) : -1; + if (n < 0) { + throw new SyntaxError('Backreference to undefined group ' + $0); } - // Else, numbered backreference without curly braces - $2 = +$2; // Type-convert; drop leading zero - // XRegExp behavior for `$n` and `$nn`: - // - Backrefs end after 1 or 2 digits. Use `${..}` for more digits. - // - `$1` is an error if no capturing groups. - // - `$10` is an error if less than 10 capturing groups. Use `${1}0` instead. - // - `$01` is `$1` if at least one capturing group, else it's an error. - // - `$0` (not followed by 1-9) and `$00` are the entire match. - // Native behavior, for comparison: - // - Backrefs end after 1 or 2 digits. Cannot reference capturing group 100+. - // - `$1` is a literal `$1` if no capturing groups. - // - `$10` is `$1` followed by a literal `0` if less than 10 capturing groups. - // - `$01` is `$1` if at least one capturing group, else it's a literal `$01`. - // - `$0` is a literal `$0`. - if (!isNaN($2)) { - if ($2 > args.length - 3) { - throw new SyntaxError('Backreference to undefined group ' + $0); - } - return args[$2] || ''; + return args[n + 1] || ''; + } + // Else, special variable or numbered backreference without curly braces + if ($2 === '$') { // $$ + return '$'; + } + if ($2 === '&' || +$2 === 0) { // $&, $0 (not followed by 1-9), $00 + return args[0]; + } + if ($2 === '`') { // $` (left context) + return args[args.length - 1].slice(0, args[args.length - 2]); + } + if ($2 === "'") { // $' (right context) + return args[args.length - 1].slice(args[args.length - 2] + args[0].length); + } + // Else, numbered backreference without curly braces + $2 = +$2; // Type-convert; drop leading zero + // XRegExp behavior for `$n` and `$nn`: + // - Backrefs end after 1 or 2 digits. Use `${..}` for more digits. + // - `$1` is an error if no capturing groups. + // - `$10` is an error if less than 10 capturing groups. Use `${1}0` instead. + // - `$01` is `$1` if at least one capturing group, else it's an error. + // - `$0` (not followed by 1-9) and `$00` are the entire match. + // Native behavior, for comparison: + // - Backrefs end after 1 or 2 digits. Cannot reference capturing group 100+. + // - `$1` is a literal `$1` if no capturing groups. + // - `$10` is `$1` followed by a literal `0` if less than 10 capturing groups. + // - `$01` is `$1` if at least one capturing group, else it's a literal `$01`. + // - `$0` is a literal `$0`. + if (!isNaN($2)) { + if ($2 > args.length - 3) { + throw new SyntaxError('Backreference to undefined group ' + $0); } - // `$` followed by an unsupported char is an error, unlike native JS - throw new SyntaxError('Invalid token ' + $0); - }); + return args[$2] || ''; + } + // `$` followed by an unsupported char is an error, unlike native JS + throw new SyntaxError('Invalid token ' + $0); }); - } + }); + } - if (isRegex) { - if (search.global) { - // Fixes IE, Safari bug (last tested IE 9, Safari 5.1) - search.lastIndex = 0; - } else { - // Fixes IE, Opera bug (last tested IE 9, Opera 11.6) - search.lastIndex = origLastIndex; - } + if (isRegex) { + if (search.global) { + // Fixes IE, Safari bug (last tested IE 9, Safari 5.1) + search.lastIndex = 0; + } else { + // Fixes IE, Opera bug (last tested IE 9, Opera 11.6) + search.lastIndex = origLastIndex; } + } - return result; - }; + return result; +}; /** * Fixes browser bugs in the native `String.prototype.split`. Calling `XRegExp.install('natives')` * uses this to override the native method. Use via `XRegExp.split` without overriding natives. * - * @private * @param {RegExp|String} separator Regex or string to use for separating the string. * @param {Number} [limit] Maximum number of items to include in the result array. * @returns {Array} Array of substrings. */ - fixed.split = function(separator, limit) { - if (!XRegExp.isRegExp(separator)) { - // Browsers handle nonregex split correctly, so use the faster native method - return nativ.split.apply(this, arguments); - } +fixed.split = function(separator, limit) { + if (!XRegExp.isRegExp(separator)) { + // Browsers handle nonregex split correctly, so use the faster native method + return nativ.split.apply(this, arguments); + } - var str = String(this), - output = [], - origLastIndex = separator.lastIndex, - lastLastIndex = 0, - lastLength; - - // Values for `limit`, per the spec: - // If undefined: pow(2,32) - 1 - // If 0, Infinity, or NaN: 0 - // If positive number: limit = floor(limit); if (limit >= pow(2,32)) limit -= pow(2,32); - // If negative number: pow(2,32) - floor(abs(limit)) - // If other: Type-convert, then use the above rules - // This line fails in very strange ways for some values of `limit` in Opera 10.5-10.63, - // unless Opera Dragonfly is open (go figure). It works in at least Opera 9.5-10.1 and 11+ - limit = (limit === undefined ? -1 : limit) >>> 0; - - XRegExp.forEach(str, separator, function(match) { - // This condition is not the same as `if (match[0].length)` - if ((match.index + match[0].length) > lastLastIndex) { - output.push(str.slice(lastLastIndex, match.index)); - if (match.length > 1 && match.index < str.length) { - Array.prototype.push.apply(output, match.slice(1)); - } - lastLength = match[0].length; - lastLastIndex = match.index + lastLength; + var str = String(this), + output = [], + origLastIndex = separator.lastIndex, + lastLastIndex = 0, + lastLength; + + // Values for `limit`, per the spec: + // If undefined: pow(2,32) - 1 + // If 0, Infinity, or NaN: 0 + // If positive number: limit = floor(limit); if (limit >= pow(2,32)) limit -= pow(2,32); + // If negative number: pow(2,32) - floor(abs(limit)) + // If other: Type-convert, then use the above rules + // This line fails in very strange ways for some values of `limit` in Opera 10.5-10.63, unless + // Opera Dragonfly is open (go figure). It works in at least Opera 9.5-10.1 and 11+ + limit = (limit === undefined ? -1 : limit) >>> 0; + + XRegExp.forEach(str, separator, function(match) { + // This condition is not the same as `if (match[0].length)` + if ((match.index + match[0].length) > lastLastIndex) { + output.push(str.slice(lastLastIndex, match.index)); + if (match.length > 1 && match.index < str.length) { + Array.prototype.push.apply(output, match.slice(1)); } - }); + lastLength = match[0].length; + lastLastIndex = match.index + lastLength; + } + }); - if (lastLastIndex === str.length) { - if (!nativ.test.call(separator, '') || lastLength) { - output.push(''); - } - } else { - output.push(str.slice(lastLastIndex)); + if (lastLastIndex === str.length) { + if (!nativ.test.call(separator, '') || lastLength) { + output.push(''); } + } else { + output.push(str.slice(lastLastIndex)); + } - separator.lastIndex = origLastIndex; - return output.length > limit ? output.slice(0, limit) : output; - }; + separator.lastIndex = origLastIndex; + return output.length > limit ? output.slice(0, limit) : output; +}; -/* ============================== - * Built-in syntax/flag tokens - * ============================== */ +// ==--------------------------== +// Built-in syntax/flag tokens +// ==--------------------------== /* * Letter escapes that natively match literal characters: `\a`, `\A`, etc. These should be * SyntaxErrors but are allowed in web reality. XRegExp makes them errors for cross-browser * consistency and to reserve their syntax, but lets them be superseded by addons. */ - XRegExp.addToken( - /\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/, - function(match, scope) { - // \B is allowed in default scope only - if (match[1] === 'B' && scope === defaultScope) { - return match[0]; - } - throw new SyntaxError('Invalid escape ' + match[0]); - }, - { - scope: 'all', - leadChar: '\\' +XRegExp.addToken( + /\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/, + function(match, scope) { + // \B is allowed in default scope only + if (match[1] === 'B' && scope === defaultScope) { + return match[0]; } - ); + throw new SyntaxError('Invalid escape ' + match[0]); + }, + { + scope: 'all', + leadChar: '\\' + } +); /* * Unicode code point escape with curly braces: `\u{N..}`. `N..` is any one or more digit @@ -1688,134 +1652,137 @@ * if you follow a `\u{N..}` token that references a code point above U+FFFF with a quantifier, or * if you use the same in a character class. */ - XRegExp.addToken( - /\\u{([\dA-Fa-f]+)}/, - function(match, scope, flags) { - var code = dec(match[1]); - if (code > 0x10FFFF) { - throw new SyntaxError('Invalid Unicode code point ' + match[0]); - } - if (code <= 0xFFFF) { - // Converting to \uNNNN avoids needing to escape the literal character and keep it - // separate from preceding tokens - return '\\u' + pad4(hex(code)); - } - // If `code` is between 0xFFFF and 0x10FFFF, require and defer to native handling - if (hasNativeU && flags.indexOf('u') > -1) { - return match[0]; - } - throw new SyntaxError('Cannot use Unicode code point above \\u{FFFF} without flag u'); - }, - { - scope: 'all', - leadChar: '\\' +XRegExp.addToken( + /\\u{([\dA-Fa-f]+)}/, + function(match, scope, flags) { + var code = dec(match[1]); + if (code > 0x10FFFF) { + throw new SyntaxError('Invalid Unicode code point ' + match[0]); } - ); + if (code <= 0xFFFF) { + // Converting to \uNNNN avoids needing to escape the literal character and keep it + // separate from preceding tokens + return '\\u' + pad4(hex(code)); + } + // If `code` is between 0xFFFF and 0x10FFFF, require and defer to native handling + if (hasNativeU && flags.indexOf('u') > -1) { + return match[0]; + } + throw new SyntaxError('Cannot use Unicode code point above \\u{FFFF} without flag u'); + }, + { + scope: 'all', + leadChar: '\\' + } +); /* * Empty character class: `[]` or `[^]`. This fixes a critical cross-browser syntax inconsistency. * Unless this is standardized (per the ES spec), regex syntax can't be accurately parsed because * character class endings can't be determined. */ - XRegExp.addToken( - /\[(\^?)]/, - function(match) { - // For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S]. - // (?!) should work like \b\B, but is unreliable in some versions of Firefox - return match[1] ? '[\\s\\S]' : '\\b\\B'; - }, - {leadChar: '['} - ); +XRegExp.addToken( + /\[(\^?)]/, + function(match) { + // For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S]. + // (?!) should work like \b\B, but is unreliable in some versions of Firefox + return match[1] ? '[\\s\\S]' : '\\b\\B'; + }, + {leadChar: '['} +); /* * Comment pattern: `(?# )`. Inline comments are an alternative to the line comments allowed in * free-spacing mode (flag x). */ - XRegExp.addToken( - /\(\?#[^)]*\)/, - function(match, scope, flags) { - // Keep tokens separated unless the following token is a quantifier - return isQuantifierNext(match.input, match.index + match[0].length, flags) ? - '' : '(?:)'; - }, - {leadChar: '('} - ); +XRegExp.addToken( + /\(\?#[^)]*\)/, + function(match, scope, flags) { + // Keep tokens separated unless the following token is a quantifier. This avoids e.g. + // inadvertedly changing `\1(?#)1` to `\11`. + return isQuantifierNext(match.input, match.index + match[0].length, flags) ? + '' : '(?:)'; + }, + {leadChar: '('} +); /* * Whitespace and line comments, in free-spacing mode (aka extended mode, flag x) only. */ - XRegExp.addToken( - /\s+|#.*/, - function(match, scope, flags) { - // Keep tokens separated unless the following token is a quantifier - return isQuantifierNext(match.input, match.index + match[0].length, flags) ? - '' : '(?:)'; - }, - {flag: 'x'} - ); +XRegExp.addToken( + /\s+|#[^\n]*\n?/, + function(match, scope, flags) { + // Keep tokens separated unless the following token is a quantifier. This avoids e.g. + // inadvertedly changing `\1 1` to `\11`. + return isQuantifierNext(match.input, match.index + match[0].length, flags) ? + '' : '(?:)'; + }, + {flag: 'x'} +); /* * Dot, in dotall mode (aka singleline mode, flag s) only. */ - XRegExp.addToken( - /\./, - function() { - return '[\\s\\S]'; - }, - { - flag: 's', - leadChar: '.' - } - ); +XRegExp.addToken( + /\./, + function() { + return '[\\s\\S]'; + }, + { + flag: 's', + leadChar: '.' + } +); /* * Named backreference: `\k`. Backreference names can use the characters A-Z, a-z, 0-9, _, * and $ only. Also allows numbered backreferences as `\k`. */ - XRegExp.addToken( - /\\k<([\w$]+)>/, - function(match) { - // Groups with the same name is an error, else would need `lastIndexOf` - var index = isNaN(match[1]) ? (indexOf(this.captureNames, match[1]) + 1) : +match[1], - endIndex = match.index + match[0].length; - if (!index || index > this.captureNames.length) { - throw new SyntaxError('Backreference to undefined group ' + match[0]); - } - // Keep backreferences separate from subsequent literal numbers - return '\\' + index + ( - endIndex === match.input.length || isNaN(match.input.charAt(endIndex)) ? - '' : '(?:)' - ); - }, - {leadChar: '\\'} - ); +XRegExp.addToken( + /\\k<([\w$]+)>/, + function(match) { + // Groups with the same name is an error, else would need `lastIndexOf` + var index = isNaN(match[1]) ? (indexOf(this.captureNames, match[1]) + 1) : +match[1], + endIndex = match.index + match[0].length; + if (!index || index > this.captureNames.length) { + throw new SyntaxError('Backreference to undefined group ' + match[0]); + } + // Keep backreferences separate from subsequent literal numbers. This avoids e.g. + // inadvertedly changing `(?)\k1` to `()\11`. + return '\\' + index + ( + endIndex === match.input.length || isNaN(match.input.charAt(endIndex)) ? + '' : '(?:)' + ); + }, + {leadChar: '\\'} +); /* * Numbered backreference or octal, plus any following digits: `\0`, `\11`, etc. Octals except `\0` * not followed by 0-9 and backreferences to unopened capture groups throw an error. Other matches * are returned unaltered. IE < 9 doesn't support backreferences above `\99` in regex syntax. */ - XRegExp.addToken( - /\\(\d+)/, - function(match, scope) { - if ( - !( - scope === defaultScope && - /^[1-9]/.test(match[1]) && - +match[1] <= this.captureNames.length - ) && - match[1] !== '0' - ) { - throw new SyntaxError('Cannot use octal escape or backreference to undefined group ' + - match[0]); - } - return match[0]; - }, - { - scope: 'all', - leadChar: '\\' +XRegExp.addToken( + /\\(\d+)/, + function(match, scope) { + if ( + !( + scope === defaultScope && + /^[1-9]/.test(match[1]) && + +match[1] <= this.captureNames.length + ) && + match[1] !== '0' + ) { + throw new SyntaxError('Cannot use octal escape or backreference to undefined group ' + + match[0]); } - ); + return match[0]; + }, + { + scope: 'all', + leadChar: '\\' + } +); /* * Named capturing group; match the opening delimiter only: `(?`. Capture names can use the @@ -1824,48 +1791,44 @@ * supported the Python-style syntax. Otherwise, XRegExp might treat numbered backreferences to * Python-style named capture as octals. */ - XRegExp.addToken( - /\(\?P?<([\w$]+)>/, - function(match) { - // Disallow bare integers as names because named backreferences are added to match - // arrays and therefore numeric properties may lead to incorrect lookups - if (!isNaN(match[1])) { - throw new SyntaxError('Cannot use integer as capture name ' + match[0]); - } - if (match[1] === 'length' || match[1] === '__proto__') { - throw new SyntaxError('Cannot use reserved word as capture name ' + match[0]); - } - if (indexOf(this.captureNames, match[1]) > -1) { - throw new SyntaxError('Cannot use same name for multiple groups ' + match[0]); - } - this.captureNames.push(match[1]); - this.hasNamedCapture = true; - return '('; - }, - {leadChar: '('} - ); +XRegExp.addToken( + /\(\?P?<([\w$]+)>/, + function(match) { + // Disallow bare integers as names because named backreferences are added to match arrays + // and therefore numeric properties may lead to incorrect lookups + if (!isNaN(match[1])) { + throw new SyntaxError('Cannot use integer as capture name ' + match[0]); + } + if (match[1] === 'length' || match[1] === '__proto__') { + throw new SyntaxError('Cannot use reserved word as capture name ' + match[0]); + } + if (indexOf(this.captureNames, match[1]) > -1) { + throw new SyntaxError('Cannot use same name for multiple groups ' + match[0]); + } + this.captureNames.push(match[1]); + this.hasNamedCapture = true; + return '('; + }, + {leadChar: '('} +); /* * Capturing group; match the opening parenthesis only. Required for support of named capturing * groups. Also adds explicit capture mode (flag n). */ - XRegExp.addToken( - /\((?!\?)/, - function(match, scope, flags) { - if (flags.indexOf('n') > -1) { - return '(?:'; - } - this.captureNames.push(null); - return '('; - }, - { - optionalFlags: 'n', - leadChar: '(' +XRegExp.addToken( + /\((?!\?)/, + function(match, scope, flags) { + if (flags.indexOf('n') > -1) { + return '(?:'; } - ); - -/* ============================== - * Expose XRegExp - * ============================== */ + this.captureNames.push(null); + return '('; + }, + { + optionalFlags: 'n', + leadChar: '(' + } +); - module.exports = XRegExp; +module.exports = XRegExp; diff --git a/tools/eslint/package.json b/tools/eslint/package.json index c5787d4cfc1c8b..77a386a9b843fd 100644 --- a/tools/eslint/package.json +++ b/tools/eslint/package.json @@ -1,19 +1,19 @@ { "_args": [ [ - "eslint@latest", + "eslint", "/Users/trott/io.js/tools" ] ], "_from": "eslint@latest", - "_id": "eslint@2.9.0", + "_id": "eslint@3.0.1", "_inCache": true, "_installable": true, "_location": "/eslint", "_nodeVersion": "4.4.2", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/eslint-2.9.0.tgz_1461949357357_0.922593503491953" + "tmp": "tmp/eslint-3.0.1.tgz_1467741316725_0.5076132179237902" }, "_npmUser": { "email": "nicholas@nczconsulting.com", @@ -23,8 +23,8 @@ "_phantomChildren": {}, "_requested": { "name": "eslint", - "raw": "eslint@latest", - "rawSpec": "latest", + "raw": "eslint", + "rawSpec": "", "scope": null, "spec": "latest", "type": "tag" @@ -32,10 +32,10 @@ "_requiredBy": [ "#USER" ], - "_resolved": "https://registry.npmjs.org/eslint/-/eslint-2.9.0.tgz", - "_shasum": "5b3fdb7497bb042e2747e3d1fe95f404dca39a60", + "_resolved": "https://registry.npmjs.org/eslint/-/eslint-3.0.1.tgz", + "_shasum": "ff12eafdc04ea71d173a099d4658a136e7157934", "_shrinkwrap": null, - "_spec": "eslint@latest", + "_spec": "eslint", "_where": "/Users/trott/io.js/tools", "author": { "email": "nicholas+npm@nczconsulting.com", @@ -51,10 +51,10 @@ "chalk": "^1.1.3", "concat-stream": "^1.4.6", "debug": "^2.1.1", - "doctrine": "^1.2.1", + "doctrine": "^1.2.2", "es6-map": "^0.1.3", "escope": "^3.6.0", - "espree": "3.1.4", + "espree": "^3.1.6", "estraverse": "^4.2.0", "esutils": "^2.0.2", "file-entry-cache": "^1.1.1", @@ -67,15 +67,16 @@ "is-resolvable": "^1.0.0", "js-yaml": "^3.5.1", "json-stable-stringify": "^1.0.0", + "levn": "^0.3.0", "lodash": "^4.0.0", "mkdirp": "^0.5.0", "optionator": "^0.8.1", - "path-is-absolute": "^1.0.0", "path-is-inside": "^1.0.1", "pluralize": "^1.2.1", "progress": "^1.1.8", "require-uncached": "^1.0.2", "shelljs": "^0.6.0", + "strip-bom": "^3.0.0", "strip-json-comments": "~1.0.1", "table": "^3.7.8", "text-table": "~0.2.0", @@ -97,15 +98,19 @@ "gh-got": "^2.2.0", "istanbul": "^0.4.0", "jsdoc": "^3.3.0-beta1", + "karma": "^0.13.22", + "karma-mocha": "^1.0.1", + "karma-mocha-reporter": "^2.0.3", + "karma-phantomjs-launcher": "^1.0.0", "leche": "^2.1.1", "linefix": "^0.1.1", "load-perf": "^0.2.0", "markdownlint": "^0.1.0", "mocha": "^2.4.5", - "mocha-phantomjs": "4.0.1", + "mock-fs": "^3.9.0", "npm-license": "^0.3.2", - "phantomjs-polyfill": "0.0.1", - "proxyquire": "^1.0.0", + "phantomjs-prebuilt": "^2.1.7", + "proxyquire": ">=1.0.0 <1.7.5", "semver": "^5.0.3", "shelljs-nodecli": "~0.1.0", "sinon": "^1.17.2", @@ -114,11 +119,11 @@ }, "directories": {}, "dist": { - "shasum": "5b3fdb7497bb042e2747e3d1fe95f404dca39a60", - "tarball": "https://registry.npmjs.org/eslint/-/eslint-2.9.0.tgz" + "shasum": "ff12eafdc04ea71d173a099d4658a136e7157934", + "tarball": "https://registry.npmjs.org/eslint/-/eslint-3.0.1.tgz" }, "engines": { - "node": ">=0.10" + "node": ">=4" }, "files": [ "LICENSE", @@ -128,7 +133,7 @@ "lib", "messages" ], - "gitHead": "d8887638a9eaeeda6ea09f7d625d1bc57ea7f436", + "gitHead": "0fd4b6db5ff273a8475fe9ddc25486a10bf40f83", "homepage": "http://eslint.org", "keywords": [ "ast", @@ -170,5 +175,5 @@ "release": "node Makefile.js release", "test": "node Makefile.js test" }, - "version": "2.9.0" + "version": "3.0.1" } From f0b0fc49f9fcba16d381c812f59096fda9f030de Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 26 May 2016 20:57:55 -0700 Subject: [PATCH 153/261] test: update weak module for gc tests Previous version of weak used for gc tests emitted a warning on OS X. Updating to current version eliminates warning. PR-URL: https://github.com/nodejs/node/pull/7014 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- test/gc/node_modules/bindings/README.md | 97 + test/gc/node_modules/bindings/bindings.js | 166 ++ test/gc/node_modules/bindings/package.json | 83 + test/gc/node_modules/nan/LICENSE.md | 13 + test/gc/node_modules/nan/README.md | 403 +++ test/gc/node_modules/nan/include_dirs.js | 1 + test/gc/node_modules/nan/nan.h | 2271 +++++++++++++++++ test/gc/node_modules/nan/nan_callbacks.h | 88 + .../node_modules/nan/nan_callbacks_12_inl.h | 512 ++++ .../nan/nan_callbacks_pre_12_inl.h | 506 ++++ test/gc/node_modules/nan/nan_converters.h | 64 + .../node_modules/nan/nan_converters_43_inl.h | 42 + .../nan/nan_converters_pre_43_inl.h | 42 + .../nan/nan_implementation_12_inl.h | 404 +++ .../nan/nan_implementation_pre_12_inl.h | 264 ++ test/gc/node_modules/nan/nan_maybe_43_inl.h | 231 ++ .../node_modules/nan/nan_maybe_pre_43_inl.h | 303 +++ test/gc/node_modules/nan/nan_new.h | 340 +++ test/gc/node_modules/nan/nan_object_wrap.h | 155 ++ .../node_modules/nan/nan_persistent_12_inl.h | 129 + .../nan/nan_persistent_pre_12_inl.h | 242 ++ test/gc/node_modules/nan/nan_string_bytes.h | 305 +++ .../nan/nan_typedarray_contents.h | 87 + test/gc/node_modules/nan/nan_weak.h | 422 +++ test/gc/node_modules/nan/package.json | 121 + test/gc/node_modules/nan/tools/1to2.js | 412 +++ test/gc/node_modules/nan/tools/README.md | 14 + test/gc/node_modules/nan/tools/package.json | 19 + test/gc/node_modules/weak/.gitignore | 1 - test/gc/node_modules/weak/LICENSE | 2 +- test/gc/node_modules/weak/README.md | 91 +- test/gc/node_modules/weak/appveyor.yml | 49 + test/gc/node_modules/weak/binding.gyp | 13 +- test/gc/node_modules/weak/build/Makefile | 342 +++ .../node_modules/weak/build/binding.Makefile | 6 + test/gc/node_modules/weak/build/config.gypi | 56 + test/gc/node_modules/weak/build/gyp-mac-tool | 611 +++++ .../node_modules/weak/build/weakref.target.mk | 168 ++ test/gc/node_modules/weak/lib/weak.js | 121 +- test/gc/node_modules/weak/package.json | 102 +- test/gc/node_modules/weak/src/weakref.cc | 371 ++- 41 files changed, 9390 insertions(+), 279 deletions(-) create mode 100644 test/gc/node_modules/bindings/README.md create mode 100644 test/gc/node_modules/bindings/bindings.js create mode 100644 test/gc/node_modules/bindings/package.json create mode 100644 test/gc/node_modules/nan/LICENSE.md create mode 100644 test/gc/node_modules/nan/README.md create mode 100644 test/gc/node_modules/nan/include_dirs.js create mode 100644 test/gc/node_modules/nan/nan.h create mode 100644 test/gc/node_modules/nan/nan_callbacks.h create mode 100644 test/gc/node_modules/nan/nan_callbacks_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_callbacks_pre_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_converters.h create mode 100644 test/gc/node_modules/nan/nan_converters_43_inl.h create mode 100644 test/gc/node_modules/nan/nan_converters_pre_43_inl.h create mode 100644 test/gc/node_modules/nan/nan_implementation_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_implementation_pre_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_maybe_43_inl.h create mode 100644 test/gc/node_modules/nan/nan_maybe_pre_43_inl.h create mode 100644 test/gc/node_modules/nan/nan_new.h create mode 100644 test/gc/node_modules/nan/nan_object_wrap.h create mode 100644 test/gc/node_modules/nan/nan_persistent_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_persistent_pre_12_inl.h create mode 100644 test/gc/node_modules/nan/nan_string_bytes.h create mode 100644 test/gc/node_modules/nan/nan_typedarray_contents.h create mode 100644 test/gc/node_modules/nan/nan_weak.h create mode 100644 test/gc/node_modules/nan/package.json create mode 100755 test/gc/node_modules/nan/tools/1to2.js create mode 100644 test/gc/node_modules/nan/tools/README.md create mode 100644 test/gc/node_modules/nan/tools/package.json delete mode 100644 test/gc/node_modules/weak/.gitignore create mode 100644 test/gc/node_modules/weak/appveyor.yml create mode 100644 test/gc/node_modules/weak/build/Makefile create mode 100644 test/gc/node_modules/weak/build/binding.Makefile create mode 100644 test/gc/node_modules/weak/build/config.gypi create mode 100755 test/gc/node_modules/weak/build/gyp-mac-tool create mode 100644 test/gc/node_modules/weak/build/weakref.target.mk diff --git a/test/gc/node_modules/bindings/README.md b/test/gc/node_modules/bindings/README.md new file mode 100644 index 00000000000000..585cf512b9b1f6 --- /dev/null +++ b/test/gc/node_modules/bindings/README.md @@ -0,0 +1,97 @@ +node-bindings +============= +### Helper module for loading your native module's .node file + +This is a helper module for authors of Node.js native addon modules. +It is basically the "swiss army knife" of `require()`ing your native module's +`.node` file. + +Throughout the course of Node's native addon history, addons have ended up being +compiled in a variety of different places, depending on which build tool and which +version of node was used. To make matters worse, now the _gyp_ build tool can +produce either a _Release_ or _Debug_ build, each being built into different +locations. + +This module checks _all_ the possible locations that a native addon would be built +at, and returns the first one that loads successfully. + + +Installation +------------ + +Install with `npm`: + +``` bash +$ npm install bindings +``` + +Or add it to the `"dependencies"` section of your _package.json_ file. + + +Example +------- + +`require()`ing the proper bindings file for the current node version, platform +and architecture is as simple as: + +``` js +var bindings = require('bindings')('binding.node') + +// Use your bindings defined in your C files +bindings.your_c_function() +``` + + +Nice Error Output +----------------- + +When the `.node` file could not be loaded, `node-bindings` throws an Error with +a nice error message telling you exactly what was tried. You can also check the +`err.tries` Array property. + +``` +Error: Could not load the bindings file. Tried: + → /Users/nrajlich/ref/build/binding.node + → /Users/nrajlich/ref/build/Debug/binding.node + → /Users/nrajlich/ref/build/Release/binding.node + → /Users/nrajlich/ref/out/Debug/binding.node + → /Users/nrajlich/ref/Debug/binding.node + → /Users/nrajlich/ref/out/Release/binding.node + → /Users/nrajlich/ref/Release/binding.node + → /Users/nrajlich/ref/build/default/binding.node + → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node + at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13) + at Object. (/Users/nrajlich/ref/lib/ref.js:5:47) + at Module._compile (module.js:449:26) + at Object.Module._extensions..js (module.js:467:10) + at Module.load (module.js:356:32) + at Function.Module._load (module.js:312:12) + ... +``` + + +License +------- + +(The MIT License) + +Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/test/gc/node_modules/bindings/bindings.js b/test/gc/node_modules/bindings/bindings.js new file mode 100644 index 00000000000000..93dcf85a187afe --- /dev/null +++ b/test/gc/node_modules/bindings/bindings.js @@ -0,0 +1,166 @@ + +/** + * Module dependencies. + */ + +var fs = require('fs') + , path = require('path') + , join = path.join + , dirname = path.dirname + , exists = fs.existsSync || path.existsSync + , defaults = { + arrow: process.env.NODE_BINDINGS_ARROW || ' → ' + , compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' + , platform: process.platform + , arch: process.arch + , version: process.versions.node + , bindings: 'bindings.node' + , try: [ + // node-gyp's linked version in the "build" dir + [ 'module_root', 'build', 'bindings' ] + // node-waf and gyp_addon (a.k.a node-gyp) + , [ 'module_root', 'build', 'Debug', 'bindings' ] + , [ 'module_root', 'build', 'Release', 'bindings' ] + // Debug files, for development (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Debug', 'bindings' ] + , [ 'module_root', 'Debug', 'bindings' ] + // Release files, but manually compiled (legacy behavior, remove for node v0.9) + , [ 'module_root', 'out', 'Release', 'bindings' ] + , [ 'module_root', 'Release', 'bindings' ] + // Legacy from node-waf, node <= 0.4.x + , [ 'module_root', 'build', 'default', 'bindings' ] + // Production "Release" buildtype binary (meh...) + , [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ] + ] + } + +/** + * The main `bindings()` function loads the compiled bindings for a given module. + * It uses V8's Error API to determine the parent filename that this function is + * being invoked from, which is then used to find the root directory. + */ + +function bindings (opts) { + + // Argument surgery + if (typeof opts == 'string') { + opts = { bindings: opts } + } else if (!opts) { + opts = {} + } + opts.__proto__ = defaults + + // Get the module root + if (!opts.module_root) { + opts.module_root = exports.getRoot(exports.getFileName()) + } + + // Ensure the given bindings name ends with .node + if (path.extname(opts.bindings) != '.node') { + opts.bindings += '.node' + } + + var tries = [] + , i = 0 + , l = opts.try.length + , n + , b + , err + + for (; i=1.2.1 <2.0.0", + "_id": "bindings@1.2.1", + "_inCache": true, + "_installable": true, + "_location": "/bindings", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "1.4.14", + "_phantomChildren": {}, + "_requested": { + "name": "bindings", + "raw": "bindings@^1.2.1", + "rawSpec": "^1.2.1", + "scope": null, + "spec": ">=1.2.1 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/weak" + ], + "_resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "_shasum": "14ad6113812d2d37d72e67b4cacb4bb726505f11", + "_shrinkwrap": null, + "_spec": "bindings@^1.2.1", + "_where": "/Users/trott/io.js/test/gc/node_modules/weak", + "author": { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", + "url": "http://tootallnate.net" + }, + "bugs": { + "url": "https://github.com/TooTallNate/node-bindings/issues" + }, + "dependencies": {}, + "description": "Helper module for loading your native module's .node file", + "devDependencies": {}, + "directories": {}, + "dist": { + "shasum": "14ad6113812d2d37d72e67b4cacb4bb726505f11", + "tarball": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz" + }, + "gitHead": "e404152ee27f8478ccbc7122ee051246e8e5ec02", + "homepage": "https://github.com/TooTallNate/node-bindings", + "keywords": [ + "native", + "addon", + "bindings", + "gyp", + "waf", + "c", + "c++" + ], + "license": "MIT", + "main": "./bindings.js", + "maintainers": [ + { + "email": "nathan@tootallnate.net", + "name": "TooTallNate" + }, + { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + } + ], + "name": "bindings", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/TooTallNate/node-bindings.git" + }, + "scripts": {}, + "version": "1.2.1" +} diff --git a/test/gc/node_modules/nan/LICENSE.md b/test/gc/node_modules/nan/LICENSE.md new file mode 100644 index 00000000000000..e4fc4127eb5b43 --- /dev/null +++ b/test/gc/node_modules/nan/LICENSE.md @@ -0,0 +1,13 @@ +The MIT License (MIT) +===================== + +Copyright (c) 2016 NAN contributors +----------------------------------- + +*NAN contributors listed at * + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/test/gc/node_modules/nan/README.md b/test/gc/node_modules/nan/README.md new file mode 100644 index 00000000000000..e730131b94aebe --- /dev/null +++ b/test/gc/node_modules/nan/README.md @@ -0,0 +1,403 @@ +Native Abstractions for Node.js +=============================== + +**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 4, 5 and 6.** + +***Current version: 2.3.3*** + +*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)* + +[![NPM](https://nodei.co/npm/nan.png?downloads=true&downloadRank=true)](https://nodei.co/npm/nan/) [![NPM](https://nodei.co/npm-dl/nan.png?months=6&height=3)](https://nodei.co/npm/nan/) + +[![Build Status](https://api.travis-ci.org/nodejs/nan.svg?branch=master)](http://travis-ci.org/nodejs/nan) +[![Build status](https://ci.appveyor.com/api/projects/status/kh73pbm9dsju7fgh)](https://ci.appveyor.com/project/RodVagg/nan) + +Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.12 to 4.0, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle. + +This project also contains some helper utilities that make addon development a bit more pleasant. + + * **[News & Updates](#news)** + * **[Usage](#usage)** + * **[Example](#example)** + * **[API](#api)** + * **[Tests](#tests)** + * **[Governance & Contributing](#governance)** + + +## News & Updates + + +## Usage + +Simply add **NAN** as a dependency in the *package.json* of your Node addon: + +``` bash +$ npm install --save nan +``` + +Pull in the path to **NAN** in your *binding.gyp* so that you can use `#include ` in your *.cpp* files: + +``` python +"include_dirs" : [ + "` when compiling your addon. + + +## Example + +Just getting started with Nan? Take a look at the **[Node Add-on Examples](https://github.com/nodejs/node-addon-examples)**. + +Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality. + +For a simpler example, see the **[async pi estimation example](https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**. + +Yet another example is **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon. + +Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plehora of code snippets for your pasting pleasure. + + +## API + +Additional to the NAN documentation below, please consult: + +* [The V8 Getting Started Guide](https://developers.google.com/v8/get_started) +* [The V8 Embedders Guide](https://developers.google.com/v8/embed) +* [V8 API Documentation](http://v8docs.nodesource.com/) +* [Node Add-on Documentation](https://nodejs.org/api/addons.html) + + + +### JavaScript-accessible methods + +A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://developers.google.com/v8/embed#templates) for further information. + +In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type. + +* **Method argument types** + - Nan::FunctionCallbackInfo + - Nan::PropertyCallbackInfo + - Nan::ReturnValue +* **Method declarations** + - Method declaration + - Getter declaration + - Setter declaration + - Property getter declaration + - Property setter declaration + - Property enumerator declaration + - Property deleter declaration + - Property query declaration + - Index getter declaration + - Index setter declaration + - Index enumerator declaration + - Index deleter declaration + - Index query declaration +* Method and template helpers + - Nan::SetMethod() + - Nan::SetPrototypeMethod() + - Nan::SetAccessor() + - Nan::SetNamedPropertyHandler() + - Nan::SetIndexedPropertyHandler() + - Nan::SetTemplate() + - Nan::SetPrototypeTemplate() + - Nan::SetInstanceTemplate() + - Nan::SetCallHandler() + - Nan::SetCallAsFunctionHandler() + +### Scopes + +A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works. + +A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope. + +The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these. + + - Nan::HandleScope + - Nan::EscapableHandleScope + +Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles). + +### Persistent references + +An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed. + +Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported. + + - Nan::PersistentBase & v8::PersistentBase + - Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits + - Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits + - Nan::Persistent + - Nan::Global + - Nan::WeakCallbackInfo + - Nan::WeakCallbackType + +Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles). + +### New + +NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8. + + - Nan::New() + - Nan::Undefined() + - Nan::Null() + - Nan::True() + - Nan::False() + - Nan::EmptyString() + + +### Converters + +NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN. + + - Nan::To() + +### Maybe Types + +The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_. + +* **Maybe Types** + - Nan::MaybeLocal + - Nan::Maybe + - Nan::Nothing + - Nan::Just +* **Maybe Helpers** + - Nan::Call() + - Nan::ToDetailString() + - Nan::ToArrayIndex() + - Nan::Equals() + - Nan::NewInstance() + - Nan::GetFunction() + - Nan::Set() + - Nan::ForceSet() + - Nan::Get() + - Nan::GetPropertyAttributes() + - Nan::Has() + - Nan::Delete() + - Nan::GetPropertyNames() + - Nan::GetOwnPropertyNames() + - Nan::SetPrototype() + - Nan::ObjectProtoToString() + - Nan::HasOwnProperty() + - Nan::HasRealNamedProperty() + - Nan::HasRealIndexedProperty() + - Nan::HasRealNamedCallbackProperty() + - Nan::GetRealNamedPropertyInPrototypeChain() + - Nan::GetRealNamedProperty() + - Nan::CallAsFunction() + - Nan::CallAsConstructor() + - Nan::GetSourceLine() + - Nan::GetLineNumber() + - Nan::GetStartColumn() + - Nan::GetEndColumn() + - Nan::CloneElementAt() + - Nan::MakeMaybe() + +### Script + +NAN provides a `v8::Script` helpers as the API has changed over the supported versions of V8. + + - Nan::CompileScript() + - Nan::RunScript() + + +### Errors + +NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted. + +Note that an Error object is simply a specialized form of `v8::Value`. + +Also consult the V8 Embedders Guide section on [Exceptions](https://developers.google.com/v8/embed#exceptions) for more information. + + - Nan::Error() + - Nan::RangeError() + - Nan::ReferenceError() + - Nan::SyntaxError() + - Nan::TypeError() + - Nan::ThrowError() + - Nan::ThrowRangeError() + - Nan::ThrowReferenceError() + - Nan::ThrowSyntaxError() + - Nan::ThrowTypeError() + - Nan::FatalException() + - Nan::ErrnoException() + - Nan::TryCatch + + +### Buffers + +NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility. + + - Nan::NewBuffer() + - Nan::CopyBuffer() + - Nan::FreeCallback() + +### Nan::Callback + +`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution. + + - Nan::Callback + +### Asynchronous work helpers + +`Nan::AsyncWorker` and `Nan::AsyncProgressWorker` are helper classes that make working with asynchronous code easier. + + - Nan::AsyncWorker + - Nan::AsyncProgressWorker + - Nan::AsyncQueueWorker + +### Strings & Bytes + +Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing. + + - Nan::Encoding + - Nan::Encode() + - Nan::DecodeBytes() + - Nan::DecodeWrite() + + +### Object Wrappers + +The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects. + + - Nan::ObjectWrap + + +### V8 internals + +The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods. + + - NAN_GC_CALLBACK() + - Nan::AddGCEpilogueCallback() + - Nan::RemoveGCEpilogueCallback() + - Nan::AddGCPrologueCallback() + - Nan::RemoveGCPrologueCallback() + - Nan::GetHeapStatistics() + - Nan::SetCounterFunction() + - Nan::SetCreateHistogramFunction() + - Nan::SetAddHistogramSampleFunction() + - Nan::IdleNotification() + - Nan::LowMemoryNotification() + - Nan::ContextDisposedNotification() + - Nan::GetInternalFieldPointer() + - Nan::SetInternalFieldPointer() + - Nan::AdjustExternalMemory() + + +### Miscellaneous V8 Helpers + + - Nan::Utf8String + - Nan::GetCurrentContext() + - Nan::SetIsolateData() + - Nan::GetIsolateData() + - Nan::TypedArrayContents + + +### Miscellaneous Node Helpers + + - Nan::MakeCallback() + - NAN_MODULE_INIT() + - Nan::Export() + + + + + +### Tests + +To run the NAN tests do: + +``` sh +npm install +npm run-script rebuild-tests +npm test +``` + +Or just: + +``` sh +npm install +make test +``` + + +## Governance & Contributing + +NAN is governed by the [io.js](https://iojs.org/) Addon API Working Group + +### Addon API Working Group (WG) + +The NAN project is jointly governed by a Working Group which is responsible for high-level guidance of the project. + +Members of the WG are also known as Collaborators, there is no distinction between the two, unlike other io.js projects. + +The WG has final authority over this project including: + +* Technical direction +* Project governance and process (including this policy) +* Contribution policy +* GitHub repository hosting +* Maintaining the list of additional Collaborators + +For the current list of WG members, see the project [README.md](./README.md#collaborators). + +Individuals making significant and valuable contributions are made members of the WG and given commit-access to the project. These individuals are identified by the WG and their addition to the WG is discussed via GitHub and requires unanimous consensus amongst those WG members participating in the discussion with a quorum of 50% of WG members required for acceptance of the vote. + +_Note:_ If you make a significant contribution and are not considered for commit-access log an issue or contact a WG member directly. + +For the current list of WG members / Collaborators, see the project [README.md](./README.md#collaborators). + +### Consensus Seeking Process + +The WG follows a [Consensus Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model. + +Modifications of the contents of the NAN repository are made on a collaborative basis. Anybody with a GitHub account may propose a modification via pull request and it will be considered by the WG. All pull requests must be reviewed and accepted by a WG member with sufficient expertise who is able to take full responsibility for the change. In the case of pull requests proposed by an existing WG member, an additional WG member is required for sign-off. Consensus should be sought if additional WG members participate and there is disagreement around a particular modification. + +If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins. + + +## Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +* (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +* (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +* (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +* (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. + + +### WG Members / Collaborators + + + + + + + + + +
    Rod VaggGitHub/rvaggTwitter/@rvagg
    Benjamin ByholmGitHub/kkoopa-
    Trevor NorrisGitHub/trevnorrisTwitter/@trevnorris
    Nathan RajlichGitHub/TooTallNateTwitter/@TooTallNate
    Brett LawsonGitHub/brett19Twitter/@brett19x
    Ben NoordhuisGitHub/bnoordhuisTwitter/@bnoordhuis
    David SiegelGitHub/agnat-
    + +## Licence & copyright + +Copyright (c) 2016 NAN WG Members / Collaborators (listed above). + +Native Abstractions for Node.js is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. diff --git a/test/gc/node_modules/nan/include_dirs.js b/test/gc/node_modules/nan/include_dirs.js new file mode 100644 index 00000000000000..4f1dfb41667b9b --- /dev/null +++ b/test/gc/node_modules/nan/include_dirs.js @@ -0,0 +1 @@ +console.log(require('path').relative('.', __dirname)); diff --git a/test/gc/node_modules/nan/nan.h b/test/gc/node_modules/nan/nan.h new file mode 100644 index 00000000000000..3fc68cbe26a5e3 --- /dev/null +++ b/test/gc/node_modules/nan/nan.h @@ -0,0 +1,2271 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors: + * - Rod Vagg + * - Benjamin Byholm + * - Trevor Norris + * - Nathan Rajlich + * - Brett Lawson + * - Ben Noordhuis + * - David Siegel + * + * MIT License + * + * Version 2.3.3: current Node 6.0.0, Node 12: 0.12.13, Node 10: 0.10.44, iojs: 3.3.1 + * + * See https://github.com/nodejs/nan for the latest update to this file + **********************************************************************************/ + +#ifndef NAN_H_ +#define NAN_H_ + +#include + +#define NODE_0_10_MODULE_VERSION 11 +#define NODE_0_12_MODULE_VERSION 14 +#define ATOM_0_21_MODULE_VERSION 41 +#define IOJS_1_0_MODULE_VERSION 42 +#define IOJS_1_1_MODULE_VERSION 43 +#define IOJS_2_0_MODULE_VERSION 44 +#define IOJS_3_0_MODULE_VERSION 45 +#define NODE_4_0_MODULE_VERSION 46 +#define NODE_5_0_MODULE_VERSION 47 +#define NODE_6_0_MODULE_VERSION 48 + +#ifdef _MSC_VER +# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800) +#else +# define NAN_HAS_CPLUSPLUS_11 (__cplusplus >= 201103L) +#endif + +#if NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION && !NAN_HAS_CPLUSPLUS_11 +# error This version of node/NAN/v8 requires a C++11 compiler +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(_MSC_VER) +# pragma warning( push ) +# pragma warning( disable : 4530 ) +# include +# include +# pragma warning( pop ) +#else +# include +# include +#endif + +// uv helpers +#ifdef UV_VERSION_MAJOR +# ifndef UV_VERSION_PATCH +# define UV_VERSION_PATCH 0 +# endif +# define NAUV_UVVERSION ((UV_VERSION_MAJOR << 16) | \ + (UV_VERSION_MINOR << 8) | \ + (UV_VERSION_PATCH)) +#else +# define NAUV_UVVERSION 0x000b00 +#endif + +#if NAUV_UVVERSION < 0x000b0b +# ifdef WIN32 +# include +# else +# include +# endif +#endif + +namespace Nan { + +#if defined(__GNUC__) && !(defined(DEBUG) && DEBUG) +# define NAN_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) && !(defined(DEBUG) && DEBUG) +# define NAN_INLINE __forceinline +#else +# define NAN_INLINE inline +#endif + +#if defined(__GNUC__) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) +# define NAN_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) && \ + !(defined(V8_DISABLE_DEPRECATIONS) && V8_DISABLE_DEPRECATIONS) +# define NAN_DEPRECATED __declspec(deprecated) +#else +# define NAN_DEPRECATED +#endif + +#if NAN_HAS_CPLUSPLUS_11 +# define NAN_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&) = delete; +# define NAN_DISALLOW_COPY(CLASS) CLASS(const CLASS&) = delete; +# define NAN_DISALLOW_MOVE(CLASS) \ + CLASS(CLASS&&) = delete; /* NOLINT(build/c++11) */ \ + void operator=(CLASS&&) = delete; +#else +# define NAN_DISALLOW_ASSIGN(CLASS) void operator=(const CLASS&); +# define NAN_DISALLOW_COPY(CLASS) CLASS(const CLASS&); +# define NAN_DISALLOW_MOVE(CLASS) +#endif + +#define NAN_DISALLOW_ASSIGN_COPY(CLASS) \ + NAN_DISALLOW_ASSIGN(CLASS) \ + NAN_DISALLOW_COPY(CLASS) + +#define NAN_DISALLOW_ASSIGN_MOVE(CLASS) \ + NAN_DISALLOW_ASSIGN(CLASS) \ + NAN_DISALLOW_MOVE(CLASS) + +#define NAN_DISALLOW_COPY_MOVE(CLASS) \ + NAN_DISALLOW_COPY(CLASS) \ + NAN_DISALLOW_MOVE(CLASS) + +#define NAN_DISALLOW_ASSIGN_COPY_MOVE(CLASS) \ + NAN_DISALLOW_ASSIGN(CLASS) \ + NAN_DISALLOW_COPY(CLASS) \ + NAN_DISALLOW_MOVE(CLASS) + +#define TYPE_CHECK(T, S) \ + while (false) { \ + *(static_cast(0)) = static_cast(0); \ + } + +//=== RegistrationFunction ===================================================== + +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + typedef v8::Handle ADDON_REGISTER_FUNCTION_ARGS_TYPE; +#else + typedef v8::Local ADDON_REGISTER_FUNCTION_ARGS_TYPE; +#endif + +#define NAN_MODULE_INIT(name) \ + void name(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) + +//=== CallbackInfo ============================================================= + +#include "nan_callbacks.h" // NOLINT(build/include) + +//============================================================================== + +#if (NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION) +typedef v8::Script UnboundScript; +typedef v8::Script BoundScript; +#else +typedef v8::UnboundScript UnboundScript; +typedef v8::Script BoundScript; +#endif + +#if (NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION) +typedef v8::String::ExternalAsciiStringResource + ExternalOneByteStringResource; +#else +typedef v8::String::ExternalOneByteStringResource + ExternalOneByteStringResource; +#endif + +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) +template +class NonCopyablePersistentTraits : + public v8::NonCopyablePersistentTraits {}; +template +class CopyablePersistentTraits : + public v8::CopyablePersistentTraits {}; + +template +class PersistentBase : + public v8::PersistentBase {}; + +template > +class Persistent; +#else +template class NonCopyablePersistentTraits; +template class PersistentBase; +template class WeakCallbackData; +template > +class Persistent; +#endif // NODE_MODULE_VERSION + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +# include "nan_maybe_43_inl.h" // NOLINT(build/include) +#else +# include "nan_maybe_pre_43_inl.h" // NOLINT(build/include) +#endif + +#include "nan_converters.h" // NOLINT(build/include) +#include "nan_new.h" // NOLINT(build/include) + +#if NAUV_UVVERSION < 0x000b17 +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async, int) +#else +#define NAUV_WORK_CB(func) \ + void func(uv_async_t *async) +#endif + +#if NAUV_UVVERSION >= 0x000b0b + +typedef uv_key_t nauv_key_t; + +inline int nauv_key_create(nauv_key_t *key) { + return uv_key_create(key); +} + +inline void nauv_key_delete(nauv_key_t *key) { + uv_key_delete(key); +} + +inline void* nauv_key_get(nauv_key_t *key) { + return uv_key_get(key); +} + +inline void nauv_key_set(nauv_key_t *key, void *value) { + uv_key_set(key, value); +} + +#else + +/* Implement thread local storage for older versions of libuv. + * This is essentially a backport of libuv commit 5d2434bf + * written by Ben Noordhuis, adjusted for names and inline. + */ + +#ifndef WIN32 + +typedef pthread_key_t nauv_key_t; + +inline int nauv_key_create(nauv_key_t* key) { + return -pthread_key_create(key, NULL); +} + +inline void nauv_key_delete(nauv_key_t* key) { + if (pthread_key_delete(*key)) + abort(); +} + +inline void* nauv_key_get(nauv_key_t* key) { + return pthread_getspecific(*key); +} + +inline void nauv_key_set(nauv_key_t* key, void* value) { + if (pthread_setspecific(*key, value)) + abort(); +} + +#else + +typedef struct { + DWORD tls_index; +} nauv_key_t; + +inline int nauv_key_create(nauv_key_t* key) { + key->tls_index = TlsAlloc(); + if (key->tls_index == TLS_OUT_OF_INDEXES) + return UV_ENOMEM; + return 0; +} + +inline void nauv_key_delete(nauv_key_t* key) { + if (TlsFree(key->tls_index) == FALSE) + abort(); + key->tls_index = TLS_OUT_OF_INDEXES; +} + +inline void* nauv_key_get(nauv_key_t* key) { + void* value = TlsGetValue(key->tls_index); + if (value == NULL) + if (GetLastError() != ERROR_SUCCESS) + abort(); + return value; +} + +inline void nauv_key_set(nauv_key_t* key, void* value) { + if (TlsSetValue(key->tls_index, value) == FALSE) + abort(); +} + +#endif +#endif + +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION +template +v8::Local New(v8::Handle); +#endif + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + typedef v8::WeakCallbackType WeakCallbackType; +#else +struct WeakCallbackType { + enum E {kParameter, kInternalFields}; + E type; + WeakCallbackType(E other) : type(other) {} // NOLINT(runtime/explicit) + inline bool operator==(E other) { return other == this->type; } + inline bool operator!=(E other) { return !operator==(other); } +}; +#endif + +template class WeakCallbackInfo; + +#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION +# include "nan_persistent_12_inl.h" // NOLINT(build/include) +#else +# include "nan_persistent_pre_12_inl.h" // NOLINT(build/include) +#endif + +namespace imp { + static const size_t kMaxLength = 0x3fffffff; + // v8::String::REPLACE_INVALID_UTF8 was introduced + // in node.js v0.10.29 and v0.8.27. +#if NODE_MAJOR_VERSION > 0 || \ + NODE_MINOR_VERSION > 10 || \ + NODE_MINOR_VERSION == 10 && NODE_PATCH_VERSION >= 29 || \ + NODE_MINOR_VERSION == 8 && NODE_PATCH_VERSION >= 27 + static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8; +#else + static const unsigned kReplaceInvalidUtf8 = 0; +#endif +} // end of namespace imp + +//=== HandleScope ============================================================== + +class HandleScope { + v8::HandleScope scope; + + public: +#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + inline HandleScope() : scope(v8::Isolate::GetCurrent()) {} + inline static int NumberOfHandles() { + return v8::HandleScope::NumberOfHandles(v8::Isolate::GetCurrent()); + } +#else + inline HandleScope() : scope() {} + inline static int NumberOfHandles() { + return v8::HandleScope::NumberOfHandles(); + } +#endif + + private: + // Make it hard to create heap-allocated or illegal handle scopes by + // disallowing certain operations. + HandleScope(const HandleScope &); + void operator=(const HandleScope &); + void *operator new(size_t size); + void operator delete(void *, size_t); +}; + +class EscapableHandleScope { + public: +#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + inline EscapableHandleScope() : scope(v8::Isolate::GetCurrent()) {} + + inline static int NumberOfHandles() { + return v8::EscapableHandleScope::NumberOfHandles(v8::Isolate::GetCurrent()); + } + + template + inline v8::Local Escape(v8::Local value) { + return scope.Escape(value); + } + + private: + v8::EscapableHandleScope scope; +#else + inline EscapableHandleScope() : scope() {} + + inline static int NumberOfHandles() { + return v8::HandleScope::NumberOfHandles(); + } + + template + inline v8::Local Escape(v8::Local value) { + return scope.Close(value); + } + + private: + v8::HandleScope scope; +#endif + + private: + // Make it hard to create heap-allocated or illegal handle scopes by + // disallowing certain operations. + EscapableHandleScope(const EscapableHandleScope &); + void operator=(const EscapableHandleScope &); + void *operator new(size_t size); + void operator delete(void *, size_t); +}; + +//=== TryCatch ================================================================= + +class TryCatch { + v8::TryCatch try_catch_; + friend void FatalException(const TryCatch&); + + public: +#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION + TryCatch() : try_catch_(v8::Isolate::GetCurrent()) {} +#endif + + NAN_INLINE bool HasCaught() const { return try_catch_.HasCaught(); } + + NAN_INLINE bool CanContinue() const { return try_catch_.CanContinue(); } + + NAN_INLINE v8::Local ReThrow() { +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + return New(try_catch_.ReThrow()); +#else + return try_catch_.ReThrow(); +#endif + } + + NAN_INLINE v8::Local Exception() const { + return try_catch_.Exception(); + } + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + NAN_INLINE v8::MaybeLocal StackTrace() const { + return try_catch_.StackTrace(GetCurrentContext()); + } +#else + NAN_INLINE MaybeLocal StackTrace() const { + return MaybeLocal(try_catch_.StackTrace()); + } +#endif + + NAN_INLINE v8::Local Message() const { + return try_catch_.Message(); + } + + NAN_INLINE void Reset() { try_catch_.Reset(); } + + NAN_INLINE void SetVerbose(bool value) { try_catch_.SetVerbose(value); } + + NAN_INLINE void SetCaptureMessage(bool value) { + try_catch_.SetCaptureMessage(value); + } +}; + +//============ ================================================================= + +/* node 0.12 */ +#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION + NAN_INLINE + void SetCounterFunction(v8::CounterLookupCallback cb) { + v8::Isolate::GetCurrent()->SetCounterFunction(cb); + } + + NAN_INLINE + void SetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::Isolate::GetCurrent()->SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb); + } + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + NAN_INLINE bool IdleNotification(int idle_time_in_ms) { + return v8::Isolate::GetCurrent()->IdleNotificationDeadline( + idle_time_in_ms * 0.001); + } +# else + NAN_INLINE bool IdleNotification(int idle_time_in_ms) { + return v8::Isolate::GetCurrent()->IdleNotification(idle_time_in_ms); + } +#endif + + NAN_INLINE void LowMemoryNotification() { + v8::Isolate::GetCurrent()->LowMemoryNotification(); + } + + NAN_INLINE void ContextDisposedNotification() { + v8::Isolate::GetCurrent()->ContextDisposedNotification(); + } +#else + NAN_INLINE + void SetCounterFunction(v8::CounterLookupCallback cb) { + v8::V8::SetCounterFunction(cb); + } + + NAN_INLINE + void SetCreateHistogramFunction(v8::CreateHistogramCallback cb) { + v8::V8::SetCreateHistogramFunction(cb); + } + + NAN_INLINE + void SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) { + v8::V8::SetAddHistogramSampleFunction(cb); + } + + NAN_INLINE bool IdleNotification(int idle_time_in_ms) { + return v8::V8::IdleNotification(idle_time_in_ms); + } + + NAN_INLINE void LowMemoryNotification() { + v8::V8::LowMemoryNotification(); + } + + NAN_INLINE void ContextDisposedNotification() { + v8::V8::ContextDisposedNotification(); + } +#endif + +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) // Node 0.12 + NAN_INLINE v8::Local Undefined() { +# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + EscapableHandleScope scope; + return scope.Escape(New(v8::Undefined(v8::Isolate::GetCurrent()))); +# else + return v8::Undefined(v8::Isolate::GetCurrent()); +# endif + } + + NAN_INLINE v8::Local Null() { +# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + EscapableHandleScope scope; + return scope.Escape(New(v8::Null(v8::Isolate::GetCurrent()))); +# else + return v8::Null(v8::Isolate::GetCurrent()); +# endif + } + + NAN_INLINE v8::Local True() { +# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + EscapableHandleScope scope; + return scope.Escape(New(v8::True(v8::Isolate::GetCurrent()))); +# else + return v8::True(v8::Isolate::GetCurrent()); +# endif + } + + NAN_INLINE v8::Local False() { +# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + EscapableHandleScope scope; + return scope.Escape(New(v8::False(v8::Isolate::GetCurrent()))); +# else + return v8::False(v8::Isolate::GetCurrent()); +# endif + } + + NAN_INLINE v8::Local EmptyString() { + return v8::String::Empty(v8::Isolate::GetCurrent()); + } + + NAN_INLINE int AdjustExternalMemory(int bc) { + return static_cast( + v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(bc)); + } + + NAN_INLINE void SetTemplate( + v8::Local templ + , const char *name + , v8::Local value) { + templ->Set(v8::Isolate::GetCurrent(), name, value); + } + + NAN_INLINE void SetTemplate( + v8::Local templ + , v8::Local name + , v8::Local value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); + } + + NAN_INLINE v8::Local GetCurrentContext() { + return v8::Isolate::GetCurrent()->GetCurrentContext(); + } + + NAN_INLINE void* GetInternalFieldPointer( + v8::Local object + , int index) { + return object->GetAlignedPointerFromInternalField(index); + } + + NAN_INLINE void SetInternalFieldPointer( + v8::Local object + , int index + , void* value) { + object->SetAlignedPointerInInternalField(index, value); + } + +# define NAN_GC_CALLBACK(name) \ + void name(v8::Isolate *isolate, v8::GCType type, v8::GCCallbackFlags flags) + +#if NODE_MODULE_VERSION <= NODE_4_0_MODULE_VERSION + typedef v8::Isolate::GCEpilogueCallback GCEpilogueCallback; + typedef v8::Isolate::GCPrologueCallback GCPrologueCallback; +#else + typedef v8::Isolate::GCCallback GCEpilogueCallback; + typedef v8::Isolate::GCCallback GCPrologueCallback; +#endif + + NAN_INLINE void AddGCEpilogueCallback( + GCEpilogueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::Isolate::GetCurrent()->AddGCEpilogueCallback(callback, gc_type_filter); + } + + NAN_INLINE void RemoveGCEpilogueCallback( + GCEpilogueCallback callback) { + v8::Isolate::GetCurrent()->RemoveGCEpilogueCallback(callback); + } + + NAN_INLINE void AddGCPrologueCallback( + GCPrologueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::Isolate::GetCurrent()->AddGCPrologueCallback(callback, gc_type_filter); + } + + NAN_INLINE void RemoveGCPrologueCallback( + GCPrologueCallback callback) { + v8::Isolate::GetCurrent()->RemoveGCPrologueCallback(callback); + } + + NAN_INLINE void GetHeapStatistics( + v8::HeapStatistics *heap_statistics) { + v8::Isolate::GetCurrent()->GetHeapStatistics(heap_statistics); + } + +# define X(NAME) \ + NAN_INLINE v8::Local NAME(const char *msg) { \ + EscapableHandleScope scope; \ + return scope.Escape(v8::Exception::NAME(New(msg).ToLocalChecked())); \ + } \ + \ + NAN_INLINE \ + v8::Local NAME(v8::Local msg) { \ + return v8::Exception::NAME(msg); \ + } \ + \ + NAN_INLINE void Throw ## NAME(const char *msg) { \ + HandleScope scope; \ + v8::Isolate::GetCurrent()->ThrowException( \ + v8::Exception::NAME(New(msg).ToLocalChecked())); \ + } \ + \ + NAN_INLINE void Throw ## NAME(v8::Local msg) { \ + HandleScope scope; \ + v8::Isolate::GetCurrent()->ThrowException( \ + v8::Exception::NAME(msg)); \ + } + + X(Error) + X(RangeError) + X(ReferenceError) + X(SyntaxError) + X(TypeError) + +# undef X + + NAN_INLINE void ThrowError(v8::Local error) { + v8::Isolate::GetCurrent()->ThrowException(error); + } + + NAN_INLINE MaybeLocal NewBuffer( + char *data + , size_t length +#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION + , node::Buffer::FreeCallback callback +#else + , node::smalloc::FreeCallback callback +#endif + , void *hint + ) { + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(length <= imp::kMaxLength && "too large buffer"); +#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION + return node::Buffer::New( + v8::Isolate::GetCurrent(), data, length, callback, hint); +#else + return MaybeLocal(node::Buffer::New( + v8::Isolate::GetCurrent(), data, length, callback, hint)); +#endif + } + + NAN_INLINE MaybeLocal CopyBuffer( + const char *data + , uint32_t size + ) { + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(size <= imp::kMaxLength && "too large buffer"); +#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION + return node::Buffer::Copy( + v8::Isolate::GetCurrent(), data, size); +#else + return MaybeLocal(node::Buffer::New( + v8::Isolate::GetCurrent(), data, size)); +#endif + } + + NAN_INLINE MaybeLocal NewBuffer(uint32_t size) { + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(size <= imp::kMaxLength && "too large buffer"); +#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION + return node::Buffer::New( + v8::Isolate::GetCurrent(), size); +#else + return MaybeLocal(node::Buffer::New( + v8::Isolate::GetCurrent(), size)); +#endif + } + + NAN_INLINE MaybeLocal NewBuffer( + char* data + , uint32_t size + ) { + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(size <= imp::kMaxLength && "too large buffer"); +#if NODE_MODULE_VERSION > IOJS_2_0_MODULE_VERSION + return node::Buffer::New(v8::Isolate::GetCurrent(), data, size); +#else + return MaybeLocal( + node::Buffer::Use(v8::Isolate::GetCurrent(), data, size)); +#endif + } + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + NAN_INLINE MaybeLocal + NewOneByteString(const uint8_t * value, int length = -1) { + return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), value, + v8::NewStringType::kNormal, length); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + , const v8::ScriptOrigin& origin + ) { + v8::ScriptCompiler::Source source(s, origin); + return v8::ScriptCompiler::Compile(GetCurrentContext(), &source); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + ) { + v8::ScriptCompiler::Source source(s); + return v8::ScriptCompiler::Compile(GetCurrentContext(), &source); + } + + NAN_INLINE MaybeLocal RunScript( + v8::Local script + ) { + return script->BindToCurrentContext()->Run(GetCurrentContext()); + } + + NAN_INLINE MaybeLocal RunScript( + v8::Local script + ) { + return script->Run(GetCurrentContext()); + } +#else + NAN_INLINE MaybeLocal + NewOneByteString(const uint8_t * value, int length = -1) { + return MaybeLocal( + v8::String::NewFromOneByte( + v8::Isolate::GetCurrent() + , value + , v8::String::kNormalString, length)); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + , const v8::ScriptOrigin& origin + ) { + v8::ScriptCompiler::Source source(s, origin); + return MaybeLocal( + v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source)); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + ) { + v8::ScriptCompiler::Source source(s); + return MaybeLocal( + v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source)); + } + + NAN_INLINE MaybeLocal RunScript( + v8::Local script + ) { + return MaybeLocal(script->BindToCurrentContext()->Run()); + } + + NAN_INLINE MaybeLocal RunScript( + v8::Local script + ) { + return MaybeLocal(script->Run()); + } +#endif + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , v8::Local func + , int argc + , v8::Local* argv) { +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + return New(node::MakeCallback( + v8::Isolate::GetCurrent(), target, func, argc, argv)); +#else + return node::MakeCallback( + v8::Isolate::GetCurrent(), target, func, argc, argv); +#endif + } + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , v8::Local symbol + , int argc + , v8::Local* argv) { +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + return New(node::MakeCallback( + v8::Isolate::GetCurrent(), target, symbol, argc, argv)); +#else + return node::MakeCallback( + v8::Isolate::GetCurrent(), target, symbol, argc, argv); +#endif + } + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , const char* method + , int argc + , v8::Local* argv) { +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + return New(node::MakeCallback( + v8::Isolate::GetCurrent(), target, method, argc, argv)); +#else + return node::MakeCallback( + v8::Isolate::GetCurrent(), target, method, argc, argv); +#endif + } + + NAN_INLINE void FatalException(const TryCatch& try_catch) { + node::FatalException(v8::Isolate::GetCurrent(), try_catch.try_catch_); + } + + NAN_INLINE v8::Local ErrnoException( + int errorno + , const char* syscall = NULL + , const char* message = NULL + , const char* path = NULL) { + return node::ErrnoException(v8::Isolate::GetCurrent(), errorno, syscall, + message, path); + } + + NAN_DEPRECATED NAN_INLINE v8::Local NanErrnoException( + int errorno + , const char* syscall = NULL + , const char* message = NULL + , const char* path = NULL) { + return ErrnoException(errorno, syscall, message, path); + } + + template + NAN_INLINE void SetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(0, data); + } + + template + NAN_INLINE T *GetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData(0)); + } + +class Utf8String { + public: + NAN_INLINE explicit Utf8String(v8::Local from) : + length_(0), str_(str_st_) { + if (!from.IsEmpty()) { + v8::Local string = from->ToString(); + if (!string.IsEmpty()) { + size_t len = 3 * string->Length() + 1; + assert(len <= INT_MAX); + if (len > sizeof (str_st_)) { + str_ = static_cast(malloc(len)); + assert(str_ != 0); + } + const int flags = + v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; + length_ = string->WriteUtf8(str_, static_cast(len), 0, flags); + str_[length_] = '\0'; + } + } + } + + NAN_INLINE int length() const { + return length_; + } + + NAN_INLINE char* operator*() { return str_; } + NAN_INLINE const char* operator*() const { return str_; } + + NAN_INLINE ~Utf8String() { + if (str_ != str_st_) { + free(str_); + } + } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(Utf8String) + + int length_; + char *str_; + char str_st_[1024]; +}; + +#else // Node 0.8 and 0.10 + NAN_INLINE v8::Local Undefined() { + EscapableHandleScope scope; + return scope.Escape(New(v8::Undefined())); + } + + NAN_INLINE v8::Local Null() { + EscapableHandleScope scope; + return scope.Escape(New(v8::Null())); + } + + NAN_INLINE v8::Local True() { + EscapableHandleScope scope; + return scope.Escape(New(v8::True())); + } + + NAN_INLINE v8::Local False() { + EscapableHandleScope scope; + return scope.Escape(New(v8::False())); + } + + NAN_INLINE v8::Local EmptyString() { + return v8::String::Empty(); + } + + NAN_INLINE int AdjustExternalMemory(int bc) { + return static_cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(bc)); + } + + NAN_INLINE void SetTemplate( + v8::Local templ + , const char *name + , v8::Local value) { + templ->Set(name, value); + } + + NAN_INLINE void SetTemplate( + v8::Local templ + , v8::Local name + , v8::Local value + , v8::PropertyAttribute attributes) { + templ->Set(name, value, attributes); + } + + NAN_INLINE v8::Local GetCurrentContext() { + return v8::Context::GetCurrent(); + } + + NAN_INLINE void* GetInternalFieldPointer( + v8::Local object + , int index) { + return object->GetPointerFromInternalField(index); + } + + NAN_INLINE void SetInternalFieldPointer( + v8::Local object + , int index + , void* value) { + object->SetPointerInInternalField(index, value); + } + +# define NAN_GC_CALLBACK(name) \ + void name(v8::GCType type, v8::GCCallbackFlags flags) + + NAN_INLINE void AddGCEpilogueCallback( + v8::GCEpilogueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::V8::AddGCEpilogueCallback(callback, gc_type_filter); + } + NAN_INLINE void RemoveGCEpilogueCallback( + v8::GCEpilogueCallback callback) { + v8::V8::RemoveGCEpilogueCallback(callback); + } + NAN_INLINE void AddGCPrologueCallback( + v8::GCPrologueCallback callback + , v8::GCType gc_type_filter = v8::kGCTypeAll) { + v8::V8::AddGCPrologueCallback(callback, gc_type_filter); + } + NAN_INLINE void RemoveGCPrologueCallback( + v8::GCPrologueCallback callback) { + v8::V8::RemoveGCPrologueCallback(callback); + } + NAN_INLINE void GetHeapStatistics( + v8::HeapStatistics *heap_statistics) { + v8::V8::GetHeapStatistics(heap_statistics); + } + +# define X(NAME) \ + NAN_INLINE v8::Local NAME(const char *msg) { \ + EscapableHandleScope scope; \ + return scope.Escape(v8::Exception::NAME(New(msg).ToLocalChecked())); \ + } \ + \ + NAN_INLINE \ + v8::Local NAME(v8::Local msg) { \ + return v8::Exception::NAME(msg); \ + } \ + \ + NAN_INLINE void Throw ## NAME(const char *msg) { \ + HandleScope scope; \ + v8::ThrowException(v8::Exception::NAME(New(msg).ToLocalChecked())); \ + } \ + \ + NAN_INLINE \ + void Throw ## NAME(v8::Local errmsg) { \ + v8::ThrowException(v8::Exception::NAME(errmsg)); \ + } + + X(Error) + X(RangeError) + X(ReferenceError) + X(SyntaxError) + X(TypeError) + +# undef X + + NAN_INLINE void ThrowError(v8::Local error) { + v8::ThrowException(error); + } + + NAN_INLINE MaybeLocal NewBuffer( + char *data + , size_t length + , node::Buffer::free_callback callback + , void *hint + ) { + EscapableHandleScope scope; + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(length <= imp::kMaxLength && "too large buffer"); + return MaybeLocal(scope.Escape( + New(node::Buffer::New(data, length, callback, hint)->handle_))); + } + + NAN_INLINE MaybeLocal CopyBuffer( + const char *data + , uint32_t size + ) { + EscapableHandleScope scope; + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(size <= imp::kMaxLength && "too large buffer"); +#if NODE_MODULE_VERSION >= NODE_0_10_MODULE_VERSION + return MaybeLocal( + scope.Escape(New(node::Buffer::New(data, size)->handle_))); +#else + return MaybeLocal(scope.Escape( + New(node::Buffer::New(const_cast(data), size)->handle_))); +#endif + } + + NAN_INLINE MaybeLocal NewBuffer(uint32_t size) { + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + EscapableHandleScope scope; + assert(size <= imp::kMaxLength && "too large buffer"); + return MaybeLocal( + scope.Escape(New(node::Buffer::New(size)->handle_))); + } + + NAN_INLINE void FreeData(char *data, void *hint) { + (void) hint; // unused + delete[] data; + } + + NAN_INLINE MaybeLocal NewBuffer( + char* data + , uint32_t size + ) { + EscapableHandleScope scope; + // arbitrary buffer lengths requires + // NODE_MODULE_VERSION >= IOJS_3_0_MODULE_VERSION + assert(size <= imp::kMaxLength && "too large buffer"); + return MaybeLocal(scope.Escape(New( + node::Buffer::New(data, size, FreeData, NULL)->handle_))); + } + +namespace imp { +NAN_INLINE void +widenString(std::vector *ws, const uint8_t *s, int l) { + size_t len = static_cast(l); + if (l < 0) { + len = strlen(reinterpret_cast(s)); + } + assert(len <= INT_MAX && "string too long"); + ws->resize(len); + std::copy(s, s + len, ws->begin()); // NOLINT(build/include_what_you_use) +} +} // end of namespace imp + + NAN_INLINE MaybeLocal + NewOneByteString(const uint8_t * value, int length = -1) { + std::vector wideString; // NOLINT(build/include_what_you_use) + imp::widenString(&wideString, value, length); + return imp::Factory::return_t(v8::String::New( + &wideString.front(), static_cast(wideString.size()))); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + , const v8::ScriptOrigin& origin + ) { + return MaybeLocal( + v8::Script::Compile(s, const_cast(&origin))); + } + + NAN_INLINE MaybeLocal CompileScript( + v8::Local s + ) { + return MaybeLocal(v8::Script::Compile(s)); + } + + NAN_INLINE + MaybeLocal RunScript(v8::Local script) { + return MaybeLocal(script->Run()); + } + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , v8::Local func + , int argc + , v8::Local* argv) { + return New(node::MakeCallback(target, func, argc, argv)); + } + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , v8::Local symbol + , int argc + , v8::Local* argv) { + return New(node::MakeCallback(target, symbol, argc, argv)); + } + + NAN_INLINE v8::Local MakeCallback( + v8::Local target + , const char* method + , int argc + , v8::Local* argv) { + return New(node::MakeCallback(target, method, argc, argv)); + } + + NAN_INLINE void FatalException(const TryCatch& try_catch) { + node::FatalException(const_cast(try_catch.try_catch_)); + } + + NAN_INLINE v8::Local ErrnoException( + int errorno + , const char* syscall = NULL + , const char* message = NULL + , const char* path = NULL) { + return node::ErrnoException(errorno, syscall, message, path); + } + + NAN_DEPRECATED NAN_INLINE v8::Local NanErrnoException( + int errorno + , const char* syscall = NULL + , const char* message = NULL + , const char* path = NULL) { + return ErrnoException(errorno, syscall, message, path); + } + + + template + NAN_INLINE void SetIsolateData( + v8::Isolate *isolate + , T *data + ) { + isolate->SetData(data); + } + + template + NAN_INLINE T *GetIsolateData( + v8::Isolate *isolate + ) { + return static_cast(isolate->GetData()); + } + +class Utf8String { + public: + NAN_INLINE explicit Utf8String(v8::Local from) : + length_(0), str_(str_st_) { + if (!from.IsEmpty()) { + v8::Local string = from->ToString(); + if (!string.IsEmpty()) { + size_t len = 3 * string->Length() + 1; + assert(len <= INT_MAX); + if (len > sizeof (str_st_)) { + str_ = static_cast(malloc(len)); + assert(str_ != 0); + } + const int flags = + v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; + length_ = string->WriteUtf8(str_, static_cast(len), 0, flags); + str_[length_] = '\0'; + } + } + } + + NAN_INLINE int length() const { + return length_; + } + + NAN_INLINE char* operator*() { return str_; } + NAN_INLINE const char* operator*() const { return str_; } + + NAN_INLINE ~Utf8String() { + if (str_ != str_st_) { + free(str_); + } + } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(Utf8String) + + int length_; + char *str_; + char str_st_[1024]; +}; + +#endif // NODE_MODULE_VERSION + +typedef void (*FreeCallback)(char *data, void *hint); + +typedef const FunctionCallbackInfo& NAN_METHOD_ARGS_TYPE; +typedef void NAN_METHOD_RETURN_TYPE; + +typedef const PropertyCallbackInfo& NAN_GETTER_ARGS_TYPE; +typedef void NAN_GETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& NAN_SETTER_ARGS_TYPE; +typedef void NAN_SETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_PROPERTY_GETTER_ARGS_TYPE; +typedef void NAN_PROPERTY_GETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_PROPERTY_SETTER_ARGS_TYPE; +typedef void NAN_PROPERTY_SETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_PROPERTY_ENUMERATOR_ARGS_TYPE; +typedef void NAN_PROPERTY_ENUMERATOR_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_PROPERTY_DELETER_ARGS_TYPE; +typedef void NAN_PROPERTY_DELETER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_PROPERTY_QUERY_ARGS_TYPE; +typedef void NAN_PROPERTY_QUERY_RETURN_TYPE; + +typedef const PropertyCallbackInfo& NAN_INDEX_GETTER_ARGS_TYPE; +typedef void NAN_INDEX_GETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& NAN_INDEX_SETTER_ARGS_TYPE; +typedef void NAN_INDEX_SETTER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_INDEX_ENUMERATOR_ARGS_TYPE; +typedef void NAN_INDEX_ENUMERATOR_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_INDEX_DELETER_ARGS_TYPE; +typedef void NAN_INDEX_DELETER_RETURN_TYPE; + +typedef const PropertyCallbackInfo& + NAN_INDEX_QUERY_ARGS_TYPE; +typedef void NAN_INDEX_QUERY_RETURN_TYPE; + +#define NAN_METHOD(name) \ + Nan::NAN_METHOD_RETURN_TYPE name(Nan::NAN_METHOD_ARGS_TYPE info) +#define NAN_GETTER(name) \ + Nan::NAN_GETTER_RETURN_TYPE name( \ + v8::Local property \ + , Nan::NAN_GETTER_ARGS_TYPE info) +#define NAN_SETTER(name) \ + Nan::NAN_SETTER_RETURN_TYPE name( \ + v8::Local property \ + , v8::Local value \ + , Nan::NAN_SETTER_ARGS_TYPE info) +#define NAN_PROPERTY_GETTER(name) \ + Nan::NAN_PROPERTY_GETTER_RETURN_TYPE name( \ + v8::Local property \ + , Nan::NAN_PROPERTY_GETTER_ARGS_TYPE info) +#define NAN_PROPERTY_SETTER(name) \ + Nan::NAN_PROPERTY_SETTER_RETURN_TYPE name( \ + v8::Local property \ + , v8::Local value \ + , Nan::NAN_PROPERTY_SETTER_ARGS_TYPE info) +#define NAN_PROPERTY_ENUMERATOR(name) \ + Nan::NAN_PROPERTY_ENUMERATOR_RETURN_TYPE name( \ + Nan::NAN_PROPERTY_ENUMERATOR_ARGS_TYPE info) +#define NAN_PROPERTY_DELETER(name) \ + Nan::NAN_PROPERTY_DELETER_RETURN_TYPE name( \ + v8::Local property \ + , Nan::NAN_PROPERTY_DELETER_ARGS_TYPE info) +#define NAN_PROPERTY_QUERY(name) \ + Nan::NAN_PROPERTY_QUERY_RETURN_TYPE name( \ + v8::Local property \ + , Nan::NAN_PROPERTY_QUERY_ARGS_TYPE info) +# define NAN_INDEX_GETTER(name) \ + Nan::NAN_INDEX_GETTER_RETURN_TYPE name( \ + uint32_t index \ + , Nan::NAN_INDEX_GETTER_ARGS_TYPE info) +#define NAN_INDEX_SETTER(name) \ + Nan::NAN_INDEX_SETTER_RETURN_TYPE name( \ + uint32_t index \ + , v8::Local value \ + , Nan::NAN_INDEX_SETTER_ARGS_TYPE info) +#define NAN_INDEX_ENUMERATOR(name) \ + Nan::NAN_INDEX_ENUMERATOR_RETURN_TYPE \ + name(Nan::NAN_INDEX_ENUMERATOR_ARGS_TYPE info) +#define NAN_INDEX_DELETER(name) \ + Nan::NAN_INDEX_DELETER_RETURN_TYPE name( \ + uint32_t index \ + , Nan::NAN_INDEX_DELETER_ARGS_TYPE info) +#define NAN_INDEX_QUERY(name) \ + Nan::NAN_INDEX_QUERY_RETURN_TYPE name( \ + uint32_t index \ + , Nan::NAN_INDEX_QUERY_ARGS_TYPE info) + +class Callback { + public: + Callback() { + HandleScope scope; + v8::Local obj = New(); + handle.Reset(obj); + } + + explicit Callback(const v8::Local &fn) { + HandleScope scope; + v8::Local obj = New(); + handle.Reset(obj); + SetFunction(fn); + } + + ~Callback() { + if (handle.IsEmpty()) return; + handle.Reset(); + } + + bool operator==(const Callback &other) const { + HandleScope scope; + v8::Local a = New(handle)->Get(kCallbackIndex); + v8::Local b = New(other.handle)->Get(kCallbackIndex); + return a->StrictEquals(b); + } + + bool operator!=(const Callback &other) const { + return !this->operator==(other); + } + + NAN_INLINE + v8::Local operator*() const { return this->GetFunction(); } + + NAN_INLINE v8::Local operator()( + v8::Local target + , int argc = 0 + , v8::Local argv[] = 0) const { + return this->Call(target, argc, argv); + } + + NAN_INLINE v8::Local operator()( + int argc = 0 + , v8::Local argv[] = 0) const { + return this->Call(argc, argv); + } + + NAN_INLINE void SetFunction(const v8::Local &fn) { + HandleScope scope; + Set(New(handle), kCallbackIndex, fn); + } + + NAN_INLINE v8::Local GetFunction() const { + EscapableHandleScope scope; + return scope.Escape(New(handle)->Get(kCallbackIndex) + .As()); + } + + NAN_INLINE bool IsEmpty() const { + HandleScope scope; + return New(handle)->Get(kCallbackIndex)->IsUndefined(); + } + + NAN_INLINE v8::Local + Call(v8::Local target + , int argc + , v8::Local argv[]) const { +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + return Call_(isolate, target, argc, argv); +#else + return Call_(target, argc, argv); +#endif + } + + NAN_INLINE v8::Local + Call(int argc, v8::Local argv[]) const { +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + return Call_(isolate, isolate->GetCurrentContext()->Global(), argc, argv); +#else + return Call_(v8::Context::GetCurrent()->Global(), argc, argv); +#endif + } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(Callback) + Persistent handle; + static const uint32_t kCallbackIndex = 0; + +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + v8::Local Call_(v8::Isolate *isolate + , v8::Local target + , int argc + , v8::Local argv[]) const { + EscapableHandleScope scope; + + v8::Local callback = New(handle)-> + Get(kCallbackIndex).As(); +# if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION + return scope.Escape(New(node::MakeCallback( + isolate + , target + , callback + , argc + , argv + ))); +# else + return scope.Escape(node::MakeCallback( + isolate + , target + , callback + , argc + , argv + )); +# endif + } +#else + v8::Local Call_(v8::Local target + , int argc + , v8::Local argv[]) const { + EscapableHandleScope scope; + + v8::Local callback = New(handle)-> + Get(kCallbackIndex).As(); + return scope.Escape(New(node::MakeCallback( + target + , callback + , argc + , argv + ))); + } +#endif +}; + +/* abstract */ class AsyncWorker { + public: + explicit AsyncWorker(Callback *callback_) + : callback(callback_), errmsg_(NULL) { + request.data = this; + + HandleScope scope; + v8::Local obj = New(); + persistentHandle.Reset(obj); + } + + virtual ~AsyncWorker() { + HandleScope scope; + + if (!persistentHandle.IsEmpty()) + persistentHandle.Reset(); + delete callback; + delete[] errmsg_; + } + + virtual void WorkComplete() { + HandleScope scope; + + if (errmsg_ == NULL) + HandleOKCallback(); + else + HandleErrorCallback(); + delete callback; + callback = NULL; + } + + NAN_INLINE void SaveToPersistent( + const char *key, const v8::Local &value) { + HandleScope scope; + New(persistentHandle)->Set(New(key).ToLocalChecked(), value); + } + + NAN_INLINE void SaveToPersistent( + const v8::Local &key, const v8::Local &value) { + HandleScope scope; + New(persistentHandle)->Set(key, value); + } + + NAN_INLINE void SaveToPersistent( + uint32_t index, const v8::Local &value) { + HandleScope scope; + New(persistentHandle)->Set(index, value); + } + + NAN_INLINE v8::Local GetFromPersistent(const char *key) const { + EscapableHandleScope scope; + return scope.Escape( + New(persistentHandle)->Get(New(key).ToLocalChecked())); + } + + NAN_INLINE v8::Local + GetFromPersistent(const v8::Local &key) const { + EscapableHandleScope scope; + return scope.Escape(New(persistentHandle)->Get(key)); + } + + NAN_INLINE v8::Local GetFromPersistent(uint32_t index) const { + EscapableHandleScope scope; + return scope.Escape(New(persistentHandle)->Get(index)); + } + + virtual void Execute() = 0; + + uv_work_t request; + + virtual void Destroy() { + delete this; + } + + protected: + Persistent persistentHandle; + Callback *callback; + + virtual void HandleOKCallback() { + callback->Call(0, NULL); + } + + virtual void HandleErrorCallback() { + HandleScope scope; + + v8::Local argv[] = { + v8::Exception::Error(New(ErrorMessage()).ToLocalChecked()) + }; + callback->Call(1, argv); + } + + void SetErrorMessage(const char *msg) { + delete[] errmsg_; + + size_t size = strlen(msg) + 1; + errmsg_ = new char[size]; + memcpy(errmsg_, msg, size); + } + + const char* ErrorMessage() const { + return errmsg_; + } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(AsyncWorker) + char *errmsg_; +}; + +/* abstract */ class AsyncProgressWorker : public AsyncWorker { + public: + explicit AsyncProgressWorker(Callback *callback_) + : AsyncWorker(callback_), asyncdata_(NULL), asyncsize_(0) { + async = new uv_async_t; + uv_async_init( + uv_default_loop() + , async + , AsyncProgress_ + ); + async->data = this; + + uv_mutex_init(&async_lock); + } + + virtual ~AsyncProgressWorker() { + uv_mutex_destroy(&async_lock); + + delete[] asyncdata_; + } + + void WorkProgress() { + uv_mutex_lock(&async_lock); + char *data = asyncdata_; + size_t size = asyncsize_; + asyncdata_ = NULL; + uv_mutex_unlock(&async_lock); + + // Dont send progress events after we've already completed. + if (callback) { + HandleProgressCallback(data, size); + } + delete[] data; + } + + class ExecutionProgress { + friend class AsyncProgressWorker; + public: + void Signal() const { + uv_async_send(that_->async); + } + // You could do fancy generics with templates here. + void Send(const char* data, size_t size) const { + that_->SendProgress_(data, size); + } + + private: + explicit ExecutionProgress(AsyncProgressWorker* that) : that_(that) {} + NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress) + AsyncProgressWorker* const that_; + }; + + virtual void Execute(const ExecutionProgress& progress) = 0; + virtual void HandleProgressCallback(const char *data, size_t size) = 0; + + virtual void Destroy() { + uv_close(reinterpret_cast(async), AsyncClose_); + } + + private: + void Execute() /*final override*/ { + ExecutionProgress progress(this); + Execute(progress); + } + + void SendProgress_(const char *data, size_t size) { + char *new_data = new char[size]; + memcpy(new_data, data, size); + + uv_mutex_lock(&async_lock); + char *old_data = asyncdata_; + asyncdata_ = new_data; + asyncsize_ = size; + uv_mutex_unlock(&async_lock); + + delete[] old_data; + uv_async_send(async); + } + + NAN_INLINE static NAUV_WORK_CB(AsyncProgress_) { + AsyncProgressWorker *worker = + static_cast(async->data); + worker->WorkProgress(); + } + + NAN_INLINE static void AsyncClose_(uv_handle_t* handle) { + AsyncProgressWorker *worker = + static_cast(handle->data); + delete reinterpret_cast(handle); + delete worker; + } + + uv_async_t *async; + uv_mutex_t async_lock; + char *asyncdata_; + size_t asyncsize_; +}; + +NAN_INLINE void AsyncExecute (uv_work_t* req) { + AsyncWorker *worker = static_cast(req->data); + worker->Execute(); +} + +NAN_INLINE void AsyncExecuteComplete (uv_work_t* req) { + AsyncWorker* worker = static_cast(req->data); + worker->WorkComplete(); + worker->Destroy(); +} + +NAN_INLINE void AsyncQueueWorker (AsyncWorker* worker) { + uv_queue_work( + uv_default_loop() + , &worker->request + , AsyncExecute + , reinterpret_cast(AsyncExecuteComplete) + ); +} + +namespace imp { + +inline +ExternalOneByteStringResource const* +GetExternalResource(v8::Local str) { +#if NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION + return str->GetExternalAsciiStringResource(); +#else + return str->GetExternalOneByteStringResource(); +#endif +} + +inline +bool +IsExternal(v8::Local str) { +#if NODE_MODULE_VERSION < ATOM_0_21_MODULE_VERSION + return str->IsExternalAscii(); +#else + return str->IsExternalOneByte(); +#endif +} + +} // end of namespace imp + +enum Encoding {ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER}; + +#if NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION +# include "nan_string_bytes.h" // NOLINT(build/include) +#endif + +NAN_INLINE v8::Local Encode( + const void *buf, size_t len, enum Encoding encoding = BINARY) { +#if (NODE_MODULE_VERSION >= ATOM_0_21_MODULE_VERSION) + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + node::encoding node_enc = static_cast(encoding); + + if (encoding == UCS2) { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len / 2); + } else { + return node::Encode( + isolate + , reinterpret_cast(buf) + , len + , node_enc); + } +#elif (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + return node::Encode( + v8::Isolate::GetCurrent() + , buf, len + , static_cast(encoding)); +#else +# if NODE_MODULE_VERSION >= NODE_0_10_MODULE_VERSION + return node::Encode(buf, len, static_cast(encoding)); +# else + return imp::Encode(reinterpret_cast(buf), len, encoding); +# endif +#endif +} + +NAN_INLINE ssize_t DecodeBytes( + v8::Local val, enum Encoding encoding = BINARY) { +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + return node::DecodeBytes( + v8::Isolate::GetCurrent() + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION) + if (encoding == BUFFER) { + return node::DecodeBytes(val, node::BINARY); + } +# endif + return node::DecodeBytes(val, static_cast(encoding)); +#endif +} + +NAN_INLINE ssize_t DecodeWrite( + char *buf + , size_t len + , v8::Local val + , enum Encoding encoding = BINARY) { +#if (NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION) + return node::DecodeWrite( + v8::Isolate::GetCurrent() + , buf + , len + , val + , static_cast(encoding)); +#else +# if (NODE_MODULE_VERSION < NODE_0_10_MODULE_VERSION) + if (encoding == BUFFER) { + return node::DecodeWrite(buf, len, val, node::BINARY); + } +# endif + return node::DecodeWrite( + buf + , len + , val + , static_cast(encoding)); +#endif +} + +NAN_INLINE void SetPrototypeTemplate( + v8::Local templ + , const char *name + , v8::Local value +) { + SetTemplate(templ->PrototypeTemplate(), name, value); +} + +NAN_INLINE void SetPrototypeTemplate( + v8::Local templ + , v8::Local name + , v8::Local value + , v8::PropertyAttribute attributes +) { + SetTemplate(templ->PrototypeTemplate(), name, value, attributes); +} + +NAN_INLINE void SetInstanceTemplate( + v8::Local templ + , const char *name + , v8::Local value +) { + SetTemplate(templ->InstanceTemplate(), name, value); +} + +NAN_INLINE void SetInstanceTemplate( + v8::Local templ + , v8::Local name + , v8::Local value + , v8::PropertyAttribute attributes +) { + SetTemplate(templ->InstanceTemplate(), name, value, attributes); +} + +namespace imp { + +// Note(@agnat): Helper to distinguish different receiver types. The first +// version deals with receivers derived from v8::Template. The second version +// handles everything else. The final argument only serves as discriminator and +// is unused. +template +NAN_INLINE +void +SetMethodAux(T recv, + v8::Local name, + v8::Local tpl, + v8::Template *) { + recv->Set(name, tpl); +} + +template +NAN_INLINE +void +SetMethodAux(T recv, + v8::Local name, + v8::Local tpl, + ...) { + recv->Set(name, GetFunction(tpl).ToLocalChecked()); +} + +} // end of namespace imp + +template class HandleType> +NAN_INLINE void SetMethod( + HandleType recv + , const char *name + , FunctionCallback callback) { + HandleScope scope; + v8::Local t = New(callback); + v8::Local fn_name = New(name).ToLocalChecked(); + t->SetClassName(fn_name); + // Note(@agnat): Pass an empty T* as discriminator. See note on + // SetMethodAux(...) above + imp::SetMethodAux(recv, fn_name, t, static_cast(0)); +} + +NAN_INLINE void SetPrototypeMethod( + v8::Local recv + , const char* name, FunctionCallback callback) { + HandleScope scope; + v8::Local t = New( + callback + , v8::Local() + , New(recv)); + v8::Local fn_name = New(name).ToLocalChecked(); + recv->PrototypeTemplate()->Set(fn_name, t); + t->SetClassName(fn_name); +} + +//=== Accessors and Such ======================================================= + +inline void SetAccessor( + v8::Local tpl + , v8::Local name + , GetterCallback getter + , SetterCallback setter = 0 + , v8::Local data = v8::Local() + , v8::AccessControl settings = v8::DEFAULT + , v8::PropertyAttribute attribute = v8::None + , imp::Sig signature = imp::Sig()) { + HandleScope scope; + + imp::NativeGetter getter_ = + imp::GetterCallbackWrapper; + imp::NativeSetter setter_ = + setter ? imp::SetterCallbackWrapper : 0; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kAccessorFieldCount); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); + + obj->SetInternalField( + imp::kGetterIndex + , New(reinterpret_cast(getter))); + + if (setter != 0) { + obj->SetInternalField( + imp::kSetterIndex + , New(reinterpret_cast(setter))); + } + + if (!data.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, data); + } + + tpl->SetAccessor( + name + , getter_ + , setter_ + , obj + , settings + , attribute + , signature); +} + +inline bool SetAccessor( + v8::Local obj + , v8::Local name + , GetterCallback getter + , SetterCallback setter = 0 + , v8::Local data = v8::Local() + , v8::AccessControl settings = v8::DEFAULT + , v8::PropertyAttribute attribute = v8::None) { + EscapableHandleScope scope; + + imp::NativeGetter getter_ = + imp::GetterCallbackWrapper; + imp::NativeSetter setter_ = + setter ? imp::SetterCallbackWrapper : 0; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kAccessorFieldCount); + v8::Local dataobj = NewInstance(otpl).ToLocalChecked(); + + dataobj->SetInternalField( + imp::kGetterIndex + , New(reinterpret_cast(getter))); + + if (!data.IsEmpty()) { + dataobj->SetInternalField(imp::kDataIndex, data); + } + + if (setter) { + dataobj->SetInternalField( + imp::kSetterIndex + , New(reinterpret_cast(setter))); + } + + return obj->SetAccessor( + name + , getter_ + , setter_ + , dataobj + , settings + , attribute); +} + +inline void SetNamedPropertyHandler( + v8::Local tpl + , PropertyGetterCallback getter + , PropertySetterCallback setter = 0 + , PropertyQueryCallback query = 0 + , PropertyDeleterCallback deleter = 0 + , PropertyEnumeratorCallback enumerator = 0 + , v8::Local data = v8::Local()) { + HandleScope scope; + + imp::NativePropertyGetter getter_ = + imp::PropertyGetterCallbackWrapper; + imp::NativePropertySetter setter_ = + setter ? imp::PropertySetterCallbackWrapper : 0; + imp::NativePropertyQuery query_ = + query ? imp::PropertyQueryCallbackWrapper : 0; + imp::NativePropertyDeleter *deleter_ = + deleter ? imp::PropertyDeleterCallbackWrapper : 0; + imp::NativePropertyEnumerator enumerator_ = + enumerator ? imp::PropertyEnumeratorCallbackWrapper : 0; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kPropertyFieldCount); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); + obj->SetInternalField( + imp::kPropertyGetterIndex + , New(reinterpret_cast(getter))); + + if (setter) { + obj->SetInternalField( + imp::kPropertySetterIndex + , New(reinterpret_cast(setter))); + } + + if (query) { + obj->SetInternalField( + imp::kPropertyQueryIndex + , New(reinterpret_cast(query))); + } + + if (deleter) { + obj->SetInternalField( + imp::kPropertyDeleterIndex + , New(reinterpret_cast(deleter))); + } + + if (enumerator) { + obj->SetInternalField( + imp::kPropertyEnumeratorIndex + , New(reinterpret_cast(enumerator))); + } + + if (!data.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, data); + } + +#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION + tpl->SetHandler(v8::NamedPropertyHandlerConfiguration( + getter_, setter_, query_, deleter_, enumerator_, obj)); +#else + tpl->SetNamedPropertyHandler( + getter_ + , setter_ + , query_ + , deleter_ + , enumerator_ + , obj); +#endif +} + +inline void SetIndexedPropertyHandler( + v8::Local tpl + , IndexGetterCallback getter + , IndexSetterCallback setter = 0 + , IndexQueryCallback query = 0 + , IndexDeleterCallback deleter = 0 + , IndexEnumeratorCallback enumerator = 0 + , v8::Local data = v8::Local()) { + HandleScope scope; + + imp::NativeIndexGetter getter_ = + imp::IndexGetterCallbackWrapper; + imp::NativeIndexSetter setter_ = + setter ? imp::IndexSetterCallbackWrapper : 0; + imp::NativeIndexQuery query_ = + query ? imp::IndexQueryCallbackWrapper : 0; + imp::NativeIndexDeleter deleter_ = + deleter ? imp::IndexDeleterCallbackWrapper : 0; + imp::NativeIndexEnumerator enumerator_ = + enumerator ? imp::IndexEnumeratorCallbackWrapper : 0; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kIndexPropertyFieldCount); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); + obj->SetInternalField( + imp::kIndexPropertyGetterIndex + , New(reinterpret_cast(getter))); + + if (setter) { + obj->SetInternalField( + imp::kIndexPropertySetterIndex + , New(reinterpret_cast(setter))); + } + + if (query) { + obj->SetInternalField( + imp::kIndexPropertyQueryIndex + , New(reinterpret_cast(query))); + } + + if (deleter) { + obj->SetInternalField( + imp::kIndexPropertyDeleterIndex + , New(reinterpret_cast(deleter))); + } + + if (enumerator) { + obj->SetInternalField( + imp::kIndexPropertyEnumeratorIndex + , New(reinterpret_cast(enumerator))); + } + + if (!data.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, data); + } + +#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION + tpl->SetHandler(v8::IndexedPropertyHandlerConfiguration( + getter_, setter_, query_, deleter_, enumerator_, obj)); +#else + tpl->SetIndexedPropertyHandler( + getter_ + , setter_ + , query_ + , deleter_ + , enumerator_ + , obj); +#endif +} + +inline void SetCallHandler( + v8::Local tpl + , FunctionCallback callback + , v8::Local data = v8::Local()) { + HandleScope scope; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kFunctionFieldCount); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); + + obj->SetInternalField( + imp::kFunctionIndex + , New(reinterpret_cast(callback))); + + if (!data.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, data); + } + + tpl->SetCallHandler(imp::FunctionCallbackWrapper, obj); +} + + +inline void SetCallAsFunctionHandler( + v8::Local tpl, + FunctionCallback callback, + v8::Local data = v8::Local()) { + HandleScope scope; + + v8::Local otpl = New(); + otpl->SetInternalFieldCount(imp::kFunctionFieldCount); + v8::Local obj = NewInstance(otpl).ToLocalChecked(); + + obj->SetInternalField( + imp::kFunctionIndex + , New(reinterpret_cast(callback))); + + if (!data.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, data); + } + + tpl->SetCallAsFunctionHandler(imp::FunctionCallbackWrapper, obj); +} + +//=== Weak Persistent Handling ================================================= + +#include "nan_weak.h" // NOLINT(build/include) + +//=== ObjectWrap =============================================================== + +#include "nan_object_wrap.h" // NOLINT(build/include) + +//=== Export ================================================================== + +inline +void +Export(ADDON_REGISTER_FUNCTION_ARGS_TYPE target, const char *name, + FunctionCallback f) { + Set(target, New(name).ToLocalChecked(), + GetFunction(New(f)).ToLocalChecked()); +} + +//=== Tap Reverse Binding ===================================================== + +struct Tap { + explicit Tap(v8::Local t) : t_() { + t_.Reset(To(t).ToLocalChecked()); + } + + ~Tap() { t_.Reset(); } // not sure if neccessary + + inline void plan(int i) { + v8::Local arg = New(i); + MakeCallback(New(t_), "plan", 1, &arg); + } + + inline void ok(bool isOk, const char *msg = NULL) { + v8::Local args[2]; + args[0] = New(isOk); + if (msg) args[1] = New(msg).ToLocalChecked(); + MakeCallback(New(t_), "ok", msg ? 2 : 1, args); + } + + inline void pass(const char * msg = NULL) { + v8::Local hmsg; + if (msg) hmsg = New(msg).ToLocalChecked(); + MakeCallback(New(t_), "pass", msg ? 1 : 0, &hmsg); + } + + private: + Persistent t_; +}; + +#define NAN_STRINGIZE2(x) #x +#define NAN_STRINGIZE(x) NAN_STRINGIZE2(x) +#define NAN_TEST_EXPRESSION(expression) \ + ( expression ), __FILE__ ":" NAN_STRINGIZE(__LINE__) ": " #expression + +#define NAN_EXPORT(target, function) Export(target, #function, function) + +#undef TYPE_CHECK + +//=== Generic Maybefication =================================================== + +namespace imp { + +template struct Maybefier; + +template struct Maybefier > { + static MaybeLocal convert(v8::Local v) { + return MaybeLocal(v); + } +}; + +template struct Maybefier > { + static MaybeLocal convert(MaybeLocal v) { + return v; + } +}; + +} // end of namespace imp + +template class MaybeMaybe> +MaybeLocal +MakeMaybe(MaybeMaybe v) { + return imp::Maybefier >::convert(v); +} + +//=== TypedArrayContents ======================================================= + +#include "nan_typedarray_contents.h" // NOLINT(build/include) + +} // end of namespace Nan + +#endif // NAN_H_ diff --git a/test/gc/node_modules/nan/nan_callbacks.h b/test/gc/node_modules/nan/nan_callbacks.h new file mode 100644 index 00000000000000..851509fdef51a6 --- /dev/null +++ b/test/gc/node_modules/nan/nan_callbacks.h @@ -0,0 +1,88 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CALLBACKS_H_ +#define NAN_CALLBACKS_H_ + +template class FunctionCallbackInfo; +template class PropertyCallbackInfo; +template class Global; + +typedef void(*FunctionCallback)(const FunctionCallbackInfo&); +typedef void(*GetterCallback) + (v8::Local, const PropertyCallbackInfo&); +typedef void(*SetterCallback)( + v8::Local, + v8::Local, + const PropertyCallbackInfo&); +typedef void(*PropertyGetterCallback)( + v8::Local, + const PropertyCallbackInfo&); +typedef void(*PropertySetterCallback)( + v8::Local, + v8::Local, + const PropertyCallbackInfo&); +typedef void(*PropertyEnumeratorCallback) + (const PropertyCallbackInfo&); +typedef void(*PropertyDeleterCallback)( + v8::Local, + const PropertyCallbackInfo&); +typedef void(*PropertyQueryCallback)( + v8::Local, + const PropertyCallbackInfo&); +typedef void(*IndexGetterCallback)( + uint32_t, + const PropertyCallbackInfo&); +typedef void(*IndexSetterCallback)( + uint32_t, + v8::Local, + const PropertyCallbackInfo&); +typedef void(*IndexEnumeratorCallback) + (const PropertyCallbackInfo&); +typedef void(*IndexDeleterCallback)( + uint32_t, + const PropertyCallbackInfo&); +typedef void(*IndexQueryCallback)( + uint32_t, + const PropertyCallbackInfo&); + +namespace imp { +typedef v8::Local Sig; + +static const int kDataIndex = 0; + +static const int kFunctionIndex = 1; +static const int kFunctionFieldCount = 2; + +static const int kGetterIndex = 1; +static const int kSetterIndex = 2; +static const int kAccessorFieldCount = 3; + +static const int kPropertyGetterIndex = 1; +static const int kPropertySetterIndex = 2; +static const int kPropertyEnumeratorIndex = 3; +static const int kPropertyDeleterIndex = 4; +static const int kPropertyQueryIndex = 5; +static const int kPropertyFieldCount = 6; + +static const int kIndexPropertyGetterIndex = 1; +static const int kIndexPropertySetterIndex = 2; +static const int kIndexPropertyEnumeratorIndex = 3; +static const int kIndexPropertyDeleterIndex = 4; +static const int kIndexPropertyQueryIndex = 5; +static const int kIndexPropertyFieldCount = 6; + +} // end of namespace imp + +#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION +# include "nan_callbacks_12_inl.h" // NOLINT(build/include) +#else +# include "nan_callbacks_pre_12_inl.h" // NOLINT(build/include) +#endif + +#endif // NAN_CALLBACKS_H_ diff --git a/test/gc/node_modules/nan/nan_callbacks_12_inl.h b/test/gc/node_modules/nan/nan_callbacks_12_inl.h new file mode 100644 index 00000000000000..bea12c71fb36be --- /dev/null +++ b/test/gc/node_modules/nan/nan_callbacks_12_inl.h @@ -0,0 +1,512 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CALLBACKS_12_INL_H_ +#define NAN_CALLBACKS_12_INL_H_ + +template +class ReturnValue { + v8::ReturnValue value_; + + public: + template + explicit inline ReturnValue(const v8::ReturnValue &value) : + value_(value) {} + template + explicit inline ReturnValue(const ReturnValue& that) + : value_(that.value_) { + TYPE_CHECK(T, S); + } + + // Handle setters + template inline void Set(const v8::Local &handle) { + TYPE_CHECK(T, S); + value_.Set(handle); + } + + template inline void Set(const Global &handle) { + TYPE_CHECK(T, S); +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && \ + (V8_MINOR_VERSION > 5 || (V8_MINOR_VERSION == 5 && \ + defined(V8_BUILD_NUMBER) && V8_BUILD_NUMBER >= 8)))) + value_.Set(handle); +#else + value_.Set(*reinterpret_cast*>(&handle)); + const_cast &>(handle).Reset(); +#endif + } + + // Fast primitive setters + inline void Set(bool value) { + TYPE_CHECK(T, v8::Boolean); + value_.Set(value); + } + + inline void Set(double i) { + TYPE_CHECK(T, v8::Number); + value_.Set(i); + } + + inline void Set(int32_t i) { + TYPE_CHECK(T, v8::Integer); + value_.Set(i); + } + + inline void Set(uint32_t i) { + TYPE_CHECK(T, v8::Integer); + value_.Set(i); + } + + // Fast JS primitive setters + inline void SetNull() { + TYPE_CHECK(T, v8::Primitive); + value_.SetNull(); + } + + inline void SetUndefined() { + TYPE_CHECK(T, v8::Primitive); + value_.SetUndefined(); + } + + inline void SetEmptyString() { + TYPE_CHECK(T, v8::String); + value_.SetEmptyString(); + } + + // Convenience getter for isolate + inline v8::Isolate *GetIsolate() const { + return value_.GetIsolate(); + } + + // Pointer setter: Uncompilable to prevent inadvertent misuse. + template + inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); } +}; + +template +class FunctionCallbackInfo { + const v8::FunctionCallbackInfo &info_; + const v8::Local data_; + + public: + explicit inline FunctionCallbackInfo( + const v8::FunctionCallbackInfo &info + , v8::Local data) : + info_(info) + , data_(data) {} + + inline ReturnValue GetReturnValue() const { + return ReturnValue(info_.GetReturnValue()); + } + + inline v8::Local Callee() const { return info_.Callee(); } + inline v8::Local Data() const { return data_; } + inline v8::Local Holder() const { return info_.Holder(); } + inline bool IsConstructCall() const { return info_.IsConstructCall(); } + inline int Length() const { return info_.Length(); } + inline v8::Local operator[](int i) const { return info_[i]; } + inline v8::Local This() const { return info_.This(); } + inline v8::Isolate *GetIsolate() const { return info_.GetIsolate(); } + + + protected: + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kCalleeIndex = 5; + static const int kContextSaveIndex = 6; + static const int kArgsLength = 7; + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo) +}; + +template +class PropertyCallbackInfo { + const v8::PropertyCallbackInfo &info_; + const v8::Local data_; + + public: + explicit inline PropertyCallbackInfo( + const v8::PropertyCallbackInfo &info + , const v8::Local data) : + info_(info) + , data_(data) {} + + inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); } + inline v8::Local Data() const { return data_; } + inline v8::Local This() const { return info_.This(); } + inline v8::Local Holder() const { return info_.Holder(); } + inline ReturnValue GetReturnValue() const { + return ReturnValue(info_.GetReturnValue()); + } + + protected: + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kThisIndex = 5; + static const int kArgsLength = 6; + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfo) +}; + +namespace imp { +static +void FunctionCallbackWrapper(const v8::FunctionCallbackInfo &info) { + v8::Local obj = info.Data().As(); + FunctionCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kFunctionIndex).As()->Value())); + FunctionCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + callback(cbinfo); +} + +typedef void (*NativeFunction)(const v8::FunctionCallbackInfo &); + +#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION +static +void GetterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + GetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kGetterIndex).As()->Value())); + callback(property.As(), cbinfo); +} + +typedef void (*NativeGetter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void SetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + SetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kSetterIndex).As()->Value())); + callback(property.As(), value, cbinfo); +} + +typedef void (*NativeSetter)( + v8::Local + , v8::Local + , const v8::PropertyCallbackInfo &); +#else +static +void GetterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + GetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kGetterIndex).As()->Value())); + callback(property, cbinfo); +} + +typedef void (*NativeGetter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void SetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + SetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kSetterIndex).As()->Value())); + callback(property, value, cbinfo); +} + +typedef void (*NativeSetter)( + v8::Local + , v8::Local + , const v8::PropertyCallbackInfo &); +#endif + +#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION +static +void PropertyGetterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyGetterIndex) + .As()->Value())); + callback(property.As(), cbinfo); +} + +typedef void (*NativePropertyGetter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void PropertySetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertySetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertySetterIndex) + .As()->Value())); + callback(property.As(), value, cbinfo); +} + +typedef void (*NativePropertySetter)( + v8::Local + , v8::Local + , const v8::PropertyCallbackInfo &); + +static +void PropertyEnumeratorCallbackWrapper( + const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyEnumeratorCallback callback = + reinterpret_cast(reinterpret_cast( + obj->GetInternalField(kPropertyEnumeratorIndex) + .As()->Value())); + callback(cbinfo); +} + +typedef void (*NativePropertyEnumerator) + (const v8::PropertyCallbackInfo &); + +static +void PropertyDeleterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyDeleterIndex) + .As()->Value())); + callback(property.As(), cbinfo); +} + +typedef void (NativePropertyDeleter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void PropertyQueryCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyQueryIndex) + .As()->Value())); + callback(property.As(), cbinfo); +} + +typedef void (*NativePropertyQuery) + (v8::Local, const v8::PropertyCallbackInfo &); +#else +static +void PropertyGetterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyGetterIndex) + .As()->Value())); + callback(property, cbinfo); +} + +typedef void (*NativePropertyGetter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void PropertySetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertySetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertySetterIndex) + .As()->Value())); + callback(property, value, cbinfo); +} + +typedef void (*NativePropertySetter)( + v8::Local + , v8::Local + , const v8::PropertyCallbackInfo &); + +static +void PropertyEnumeratorCallbackWrapper( + const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyEnumeratorCallback callback = + reinterpret_cast(reinterpret_cast( + obj->GetInternalField(kPropertyEnumeratorIndex) + .As()->Value())); + callback(cbinfo); +} + +typedef void (*NativePropertyEnumerator) + (const v8::PropertyCallbackInfo &); + +static +void PropertyDeleterCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyDeleterIndex) + .As()->Value())); + callback(property, cbinfo); +} + +typedef void (NativePropertyDeleter) + (v8::Local, const v8::PropertyCallbackInfo &); + +static +void PropertyQueryCallbackWrapper( + v8::Local property + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyQueryIndex) + .As()->Value())); + callback(property, cbinfo); +} + +typedef void (*NativePropertyQuery) + (v8::Local, const v8::PropertyCallbackInfo &); +#endif + +static +void IndexGetterCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyGetterIndex) + .As()->Value())); + callback(index, cbinfo); +} + +typedef void (*NativeIndexGetter) + (uint32_t, const v8::PropertyCallbackInfo &); + +static +void IndexSetterCallbackWrapper( + uint32_t index + , v8::Local value + , const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexSetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertySetterIndex) + .As()->Value())); + callback(index, value, cbinfo); +} + +typedef void (*NativeIndexSetter)( + uint32_t + , v8::Local + , const v8::PropertyCallbackInfo &); + +static +void IndexEnumeratorCallbackWrapper( + const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexEnumeratorCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField( + kIndexPropertyEnumeratorIndex).As()->Value())); + callback(cbinfo); +} + +typedef void (*NativeIndexEnumerator) + (const v8::PropertyCallbackInfo &); + +static +void IndexDeleterCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyDeleterIndex) + .As()->Value())); + callback(index, cbinfo); +} + +typedef void (*NativeIndexDeleter) + (uint32_t, const v8::PropertyCallbackInfo &); + +static +void IndexQueryCallbackWrapper( + uint32_t index, const v8::PropertyCallbackInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyQueryIndex) + .As()->Value())); + callback(index, cbinfo); +} + +typedef void (*NativeIndexQuery) + (uint32_t, const v8::PropertyCallbackInfo &); +} // end of namespace imp + +#endif // NAN_CALLBACKS_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_callbacks_pre_12_inl.h b/test/gc/node_modules/nan/nan_callbacks_pre_12_inl.h new file mode 100644 index 00000000000000..3604cc5405d8a1 --- /dev/null +++ b/test/gc/node_modules/nan/nan_callbacks_pre_12_inl.h @@ -0,0 +1,506 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CALLBACKS_PRE_12_INL_H_ +#define NAN_CALLBACKS_PRE_12_INL_H_ + +namespace imp { +template class ReturnValueImp; +} // end of namespace imp + +template +class ReturnValue { + v8::Isolate *isolate_; + v8::Persistent *value_; + friend class imp::ReturnValueImp; + + public: + template + explicit inline ReturnValue(v8::Isolate *isolate, v8::Persistent *p) : + isolate_(isolate), value_(p) {} + template + explicit inline ReturnValue(const ReturnValue& that) + : isolate_(that.isolate_), value_(that.value_) { + TYPE_CHECK(T, S); + } + + // Handle setters + template inline void Set(const v8::Local &handle) { + TYPE_CHECK(T, S); + value_->Dispose(); + *value_ = v8::Persistent::New(handle); + } + + template inline void Set(const Global &handle) { + TYPE_CHECK(T, S); + value_->Dispose(); + *value_ = v8::Persistent::New(handle.persistent); + const_cast &>(handle).Reset(); + } + + // Fast primitive setters + inline void Set(bool value) { + TYPE_CHECK(T, v8::Boolean); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Boolean::New(value)); + } + + inline void Set(double i) { + TYPE_CHECK(T, v8::Number); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Number::New(i)); + } + + inline void Set(int32_t i) { + TYPE_CHECK(T, v8::Integer); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Int32::New(i)); + } + + inline void Set(uint32_t i) { + TYPE_CHECK(T, v8::Integer); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Uint32::NewFromUnsigned(i)); + } + + // Fast JS primitive setters + inline void SetNull() { + TYPE_CHECK(T, v8::Primitive); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Null()); + } + + inline void SetUndefined() { + TYPE_CHECK(T, v8::Primitive); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::Undefined()); + } + + inline void SetEmptyString() { + TYPE_CHECK(T, v8::String); + value_->Dispose(); + *value_ = v8::Persistent::New(v8::String::Empty()); + } + + // Convenience getter for isolate + inline v8::Isolate *GetIsolate() const { + return isolate_; + } + + // Pointer setter: Uncompilable to prevent inadvertent misuse. + template + inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); } +}; + +template +class FunctionCallbackInfo { + const v8::Arguments &args_; + v8::Local data_; + ReturnValue return_value_; + v8::Persistent retval_; + + public: + explicit inline FunctionCallbackInfo( + const v8::Arguments &args + , v8::Local data) : + args_(args) + , data_(data) + , return_value_(args.GetIsolate(), &retval_) + , retval_(v8::Persistent::New(v8::Undefined())) {} + + inline ~FunctionCallbackInfo() { + retval_.Dispose(); + retval_.Clear(); + } + + inline ReturnValue GetReturnValue() const { + return ReturnValue(return_value_); + } + + inline v8::Local Callee() const { return args_.Callee(); } + inline v8::Local Data() const { return data_; } + inline v8::Local Holder() const { return args_.Holder(); } + inline bool IsConstructCall() const { return args_.IsConstructCall(); } + inline int Length() const { return args_.Length(); } + inline v8::Local operator[](int i) const { return args_[i]; } + inline v8::Local This() const { return args_.This(); } + inline v8::Isolate *GetIsolate() const { return args_.GetIsolate(); } + + + protected: + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kCalleeIndex = 5; + static const int kContextSaveIndex = 6; + static const int kArgsLength = 7; + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo) +}; + +template +class PropertyCallbackInfoBase { + const v8::AccessorInfo &info_; + const v8::Local data_; + + public: + explicit inline PropertyCallbackInfoBase( + const v8::AccessorInfo &info + , const v8::Local data) : + info_(info) + , data_(data) {} + + inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); } + inline v8::Local Data() const { return data_; } + inline v8::Local This() const { return info_.This(); } + inline v8::Local Holder() const { return info_.Holder(); } + + protected: + static const int kHolderIndex = 0; + static const int kIsolateIndex = 1; + static const int kReturnValueDefaultValueIndex = 2; + static const int kReturnValueIndex = 3; + static const int kDataIndex = 4; + static const int kThisIndex = 5; + static const int kArgsLength = 6; + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfoBase) +}; + +template +class PropertyCallbackInfo : public PropertyCallbackInfoBase { + ReturnValue return_value_; + v8::Persistent retval_; + + public: + explicit inline PropertyCallbackInfo( + const v8::AccessorInfo &info + , const v8::Local data) : + PropertyCallbackInfoBase(info, data) + , return_value_(info.GetIsolate(), &retval_) + , retval_(v8::Persistent::New(v8::Undefined())) {} + + inline ~PropertyCallbackInfo() { + retval_.Dispose(); + retval_.Clear(); + } + + inline ReturnValue GetReturnValue() const { return return_value_; } +}; + +template<> +class PropertyCallbackInfo : + public PropertyCallbackInfoBase { + ReturnValue return_value_; + v8::Persistent retval_; + + public: + explicit inline PropertyCallbackInfo( + const v8::AccessorInfo &info + , const v8::Local data) : + PropertyCallbackInfoBase(info, data) + , return_value_(info.GetIsolate(), &retval_) + , retval_(v8::Persistent::New(v8::Local())) {} + + inline ~PropertyCallbackInfo() { + retval_.Dispose(); + retval_.Clear(); + } + + inline ReturnValue GetReturnValue() const { + return return_value_; + } +}; + +template<> +class PropertyCallbackInfo : + public PropertyCallbackInfoBase { + ReturnValue return_value_; + v8::Persistent retval_; + + public: + explicit inline PropertyCallbackInfo( + const v8::AccessorInfo &info + , const v8::Local data) : + PropertyCallbackInfoBase(info, data) + , return_value_(info.GetIsolate(), &retval_) + , retval_(v8::Persistent::New(v8::Local())) {} + + inline ~PropertyCallbackInfo() { + retval_.Dispose(); + retval_.Clear(); + } + + inline ReturnValue GetReturnValue() const { + return return_value_; + } +}; + +template<> +class PropertyCallbackInfo : + public PropertyCallbackInfoBase { + ReturnValue return_value_; + v8::Persistent retval_; + + public: + explicit inline PropertyCallbackInfo( + const v8::AccessorInfo &info + , const v8::Local data) : + PropertyCallbackInfoBase(info, data) + , return_value_(info.GetIsolate(), &retval_) + , retval_(v8::Persistent::New(v8::Local())) {} + + inline ~PropertyCallbackInfo() { + retval_.Dispose(); + retval_.Clear(); + } + + inline ReturnValue GetReturnValue() const { + return return_value_; + } +}; + +namespace imp { +template +class ReturnValueImp : public ReturnValue { + public: + explicit ReturnValueImp(ReturnValue that) : + ReturnValue(that) {} + NAN_INLINE v8::Handle Value() { + return *ReturnValue::value_; + } +}; + +static +v8::Handle FunctionCallbackWrapper(const v8::Arguments &args) { + v8::Local obj = args.Data().As(); + FunctionCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kFunctionIndex).As()->Value())); + FunctionCallbackInfo + cbinfo(args, obj->GetInternalField(kDataIndex)); + callback(cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeFunction)(const v8::Arguments &); + +static +v8::Handle GetterCallbackWrapper( + v8::Local property, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + GetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kGetterIndex).As()->Value())); + callback(property, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeGetter) + (v8::Local, const v8::AccessorInfo &); + +static +void SetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + SetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kSetterIndex).As()->Value())); + callback(property, value, cbinfo); +} + +typedef void (*NativeSetter) + (v8::Local, v8::Local, const v8::AccessorInfo &); + +static +v8::Handle PropertyGetterCallbackWrapper( + v8::Local property, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyGetterIndex) + .As()->Value())); + callback(property, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativePropertyGetter) + (v8::Local, const v8::AccessorInfo &); + +static +v8::Handle PropertySetterCallbackWrapper( + v8::Local property + , v8::Local value + , const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertySetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertySetterIndex) + .As()->Value())); + callback(property, value, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativePropertySetter) + (v8::Local, v8::Local, const v8::AccessorInfo &); + +static +v8::Handle PropertyEnumeratorCallbackWrapper( + const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyEnumeratorCallback callback = + reinterpret_cast(reinterpret_cast( + obj->GetInternalField(kPropertyEnumeratorIndex) + .As()->Value())); + callback(cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativePropertyEnumerator) + (const v8::AccessorInfo &); + +static +v8::Handle PropertyDeleterCallbackWrapper( + v8::Local property + , const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyDeleterIndex) + .As()->Value())); + callback(property, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (NativePropertyDeleter) + (v8::Local, const v8::AccessorInfo &); + +static +v8::Handle PropertyQueryCallbackWrapper( + v8::Local property, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + PropertyQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kPropertyQueryIndex) + .As()->Value())); + callback(property, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativePropertyQuery) + (v8::Local, const v8::AccessorInfo &); + +static +v8::Handle IndexGetterCallbackWrapper( + uint32_t index, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexGetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyGetterIndex) + .As()->Value())); + callback(index, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeIndexGetter) + (uint32_t, const v8::AccessorInfo &); + +static +v8::Handle IndexSetterCallbackWrapper( + uint32_t index + , v8::Local value + , const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexSetterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertySetterIndex) + .As()->Value())); + callback(index, value, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeIndexSetter) + (uint32_t, v8::Local, const v8::AccessorInfo &); + +static +v8::Handle IndexEnumeratorCallbackWrapper( + const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexEnumeratorCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyEnumeratorIndex) + .As()->Value())); + callback(cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeIndexEnumerator) + (const v8::AccessorInfo &); + +static +v8::Handle IndexDeleterCallbackWrapper( + uint32_t index, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexDeleterCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyDeleterIndex) + .As()->Value())); + callback(index, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeIndexDeleter) + (uint32_t, const v8::AccessorInfo &); + +static +v8::Handle IndexQueryCallbackWrapper( + uint32_t index, const v8::AccessorInfo &info) { + v8::Local obj = info.Data().As(); + PropertyCallbackInfo + cbinfo(info, obj->GetInternalField(kDataIndex)); + IndexQueryCallback callback = reinterpret_cast( + reinterpret_cast( + obj->GetInternalField(kIndexPropertyQueryIndex) + .As()->Value())); + callback(index, cbinfo); + return ReturnValueImp(cbinfo.GetReturnValue()).Value(); +} + +typedef v8::Handle (*NativeIndexQuery) + (uint32_t, const v8::AccessorInfo &); +} // end of namespace imp + +#endif // NAN_CALLBACKS_PRE_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_converters.h b/test/gc/node_modules/nan/nan_converters.h new file mode 100644 index 00000000000000..533e97e581cc5f --- /dev/null +++ b/test/gc/node_modules/nan/nan_converters.h @@ -0,0 +1,64 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CONVERTERS_H_ +#define NAN_CONVERTERS_H_ + +namespace imp { +template struct ToFactoryBase { + typedef MaybeLocal return_t; +}; +template struct ValueFactoryBase { typedef Maybe return_t; }; + +template struct ToFactory; + +#define X(TYPE) \ + template<> \ + struct ToFactory : ToFactoryBase { \ + static inline return_t convert(v8::Local val); \ + }; + +X(Boolean) +X(Number) +X(String) +X(Object) +X(Integer) +X(Uint32) +X(Int32) + +#undef X + +#define X(TYPE) \ + template<> \ + struct ToFactory : ValueFactoryBase { \ + static inline return_t convert(v8::Local val); \ + }; + +X(bool) +X(double) +X(int64_t) +X(uint32_t) +X(int32_t) + +#undef X +} // end of namespace imp + +template +NAN_INLINE +typename imp::ToFactory::return_t To(v8::Local val) { + return imp::ToFactory::convert(val); +} + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +# include "nan_converters_43_inl.h" +#else +# include "nan_converters_pre_43_inl.h" +#endif + +#endif // NAN_CONVERTERS_H_ diff --git a/test/gc/node_modules/nan/nan_converters_43_inl.h b/test/gc/node_modules/nan/nan_converters_43_inl.h new file mode 100644 index 00000000000000..e2eb032fd64fd8 --- /dev/null +++ b/test/gc/node_modules/nan/nan_converters_43_inl.h @@ -0,0 +1,42 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CONVERTERS_43_INL_H_ +#define NAN_CONVERTERS_43_INL_H_ + +#define X(TYPE) \ +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + return val->To ## TYPE(GetCurrentContext()); \ +} + +X(Boolean) +X(Number) +X(String) +X(Object) +X(Integer) +X(Uint32) +X(Int32) + +#undef X + +#define X(TYPE, NAME) \ +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + return val->NAME ## Value(GetCurrentContext()); \ +} + +X(bool, Boolean) +X(double, Number) +X(int64_t, Integer) +X(uint32_t, Uint32) +X(int32_t, Int32) + +#undef X + +#endif // NAN_CONVERTERS_43_INL_H_ diff --git a/test/gc/node_modules/nan/nan_converters_pre_43_inl.h b/test/gc/node_modules/nan/nan_converters_pre_43_inl.h new file mode 100644 index 00000000000000..177a74a2af5bda --- /dev/null +++ b/test/gc/node_modules/nan/nan_converters_pre_43_inl.h @@ -0,0 +1,42 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_CONVERTERS_PRE_43_INL_H_ +#define NAN_CONVERTERS_PRE_43_INL_H_ + +#define X(TYPE) \ +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + return MaybeLocal(val->To ## TYPE()); \ +} + +X(Boolean) +X(Number) +X(String) +X(Object) +X(Integer) +X(Uint32) +X(Int32) + +#undef X + +#define X(TYPE, NAME) \ +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + return Just(val->NAME ##Value()); \ +} + +X(bool, Boolean) +X(double, Number) +X(int64_t, Integer) +X(uint32_t, Uint32) +X(int32_t, Int32) + +#undef X + +#endif // NAN_CONVERTERS_PRE_43_INL_H_ diff --git a/test/gc/node_modules/nan/nan_implementation_12_inl.h b/test/gc/node_modules/nan/nan_implementation_12_inl.h new file mode 100644 index 00000000000000..cb1e765a51e13a --- /dev/null +++ b/test/gc/node_modules/nan/nan_implementation_12_inl.h @@ -0,0 +1,404 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_12_INL_H_ +#define NAN_IMPLEMENTATION_12_INL_H_ +//============================================================================== +// node v0.11 implementation +//============================================================================== + +namespace imp { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(v8::Isolate::GetCurrent()); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(v8::Isolate::GetCurrent(), length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(v8::Isolate::GetCurrent(), value); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Local tmpl + , v8::Local obj) { + return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj); +} + +//=== Date ===================================================================== + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +Factory::return_t +Factory::New(double value) { + v8::Local ret; + if (v8::Date::New(GetCurrentContext(), value). + ToLocal(reinterpret_cast*>(&ret))) { + return v8::MaybeLocal(ret); + } else { + return v8::MaybeLocal(ret); + } +} +#else +Factory::return_t +Factory::New(double value) { + return Factory::return_t( + v8::Date::New(v8::Isolate::GetCurrent(), value).As()); +} +#endif + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(v8::Isolate::GetCurrent(), value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( FunctionCallback callback + , v8::Local data) { + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::EscapableHandleScope scope(isolate); + v8::Local tpl = v8::ObjectTemplate::New(isolate); + tpl->SetInternalFieldCount(imp::kFunctionFieldCount); + v8::Local obj = NewInstance(tpl).ToLocalChecked(); + + obj->SetInternalField( + imp::kFunctionIndex + , v8::External::New(isolate, reinterpret_cast(callback))); + + v8::Local val = v8::Local::New(isolate, data); + + if (!val.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, val); + } + + return scope.Escape(v8::Function::New( isolate + , imp::FunctionCallbackWrapper + , obj)); +} + +//=== Function Template ======================================================== + +Factory::return_t +Factory::New( FunctionCallback callback + , v8::Local data + , v8::Local signature) { + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + if (callback) { + v8::EscapableHandleScope scope(isolate); + v8::Local tpl = v8::ObjectTemplate::New(isolate); + tpl->SetInternalFieldCount(imp::kFunctionFieldCount); + v8::Local obj = NewInstance(tpl).ToLocalChecked(); + + obj->SetInternalField( + imp::kFunctionIndex + , v8::External::New(isolate, reinterpret_cast(callback))); + v8::Local val = v8::Local::New(isolate, data); + + if (!val.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, val); + } + + return scope.Escape(v8::FunctionTemplate::New( isolate + , imp::FunctionCallbackWrapper + , obj + , signature)); + } else { + return v8::FunctionTemplate::New(isolate, 0, data, signature); + } +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(v8::Isolate::GetCurrent(), value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New( v8::Isolate::GetCurrent() + , value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(v8::Isolate::GetCurrent(), value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To( + v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value)); +} + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(v8::Isolate::GetCurrent()); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(v8::Isolate::GetCurrent()); +} + +//=== RegExp =================================================================== + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +Factory::return_t +Factory::New( + v8::Local pattern + , v8::RegExp::Flags flags) { + return v8::RegExp::New(GetCurrentContext(), pattern, flags); +} +#else +Factory::return_t +Factory::New( + v8::Local pattern + , v8::RegExp::Flags flags) { + return Factory::return_t(v8::RegExp::New(pattern, flags)); +} +#endif + +//=== Script =================================================================== + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +Factory::return_t +Factory::New( v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::Compile(GetCurrentContext(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::Compile(GetCurrentContext(), &src); +} +#else +Factory::return_t +Factory::New( v8::Local source) { + v8::ScriptCompiler::Source src(source); + return Factory::return_t( + v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src)); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return Factory::return_t( + v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src)); +} +#endif + +//=== Signature ================================================================ + +Factory::return_t +Factory::New(Factory::FTH receiver) { + return v8::Signature::New(v8::Isolate::GetCurrent(), receiver); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return Factory::return_t( + v8::String::Empty(v8::Isolate::GetCurrent())); +} + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +Factory::return_t +Factory::New(const char * value, int length) { + return v8::String::NewFromUtf8( + v8::Isolate::GetCurrent(), value, v8::NewStringType::kNormal, length); +} + +Factory::return_t +Factory::New(std::string const& value) { + assert(value.size() <= INT_MAX && "string too long"); + return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), + value.data(), v8::NewStringType::kNormal, static_cast(value.size())); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value, + v8::NewStringType::kNormal, length); +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return v8::String::NewExternalTwoByte(v8::Isolate::GetCurrent(), value); +} + +Factory::return_t +Factory::New(ExternalOneByteStringResource * value) { + return v8::String::NewExternalOneByte(v8::Isolate::GetCurrent(), value); +} +#else +Factory::return_t +Factory::New(const char * value, int length) { + return Factory::return_t( + v8::String::NewFromUtf8( + v8::Isolate::GetCurrent() + , value + , v8::String::kNormalString + , length)); +} + +Factory::return_t +Factory::New( + std::string const& value) /* NOLINT(build/include_what_you_use) */ { + assert(value.size() <= INT_MAX && "string too long"); + return Factory::return_t( + v8::String::NewFromUtf8( + v8::Isolate::GetCurrent() + , value.data() + , v8::String::kNormalString + , static_cast(value.size()))); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return Factory::return_t( + v8::String::NewFromTwoByte( + v8::Isolate::GetCurrent() + , value + , v8::String::kNormalString + , length)); +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return Factory::return_t( + v8::String::NewExternal(v8::Isolate::GetCurrent(), value)); +} + +Factory::return_t +Factory::New(ExternalOneByteStringResource * value) { + return Factory::return_t( + v8::String::NewExternal(v8::Isolate::GetCurrent(), value)); +} +#endif + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Local value) { + return v8::StringObject::New(value).As(); +} + +//=== Unbound Script =========================================================== + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +Factory::return_t +Factory::New(v8::Local source) { + v8::ScriptCompiler::Source src(source); + return v8::ScriptCompiler::CompileUnboundScript( + v8::Isolate::GetCurrent(), &src); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return v8::ScriptCompiler::CompileUnboundScript( + v8::Isolate::GetCurrent(), &src); +} +#else +Factory::return_t +Factory::New(v8::Local source) { + v8::ScriptCompiler::Source src(source); + return Factory::return_t( + v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src)); +} + +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + v8::ScriptCompiler::Source src(source, origin); + return Factory::return_t( + v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src)); +} +#endif + +} // end of namespace imp + +//=== Presistents and Handles ================================================== + +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION +template +inline v8::Local New(v8::Handle h) { + return v8::Local::New(v8::Isolate::GetCurrent(), h); +} +#endif + +template +inline v8::Local New(v8::Persistent const& p) { + return v8::Local::New(v8::Isolate::GetCurrent(), p); +} + +template +inline v8::Local New(Persistent const& p) { + return v8::Local::New(v8::Isolate::GetCurrent(), p); +} + +template +inline v8::Local New(Global const& p) { + return v8::Local::New(v8::Isolate::GetCurrent(), p); +} + +#endif // NAN_IMPLEMENTATION_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_implementation_pre_12_inl.h b/test/gc/node_modules/nan/nan_implementation_pre_12_inl.h new file mode 100644 index 00000000000000..f6642eece57772 --- /dev/null +++ b/test/gc/node_modules/nan/nan_implementation_pre_12_inl.h @@ -0,0 +1,264 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_ +#define NAN_IMPLEMENTATION_PRE_12_INL_H_ + +//============================================================================== +// node v0.10 implementation +//============================================================================== + +namespace imp { + +//=== Array ==================================================================== + +Factory::return_t +Factory::New() { + return v8::Array::New(); +} + +Factory::return_t +Factory::New(int length) { + return v8::Array::New(length); +} + +//=== Boolean ================================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::Boolean::New(value)->ToBoolean(); +} + +//=== Boolean Object =========================================================== + +Factory::return_t +Factory::New(bool value) { + return v8::BooleanObject::New(value).As(); +} + +//=== Context ================================================================== + +Factory::return_t +Factory::New( v8::ExtensionConfiguration* extensions + , v8::Local tmpl + , v8::Local obj) { + v8::Persistent ctx = v8::Context::New(extensions, tmpl, obj); + v8::Local lctx = v8::Local::New(ctx); + ctx.Dispose(); + return lctx; +} + +//=== Date ===================================================================== + +Factory::return_t +Factory::New(double value) { + return Factory::return_t(v8::Date::New(value).As()); +} + +//=== External ================================================================= + +Factory::return_t +Factory::New(void * value) { + return v8::External::New(value); +} + +//=== Function ================================================================= + +Factory::return_t +Factory::New( FunctionCallback callback + , v8::Local data) { + return Factory::New( callback + , data + , v8::Local() + )->GetFunction(); +} + + +//=== FunctionTemplate ========================================================= + +Factory::return_t +Factory::New( FunctionCallback callback + , v8::Local data + , v8::Local signature) { + if (callback) { + v8::HandleScope scope; + + v8::Local tpl = v8::ObjectTemplate::New(); + tpl->SetInternalFieldCount(imp::kFunctionFieldCount); + v8::Local obj = tpl->NewInstance(); + + obj->SetInternalField( + imp::kFunctionIndex + , v8::External::New(reinterpret_cast(callback))); + + v8::Local val = v8::Local::New(data); + + if (!val.IsEmpty()) { + obj->SetInternalField(imp::kDataIndex, val); + } + + // Note(agnat): Emulate length argument here. Unfortunately, I couldn't find + // a way. Have at it though... + return scope.Close( + v8::FunctionTemplate::New(imp::FunctionCallbackWrapper + , obj + , signature)); + } else { + return v8::FunctionTemplate::New(0, data, signature); + } +} + +//=== Number =================================================================== + +Factory::return_t +Factory::New(double value) { + return v8::Number::New(value); +} + +//=== Number Object ============================================================ + +Factory::return_t +Factory::New(double value) { + return v8::NumberObject::New(value).As(); +} + +//=== Integer, Int32 and Uint32 ================================================ + +template +typename IntegerFactory::return_t +IntegerFactory::New(int32_t value) { + return To(T::New(value)); +} + +template +typename IntegerFactory::return_t +IntegerFactory::New(uint32_t value) { + return To(T::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(int32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + +Factory::return_t +Factory::New(uint32_t value) { + return To(v8::Uint32::NewFromUnsigned(value)); +} + + +//=== Object =================================================================== + +Factory::return_t +Factory::New() { + return v8::Object::New(); +} + +//=== Object Template ========================================================== + +Factory::return_t +Factory::New() { + return v8::ObjectTemplate::New(); +} + +//=== RegExp =================================================================== + +Factory::return_t +Factory::New( + v8::Local pattern + , v8::RegExp::Flags flags) { + return Factory::return_t(v8::RegExp::New(pattern, flags)); +} + +//=== Script =================================================================== + +Factory::return_t +Factory::New( v8::Local source) { + return Factory::return_t(v8::Script::New(source)); +} +Factory::return_t +Factory::New( v8::Local source + , v8::ScriptOrigin const& origin) { + return Factory::return_t( + v8::Script::New(source, const_cast(&origin))); +} + +//=== Signature ================================================================ + +Factory::return_t +Factory::New(Factory::FTH receiver) { + return v8::Signature::New(receiver); +} + +//=== String =================================================================== + +Factory::return_t +Factory::New() { + return Factory::return_t(v8::String::Empty()); +} + +Factory::return_t +Factory::New(const char * value, int length) { + return Factory::return_t(v8::String::New(value, length)); +} + +Factory::return_t +Factory::New( + std::string const& value) /* NOLINT(build/include_what_you_use) */ { + assert(value.size() <= INT_MAX && "string too long"); + return Factory::return_t( + v8::String::New( value.data(), static_cast(value.size()))); +} + +Factory::return_t +Factory::New(const uint16_t * value, int length) { + return Factory::return_t(v8::String::New(value, length)); +} + +Factory::return_t +Factory::New(v8::String::ExternalStringResource * value) { + return Factory::return_t(v8::String::NewExternal(value)); +} + +Factory::return_t +Factory::New(v8::String::ExternalAsciiStringResource * value) { + return Factory::return_t(v8::String::NewExternal(value)); +} + +//=== String Object ============================================================ + +Factory::return_t +Factory::New(v8::Local value) { + return v8::StringObject::New(value).As(); +} + +} // end of namespace imp + +//=== Presistents and Handles ================================================== + +template +inline v8::Local New(v8::Handle h) { + return v8::Local::New(h); +} + +template +inline v8::Local New(v8::Persistent const& p) { + return v8::Local::New(p); +} + +template +inline v8::Local New(Persistent const& p) { + return v8::Local::New(p.persistent); +} + +template +inline v8::Local New(Global const& p) { + return v8::Local::New(p.persistent); +} + +#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_maybe_43_inl.h b/test/gc/node_modules/nan/nan_maybe_43_inl.h new file mode 100644 index 00000000000000..b4f92357b2bbf8 --- /dev/null +++ b/test/gc/node_modules/nan/nan_maybe_43_inl.h @@ -0,0 +1,231 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_MAYBE_43_INL_H_ +#define NAN_MAYBE_43_INL_H_ + +template +using MaybeLocal = v8::MaybeLocal; + +template +using Maybe = v8::Maybe; + +template +NAN_INLINE Maybe Nothing() { + return v8::Nothing(); +} + +template +NAN_INLINE Maybe Just(const T& t) { + return v8::Just(t); +} + +v8::Local GetCurrentContext(); + +NAN_INLINE +MaybeLocal ToDetailString(v8::Local val) { + return val->ToDetailString(GetCurrentContext()); +} + +NAN_INLINE +MaybeLocal ToArrayIndex(v8::Local val) { + return val->ToArrayIndex(GetCurrentContext()); +} + +NAN_INLINE +Maybe Equals(v8::Local a, v8::Local(b)) { + return a->Equals(GetCurrentContext(), b); +} + +NAN_INLINE +MaybeLocal NewInstance(v8::Local h) { + return h->NewInstance(GetCurrentContext()); +} + +NAN_INLINE +MaybeLocal NewInstance( + v8::Local h + , int argc + , v8::Local argv[]) { + return h->NewInstance(GetCurrentContext(), argc, argv); +} + +NAN_INLINE +MaybeLocal NewInstance(v8::Local h) { + return h->NewInstance(GetCurrentContext()); +} + + +NAN_INLINE MaybeLocal GetFunction( + v8::Local t) { + return t->GetFunction(GetCurrentContext()); +} + +NAN_INLINE Maybe Set( + v8::Local obj + , v8::Local key + , v8::Local value) { + return obj->Set(GetCurrentContext(), key, value); +} + +NAN_INLINE Maybe Set( + v8::Local obj + , uint32_t index + , v8::Local value) { + return obj->Set(GetCurrentContext(), index, value); +} + +NAN_INLINE Maybe ForceSet( + v8::Local obj + , v8::Local key + , v8::Local value + , v8::PropertyAttribute attribs = v8::None) { + return obj->ForceSet(GetCurrentContext(), key, value, attribs); +} + +NAN_INLINE MaybeLocal Get( + v8::Local obj + , v8::Local key) { + return obj->Get(GetCurrentContext(), key); +} + +NAN_INLINE +MaybeLocal Get(v8::Local obj, uint32_t index) { + return obj->Get(GetCurrentContext(), index); +} + +NAN_INLINE v8::PropertyAttribute GetPropertyAttributes( + v8::Local obj + , v8::Local key) { + return obj->GetPropertyAttributes(GetCurrentContext(), key).FromJust(); +} + +NAN_INLINE Maybe Has( + v8::Local obj + , v8::Local key) { + return obj->Has(GetCurrentContext(), key); +} + +NAN_INLINE Maybe Has(v8::Local obj, uint32_t index) { + return obj->Has(GetCurrentContext(), index); +} + +NAN_INLINE Maybe Delete( + v8::Local obj + , v8::Local key) { + return obj->Delete(GetCurrentContext(), key); +} + +NAN_INLINE +Maybe Delete(v8::Local obj, uint32_t index) { + return obj->Delete(GetCurrentContext(), index); +} + +NAN_INLINE +MaybeLocal GetPropertyNames(v8::Local obj) { + return obj->GetPropertyNames(GetCurrentContext()); +} + +NAN_INLINE +MaybeLocal GetOwnPropertyNames(v8::Local obj) { + return obj->GetOwnPropertyNames(GetCurrentContext()); +} + +NAN_INLINE Maybe SetPrototype( + v8::Local obj + , v8::Local prototype) { + return obj->SetPrototype(GetCurrentContext(), prototype); +} + +NAN_INLINE MaybeLocal ObjectProtoToString( + v8::Local obj) { + return obj->ObjectProtoToString(GetCurrentContext()); +} + +NAN_INLINE Maybe HasOwnProperty( + v8::Local obj + , v8::Local key) { + return obj->HasOwnProperty(GetCurrentContext(), key); +} + +NAN_INLINE Maybe HasRealNamedProperty( + v8::Local obj + , v8::Local key) { + return obj->HasRealNamedProperty(GetCurrentContext(), key); +} + +NAN_INLINE Maybe HasRealIndexedProperty( + v8::Local obj + , uint32_t index) { + return obj->HasRealIndexedProperty(GetCurrentContext(), index); +} + +NAN_INLINE Maybe HasRealNamedCallbackProperty( + v8::Local obj + , v8::Local key) { + return obj->HasRealNamedCallbackProperty(GetCurrentContext(), key); +} + +NAN_INLINE MaybeLocal GetRealNamedPropertyInPrototypeChain( + v8::Local obj + , v8::Local key) { + return obj->GetRealNamedPropertyInPrototypeChain(GetCurrentContext(), key); +} + +NAN_INLINE MaybeLocal GetRealNamedProperty( + v8::Local obj + , v8::Local key) { + return obj->GetRealNamedProperty(GetCurrentContext(), key); +} + +NAN_INLINE MaybeLocal CallAsFunction( + v8::Local obj + , v8::Local recv + , int argc + , v8::Local argv[]) { + return obj->CallAsFunction(GetCurrentContext(), recv, argc, argv); +} + +NAN_INLINE MaybeLocal CallAsConstructor( + v8::Local obj + , int argc, v8::Local argv[]) { + return obj->CallAsConstructor(GetCurrentContext(), argc, argv); +} + +NAN_INLINE +MaybeLocal GetSourceLine(v8::Local msg) { + return msg->GetSourceLine(GetCurrentContext()); +} + +NAN_INLINE Maybe GetLineNumber(v8::Local msg) { + return msg->GetLineNumber(GetCurrentContext()); +} + +NAN_INLINE Maybe GetStartColumn(v8::Local msg) { + return msg->GetStartColumn(GetCurrentContext()); +} + +NAN_INLINE Maybe GetEndColumn(v8::Local msg) { + return msg->GetEndColumn(GetCurrentContext()); +} + +NAN_INLINE MaybeLocal CloneElementAt( + v8::Local array + , uint32_t index) { + return array->CloneElementAt(GetCurrentContext(), index); +} + +NAN_INLINE MaybeLocal Call( + v8::Local fun + , v8::Local recv + , int argc + , v8::Local argv[]) { + return fun->Call(GetCurrentContext(), recv, argc, argv); +} + +#endif // NAN_MAYBE_43_INL_H_ diff --git a/test/gc/node_modules/nan/nan_maybe_pre_43_inl.h b/test/gc/node_modules/nan/nan_maybe_pre_43_inl.h new file mode 100644 index 00000000000000..3b79341243b12a --- /dev/null +++ b/test/gc/node_modules/nan/nan_maybe_pre_43_inl.h @@ -0,0 +1,303 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_MAYBE_PRE_43_INL_H_ +#define NAN_MAYBE_PRE_43_INL_H_ + +template +class MaybeLocal { + public: + NAN_INLINE MaybeLocal() : val_(v8::Local()) {} + + template +# if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION + NAN_INLINE MaybeLocal(v8::Local that) : val_(that) {} +# else + NAN_INLINE MaybeLocal(v8::Local that) : + val_(*reinterpret_cast*>(&that)) {} +# endif + + NAN_INLINE bool IsEmpty() const { return val_.IsEmpty(); } + + template + NAN_INLINE bool ToLocal(v8::Local *out) const { + *out = val_; + return !IsEmpty(); + } + + NAN_INLINE v8::Local ToLocalChecked() const { +#if defined(V8_ENABLE_CHECKS) + assert(!IsEmpty() && "ToLocalChecked is Empty"); +#endif // V8_ENABLE_CHECKS + return val_; + } + + template + NAN_INLINE v8::Local FromMaybe(v8::Local default_value) const { + return IsEmpty() ? default_value : val_; + } + + private: + v8::Local val_; +}; + +template +class Maybe { + public: + NAN_INLINE bool IsNothing() const { return !has_value_; } + NAN_INLINE bool IsJust() const { return has_value_; } + + NAN_INLINE T FromJust() const { +#if defined(V8_ENABLE_CHECKS) + assert(IsJust() && "FromJust is Nothing"); +#endif // V8_ENABLE_CHECKS + return value_; + } + + NAN_INLINE T FromMaybe(const T& default_value) const { + return has_value_ ? value_ : default_value; + } + + NAN_INLINE bool operator==(const Maybe &other) const { + return (IsJust() == other.IsJust()) && + (!IsJust() || FromJust() == other.FromJust()); + } + + NAN_INLINE bool operator!=(const Maybe &other) const { + return !operator==(other); + } + + private: + Maybe() : has_value_(false) {} + explicit Maybe(const T& t) : has_value_(true), value_(t) {} + bool has_value_; + T value_; + + template + friend Maybe Nothing(); + template + friend Maybe Just(const U& u); +}; + +template +inline Maybe Nothing() { + return Maybe(); +} + +template +inline Maybe Just(const T& t) { + return Maybe(t); +} + +NAN_INLINE +MaybeLocal ToDetailString(v8::Handle val) { + return MaybeLocal(val->ToDetailString()); +} + +NAN_INLINE +MaybeLocal ToArrayIndex(v8::Handle val) { + return MaybeLocal(val->ToArrayIndex()); +} + +NAN_INLINE +Maybe Equals(v8::Handle a, v8::Handle(b)) { + return Just(a->Equals(b)); +} + +NAN_INLINE +MaybeLocal NewInstance(v8::Handle h) { + return MaybeLocal(h->NewInstance()); +} + +NAN_INLINE +MaybeLocal NewInstance( + v8::Local h + , int argc + , v8::Local argv[]) { + return MaybeLocal(h->NewInstance(argc, argv)); +} + +NAN_INLINE +MaybeLocal NewInstance(v8::Handle h) { + return MaybeLocal(h->NewInstance()); +} + +NAN_INLINE +MaybeLocal GetFunction(v8::Handle t) { + return MaybeLocal(t->GetFunction()); +} + +NAN_INLINE Maybe Set( + v8::Handle obj + , v8::Handle key + , v8::Handle value) { + return Just(obj->Set(key, value)); +} + +NAN_INLINE Maybe Set( + v8::Handle obj + , uint32_t index + , v8::Handle value) { + return Just(obj->Set(index, value)); +} + +NAN_INLINE Maybe ForceSet( + v8::Handle obj + , v8::Handle key + , v8::Handle value + , v8::PropertyAttribute attribs = v8::None) { + return Just(obj->ForceSet(key, value, attribs)); +} + +NAN_INLINE MaybeLocal Get( + v8::Handle obj + , v8::Handle key) { + return MaybeLocal(obj->Get(key)); +} + +NAN_INLINE MaybeLocal Get( + v8::Handle obj + , uint32_t index) { + return MaybeLocal(obj->Get(index)); +} + +NAN_INLINE Maybe GetPropertyAttributes( + v8::Handle obj + , v8::Handle key) { + return Just(obj->GetPropertyAttributes(key)); +} + +NAN_INLINE Maybe Has( + v8::Handle obj + , v8::Handle key) { + return Just(obj->Has(key)); +} + +NAN_INLINE Maybe Has( + v8::Handle obj + , uint32_t index) { + return Just(obj->Has(index)); +} + +NAN_INLINE Maybe Delete( + v8::Handle obj + , v8::Handle key) { + return Just(obj->Delete(key)); +} + +NAN_INLINE Maybe Delete( + v8::Handle obj + , uint32_t index) { + return Just(obj->Delete(index)); +} + +NAN_INLINE +MaybeLocal GetPropertyNames(v8::Handle obj) { + return MaybeLocal(obj->GetPropertyNames()); +} + +NAN_INLINE +MaybeLocal GetOwnPropertyNames(v8::Handle obj) { + return MaybeLocal(obj->GetOwnPropertyNames()); +} + +NAN_INLINE Maybe SetPrototype( + v8::Handle obj + , v8::Handle prototype) { + return Just(obj->SetPrototype(prototype)); +} + +NAN_INLINE MaybeLocal ObjectProtoToString( + v8::Handle obj) { + return MaybeLocal(obj->ObjectProtoToString()); +} + +NAN_INLINE Maybe HasOwnProperty( + v8::Handle obj + , v8::Handle key) { + return Just(obj->HasOwnProperty(key)); +} + +NAN_INLINE Maybe HasRealNamedProperty( + v8::Handle obj + , v8::Handle key) { + return Just(obj->HasRealNamedProperty(key)); +} + +NAN_INLINE Maybe HasRealIndexedProperty( + v8::Handle obj + , uint32_t index) { + return Just(obj->HasRealIndexedProperty(index)); +} + +NAN_INLINE Maybe HasRealNamedCallbackProperty( + v8::Handle obj + , v8::Handle key) { + return Just(obj->HasRealNamedCallbackProperty(key)); +} + +NAN_INLINE MaybeLocal GetRealNamedPropertyInPrototypeChain( + v8::Handle obj + , v8::Handle key) { + return MaybeLocal( + obj->GetRealNamedPropertyInPrototypeChain(key)); +} + +NAN_INLINE MaybeLocal GetRealNamedProperty( + v8::Handle obj + , v8::Handle key) { + return MaybeLocal(obj->GetRealNamedProperty(key)); +} + +NAN_INLINE MaybeLocal CallAsFunction( + v8::Handle obj + , v8::Handle recv + , int argc + , v8::Handle argv[]) { + return MaybeLocal(obj->CallAsFunction(recv, argc, argv)); +} + +NAN_INLINE MaybeLocal CallAsConstructor( + v8::Handle obj + , int argc + , v8::Local argv[]) { + return MaybeLocal(obj->CallAsConstructor(argc, argv)); +} + +NAN_INLINE +MaybeLocal GetSourceLine(v8::Handle msg) { + return MaybeLocal(msg->GetSourceLine()); +} + +NAN_INLINE Maybe GetLineNumber(v8::Handle msg) { + return Just(msg->GetLineNumber()); +} + +NAN_INLINE Maybe GetStartColumn(v8::Handle msg) { + return Just(msg->GetStartColumn()); +} + +NAN_INLINE Maybe GetEndColumn(v8::Handle msg) { + return Just(msg->GetEndColumn()); +} + +NAN_INLINE MaybeLocal CloneElementAt( + v8::Handle array + , uint32_t index) { + return MaybeLocal(array->CloneElementAt(index)); +} + +NAN_INLINE MaybeLocal Call( + v8::Local fun + , v8::Local recv + , int argc + , v8::Local argv[]) { + return MaybeLocal(fun->Call(recv, argc, argv)); +} + +#endif // NAN_MAYBE_PRE_43_INL_H_ diff --git a/test/gc/node_modules/nan/nan_new.h b/test/gc/node_modules/nan/nan_new.h new file mode 100644 index 00000000000000..6c7d19fc12fa9f --- /dev/null +++ b/test/gc/node_modules/nan/nan_new.h @@ -0,0 +1,340 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_NEW_H_ +#define NAN_NEW_H_ + +namespace imp { // scnr + +// TODO(agnat): Generalize +template v8::Local To(v8::Local i); + +template <> +inline +v8::Local +To(v8::Local i) { + return Nan::To(i).ToLocalChecked(); +} + +template <> +inline +v8::Local +To(v8::Local i) { + return Nan::To(i).ToLocalChecked(); +} + +template <> +inline +v8::Local +To(v8::Local i) { + return Nan::To(i).ToLocalChecked(); +} + +template struct FactoryBase { + typedef v8::Local return_t; +}; + +template struct MaybeFactoryBase { + typedef MaybeLocal return_t; +}; + +template struct Factory; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); + static inline return_t New(int length); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(bool value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( v8::ExtensionConfiguration* extensions = NULL + , v8::Local tmpl = v8::Local() + , v8::Local obj = v8::Local()); +}; + +template <> +struct Factory : MaybeFactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(void *value); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( FunctionCallback callback + , v8::Local data = v8::Local()); +}; + +template <> +struct Factory : FactoryBase { + static inline + return_t + New( FunctionCallback callback = NULL + , v8::Local data = v8::Local() + , v8::Local signature = v8::Local()); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(double value); +}; + +template +struct IntegerFactory : FactoryBase { + typedef typename FactoryBase::return_t return_t; + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : IntegerFactory {}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(int32_t value); + static inline return_t New(uint32_t value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(); +}; + +template <> +struct Factory : MaybeFactoryBase { + static inline return_t New( + v8::Local pattern, v8::RegExp::Flags flags); +}; + +template <> +struct Factory : MaybeFactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +template <> +struct Factory : FactoryBase { + typedef v8::Local FTH; + static inline return_t New(FTH receiver = FTH()); +}; + +template <> +struct Factory : MaybeFactoryBase { + static inline return_t New(); + static inline return_t New(const char *value, int length = -1); + static inline return_t New(const uint16_t *value, int length = -1); + static inline return_t New(std::string const& value); + + static inline return_t New(v8::String::ExternalStringResource * value); + static inline return_t New(ExternalOneByteStringResource * value); +}; + +template <> +struct Factory : FactoryBase { + static inline return_t New(v8::Local value); +}; + +} // end of namespace imp + +#if (NODE_MODULE_VERSION >= 12) + +namespace imp { + +template <> +struct Factory : MaybeFactoryBase { + static inline return_t New( v8::Local source); + static inline return_t New( v8::Local source + , v8::ScriptOrigin const& origin); +}; + +} // end of namespace imp + +# include "nan_implementation_12_inl.h" + +#else // NODE_MODULE_VERSION >= 12 + +# include "nan_implementation_pre_12_inl.h" + +#endif + +//=== API ====================================================================== + +template +typename imp::Factory::return_t +New() { + return imp::Factory::New(); +} + +template +typename imp::Factory::return_t +New(A0 arg0) { + return imp::Factory::New(arg0); +} + +template +typename imp::Factory::return_t +New(A0 arg0, A1 arg1) { + return imp::Factory::New(arg0, arg1); +} + +template +typename imp::Factory::return_t +New(A0 arg0, A1 arg1, A2 arg2) { + return imp::Factory::New(arg0, arg1, arg2); +} + +template +typename imp::Factory::return_t +New(A0 arg0, A1 arg1, A2 arg2, A3 arg3) { + return imp::Factory::New(arg0, arg1, arg2, arg3); +} + +// Note(agnat): When passing overloaded function pointers to template functions +// as generic arguments the compiler needs help in picking the right overload. +// These two functions handle New and New with +// all argument variations. + +// v8::Function and v8::FunctionTemplate with one or two arguments +template +typename imp::Factory::return_t +New( FunctionCallback callback + , v8::Local data = v8::Local()) { + return imp::Factory::New(callback, data); +} + +// v8::Function and v8::FunctionTemplate with three arguments +template +typename imp::Factory::return_t +New( FunctionCallback callback + , v8::Local data = v8::Local() + , A2 a2 = A2()) { + return imp::Factory::New(callback, data, a2); +} + +// Convenience + +#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION +template inline v8::Local New(v8::Handle h); +#endif + +#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION +template + inline v8::Local New(v8::Persistent const& p); +#else +template inline v8::Local New(v8::Persistent const& p); +#endif +template +inline v8::Local New(Persistent const& p); +template +inline v8::Local New(Global const& p); + +inline +imp::Factory::return_t +New(bool value) { + return New(value); +} + +inline +imp::Factory::return_t +New(int32_t value) { + return New(value); +} + +inline +imp::Factory::return_t +New(uint32_t value) { + return New(value); +} + +inline +imp::Factory::return_t +New(double value) { + return New(value); +} + +inline +imp::Factory::return_t +New(std::string const& value) { // NOLINT(build/include_what_you_use) + return New(value); +} + +inline +imp::Factory::return_t +New(const char * value, int length) { + return New(value, length); +} + +inline +imp::Factory::return_t +New(const uint16_t * value, int length) { + return New(value, length); +} + +inline +imp::Factory::return_t +New(const char * value) { + return New(value); +} + +inline +imp::Factory::return_t +New(const uint16_t * value) { + return New(value); +} + +inline +imp::Factory::return_t +New(v8::String::ExternalStringResource * value) { + return New(value); +} + +inline +imp::Factory::return_t +New(ExternalOneByteStringResource * value) { + return New(value); +} + +inline +imp::Factory::return_t +New(v8::Local pattern, v8::RegExp::Flags flags) { + return New(pattern, flags); +} + +#endif // NAN_NEW_H_ diff --git a/test/gc/node_modules/nan/nan_object_wrap.h b/test/gc/node_modules/nan/nan_object_wrap.h new file mode 100644 index 00000000000000..632d519b7c52e6 --- /dev/null +++ b/test/gc/node_modules/nan/nan_object_wrap.h @@ -0,0 +1,155 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_OBJECT_WRAP_H_ +#define NAN_OBJECT_WRAP_H_ + +class ObjectWrap { + public: + ObjectWrap() { + refs_ = 0; + } + + + virtual ~ObjectWrap() { + if (persistent().IsEmpty()) { + return; + } + + assert(persistent().IsNearDeath()); + persistent().ClearWeak(); + persistent().Reset(); + } + + + template + static inline T* Unwrap(v8::Local object) { + assert(!object.IsEmpty()); + assert(object->InternalFieldCount() > 0); + // Cast to ObjectWrap before casting to T. A direct cast from void + // to T won't work right when T has more than one base class. + void* ptr = GetInternalFieldPointer(object, 0); + ObjectWrap* wrap = static_cast(ptr); + return static_cast(wrap); + } + + + inline v8::Local handle() { + return New(persistent()); + } + + + inline Persistent& persistent() { + return handle_; + } + + + protected: + inline void Wrap(v8::Local object) { + assert(persistent().IsEmpty()); + assert(object->InternalFieldCount() > 0); + SetInternalFieldPointer(object, 0, this); + persistent().Reset(object); + MakeWeak(); + } + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + + inline void MakeWeak() { + persistent().v8::PersistentBase::SetWeak( + this, WeakCallback, v8::WeakCallbackType::kParameter); + persistent().MarkIndependent(); + } + +#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + + inline void MakeWeak() { + persistent().v8::PersistentBase::SetWeak(this, WeakCallback); + persistent().MarkIndependent(); + } + +#else + + inline void MakeWeak() { + persistent().persistent.MakeWeak(this, WeakCallback); + persistent().MarkIndependent(); + } + +#endif + + /* Ref() marks the object as being attached to an event loop. + * Refed objects will not be garbage collected, even if + * all references are lost. + */ + virtual void Ref() { + assert(!persistent().IsEmpty()); + persistent().ClearWeak(); + refs_++; + } + + /* Unref() marks an object as detached from the event loop. This is its + * default state. When an object with a "weak" reference changes from + * attached to detached state it will be freed. Be careful not to access + * the object after making this call as it might be gone! + * (A "weak reference" means an object that only has a + * persistant handle.) + * + * DO NOT CALL THIS FROM DESTRUCTOR + */ + virtual void Unref() { + assert(!persistent().IsEmpty()); + assert(!persistent().IsWeak()); + assert(refs_ > 0); + if (--refs_ == 0) + MakeWeak(); + } + + int refs_; // ro + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(ObjectWrap) +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + + static void + WeakCallback(v8::WeakCallbackInfo const& info) { + ObjectWrap* wrap = info.GetParameter(); + assert(wrap->refs_ == 0); + assert(wrap->handle_.IsNearDeath()); + wrap->handle_.Reset(); + delete wrap; + } + +#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + + static void + WeakCallback(v8::WeakCallbackData const& data) { + ObjectWrap* wrap = data.GetParameter(); + assert(wrap->refs_ == 0); + assert(wrap->handle_.IsNearDeath()); + wrap->handle_.Reset(); + delete wrap; + } + +#else + + static void WeakCallback(v8::Persistent value, void *data) { + ObjectWrap *wrap = static_cast(data); + assert(wrap->refs_ == 0); + assert(wrap->handle_.IsNearDeath()); + wrap->handle_.Reset(); + delete wrap; + } + +#endif + Persistent handle_; +}; + + +#endif // NAN_OBJECT_WRAP_H_ diff --git a/test/gc/node_modules/nan/nan_persistent_12_inl.h b/test/gc/node_modules/nan/nan_persistent_12_inl.h new file mode 100644 index 00000000000000..0d56f53e16e010 --- /dev/null +++ b/test/gc/node_modules/nan/nan_persistent_12_inl.h @@ -0,0 +1,129 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_PERSISTENT_12_INL_H_ +#define NAN_PERSISTENT_12_INL_H_ + +template class Persistent : + public v8::Persistent { + public: + NAN_INLINE Persistent() : v8::Persistent() {} + + template NAN_INLINE Persistent(v8::Local that) : + v8::Persistent(v8::Isolate::GetCurrent(), that) {} + + template + NAN_INLINE Persistent(const v8::Persistent &that) : + v8::Persistent(v8::Isolate::GetCurrent(), that) {} + + NAN_INLINE void Reset() { v8::PersistentBase::Reset(); } + + template + NAN_INLINE void Reset(const v8::Local &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void Reset(const v8::PersistentBase &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type); + + private: + NAN_INLINE T *operator*() const { return *PersistentBase::persistent; } + + template + NAN_INLINE void Copy(const Persistent &that) { + TYPE_CHECK(T, S); + + this->Reset(); + + if (!that.IsEmpty()) { + this->Reset(that); + M::Copy(that, this); + } + } +}; + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +template +class Global : public v8::Global { + public: + NAN_INLINE Global() : v8::Global() {} + + template NAN_INLINE Global(v8::Local that) : + v8::Global(v8::Isolate::GetCurrent(), that) {} + + template + NAN_INLINE Global(const v8::PersistentBase &that) : + v8::Global(v8::Isolate::GetCurrent(), that) {} + + NAN_INLINE void Reset() { v8::PersistentBase::Reset(); } + + template + NAN_INLINE void Reset(const v8::Local &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void Reset(const v8::PersistentBase &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + reinterpret_cast*>(this)->SetWeak( + parameter, callback, type); + } +}; +#else +template +class Global : public v8::UniquePersistent { + public: + NAN_INLINE Global() : v8::UniquePersistent() {} + + template NAN_INLINE Global(v8::Local that) : + v8::UniquePersistent(v8::Isolate::GetCurrent(), that) {} + + template + NAN_INLINE Global(const v8::PersistentBase &that) : + v8::UniquePersistent(v8::Isolate::GetCurrent(), that) {} + + NAN_INLINE void Reset() { v8::PersistentBase::Reset(); } + + template + NAN_INLINE void Reset(const v8::Local &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void Reset(const v8::PersistentBase &other) { + v8::PersistentBase::Reset(v8::Isolate::GetCurrent(), other); + } + + template + NAN_INLINE void SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + reinterpret_cast*>(this)->SetWeak( + parameter, callback, type); + } +}; +#endif + +#endif // NAN_PERSISTENT_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_persistent_pre_12_inl.h b/test/gc/node_modules/nan/nan_persistent_pre_12_inl.h new file mode 100644 index 00000000000000..fb19aa4c067c31 --- /dev/null +++ b/test/gc/node_modules/nan/nan_persistent_pre_12_inl.h @@ -0,0 +1,242 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_PERSISTENT_PRE_12_INL_H_ +#define NAN_PERSISTENT_PRE_12_INL_H_ + +template +class PersistentBase { + v8::Persistent persistent; + template + friend v8::Local New(const PersistentBase &p); + template + friend v8::Local New(const Persistent &p); + template + friend v8::Local New(const Global &p); + template friend class ReturnValue; + + public: + NAN_INLINE PersistentBase() : + persistent() {} + + NAN_INLINE void Reset() { + persistent.Dispose(); + persistent.Clear(); + } + + template + NAN_INLINE void Reset(const v8::Local &other) { + TYPE_CHECK(T, S); + + if (!persistent.IsEmpty()) { + persistent.Dispose(); + } + + if (other.IsEmpty()) { + persistent.Clear(); + } else { + persistent = v8::Persistent::New(other); + } + } + + template + NAN_INLINE void Reset(const PersistentBase &other) { + TYPE_CHECK(T, S); + + if (!persistent.IsEmpty()) { + persistent.Dispose(); + } + + if (other.IsEmpty()) { + persistent.Clear(); + } else { + persistent = v8::Persistent::New(other.persistent); + } + } + + NAN_INLINE bool IsEmpty() const { return persistent.IsEmpty(); } + + NAN_INLINE void Empty() { persistent.Clear(); } + + template + NAN_INLINE bool operator==(const PersistentBase &that) { + return this->persistent == that.persistent; + } + + template + NAN_INLINE bool operator==(const v8::Local &that) { + return this->persistent == that; + } + + template + NAN_INLINE bool operator!=(const PersistentBase &that) { + return !operator==(that); + } + + template + NAN_INLINE bool operator!=(const v8::Local &that) { + return !operator==(that); + } + + template + NAN_INLINE void SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type); + + NAN_INLINE void ClearWeak() { persistent.ClearWeak(); } + + NAN_INLINE void MarkIndependent() { persistent.MarkIndependent(); } + + NAN_INLINE bool IsIndependent() const { return persistent.IsIndependent(); } + + NAN_INLINE bool IsNearDeath() const { return persistent.IsNearDeath(); } + + NAN_INLINE bool IsWeak() const { return persistent.IsWeak(); } + + private: + NAN_INLINE explicit PersistentBase(v8::Persistent that) : + persistent(that) { } + NAN_INLINE explicit PersistentBase(T *val) : persistent(val) {} + template friend class Persistent; + template friend class Global; + friend class ObjectWrap; +}; + +template +class NonCopyablePersistentTraits { + public: + typedef Persistent > + NonCopyablePersistent; + static const bool kResetInDestructor = false; + template + NAN_INLINE static void Copy(const Persistent &source, + NonCopyablePersistent *dest) { + Uncompilable(); + } + + template NAN_INLINE static void Uncompilable() { + TYPE_CHECK(O, v8::Primitive); + } +}; + +template +struct CopyablePersistentTraits { + typedef Persistent > CopyablePersistent; + static const bool kResetInDestructor = true; + template + static NAN_INLINE void Copy(const Persistent &source, + CopyablePersistent *dest) {} +}; + +template class Persistent : + public PersistentBase { + public: + NAN_INLINE Persistent() {} + + template NAN_INLINE Persistent(v8::Handle that) + : PersistentBase(v8::Persistent::New(that)) { + TYPE_CHECK(T, S); + } + + NAN_INLINE Persistent(const Persistent &that) : PersistentBase() { + Copy(that); + } + + template + NAN_INLINE Persistent(const Persistent &that) : + PersistentBase() { + Copy(that); + } + + NAN_INLINE Persistent &operator=(const Persistent &that) { + Copy(that); + return *this; + } + + template + NAN_INLINE Persistent &operator=(const Persistent &that) { + Copy(that); + return *this; + } + + NAN_INLINE ~Persistent() { + if (M::kResetInDestructor) this->Reset(); + } + + private: + NAN_INLINE T *operator*() const { return *PersistentBase::persistent; } + + template + NAN_INLINE void Copy(const Persistent &that) { + TYPE_CHECK(T, S); + + this->Reset(); + + if (!that.IsEmpty()) { + this->persistent = v8::Persistent::New(that.persistent); + M::Copy(that, this); + } + } +}; + +template +class Global : public PersistentBase { + struct RValue { + NAN_INLINE explicit RValue(Global* obj) : object(obj) {} + Global* object; + }; + + public: + NAN_INLINE Global() : PersistentBase(0) { } + + template + NAN_INLINE Global(v8::Local that) + : PersistentBase(v8::Persistent::New(that)) { + TYPE_CHECK(T, S); + } + + template + NAN_INLINE Global(const PersistentBase &that) + : PersistentBase(that) { + TYPE_CHECK(T, S); + } + /** + * Move constructor. + */ + NAN_INLINE Global(RValue rvalue) + : PersistentBase(rvalue.object->persistent) { + rvalue.object->Reset(); + } + NAN_INLINE ~Global() { this->Reset(); } + /** + * Move via assignment. + */ + template + NAN_INLINE Global &operator=(Global rhs) { + TYPE_CHECK(T, S); + this->Reset(rhs.persistent); + rhs.Reset(); + return *this; + } + /** + * Cast operator for moves. + */ + NAN_INLINE operator RValue() { return RValue(this); } + /** + * Pass allows returning uniques from functions, etc. + */ + Global Pass() { return Global(RValue(this)); } + + private: + Global(Global &); + void operator=(Global &); + template friend class ReturnValue; +}; + +#endif // NAN_PERSISTENT_PRE_12_INL_H_ diff --git a/test/gc/node_modules/nan/nan_string_bytes.h b/test/gc/node_modules/nan/nan_string_bytes.h new file mode 100644 index 00000000000000..a2e6437d12b74c --- /dev/null +++ b/test/gc/node_modules/nan/nan_string_bytes.h @@ -0,0 +1,305 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef NAN_STRING_BYTES_H_ +#define NAN_STRING_BYTES_H_ + +// Decodes a v8::Local or Buffer to a raw char* + +namespace imp { + +using v8::Local; +using v8::Object; +using v8::String; +using v8::Value; + + +//// Base 64 //// + +#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4) + + + +//// HEX //// + +static bool contains_non_ascii_slow(const char* buf, size_t len) { + for (size_t i = 0; i < len; ++i) { + if (buf[i] & 0x80) return true; + } + return false; +} + + +static bool contains_non_ascii(const char* src, size_t len) { + if (len < 16) { + return contains_non_ascii_slow(src, len); + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned unaligned = reinterpret_cast(src) & align_mask; + + if (unaligned > 0) { + const unsigned n = bytes_per_word - unaligned; + if (contains_non_ascii_slow(src, n)) return true; + src += n; + len -= n; + } + + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = 0x8080808080808080ll; +#else + const uintptr_t mask = 0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + if (srcw[i] & mask) return true; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + if (contains_non_ascii_slow(src + offset, remainder)) return true; + } + + return false; +} + + +static void force_ascii_slow(const char* src, char* dst, size_t len) { + for (size_t i = 0; i < len; ++i) { + dst[i] = src[i] & 0x7f; + } +} + + +static void force_ascii(const char* src, char* dst, size_t len) { + if (len < 16) { + force_ascii_slow(src, dst, len); + return; + } + + const unsigned bytes_per_word = sizeof(void*); + const unsigned align_mask = bytes_per_word - 1; + const unsigned src_unalign = reinterpret_cast(src) & align_mask; + const unsigned dst_unalign = reinterpret_cast(dst) & align_mask; + + if (src_unalign > 0) { + if (src_unalign == dst_unalign) { + const unsigned unalign = bytes_per_word - src_unalign; + force_ascii_slow(src, dst, unalign); + src += unalign; + dst += unalign; + len -= src_unalign; + } else { + force_ascii_slow(src, dst, len); + return; + } + } + +#if defined(__x86_64__) || defined(_WIN64) + const uintptr_t mask = ~0x8080808080808080ll; +#else + const uintptr_t mask = ~0x80808080l; +#endif + + const uintptr_t* srcw = reinterpret_cast(src); + uintptr_t* dstw = reinterpret_cast(dst); + + for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) { + dstw[i] = srcw[i] & mask; + } + + const unsigned remainder = len & align_mask; + if (remainder > 0) { + const size_t offset = len - remainder; + force_ascii_slow(src + offset, dst + offset, remainder); + } +} + + +static size_t base64_encode(const char* src, + size_t slen, + char* dst, + size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= base64_encoded_size(slen) && + "not enough space provided for base64 encode"); + + dlen = base64_encoded_size(slen); + + unsigned a; + unsigned b; + unsigned c; + unsigned i; + unsigned k; + unsigned n; + + static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + i = 0; + k = 0; + n = slen / 3 * 3; + + while (i < n) { + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + c = src[i + 2] & 0xff; + + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)]; + dst[k + 3] = table[c & 0x3f]; + + i += 3; + k += 4; + } + + if (n != slen) { + switch (slen - n) { + case 1: + a = src[i + 0] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[(a & 3) << 4]; + dst[k + 2] = '='; + dst[k + 3] = '='; + break; + + case 2: + a = src[i + 0] & 0xff; + b = src[i + 1] & 0xff; + dst[k + 0] = table[a >> 2]; + dst[k + 1] = table[((a & 3) << 4) | (b >> 4)]; + dst[k + 2] = table[(b & 0x0f) << 2]; + dst[k + 3] = '='; + break; + } + } + + return dlen; +} + + +static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) { + // We know how much we'll write, just make sure that there's space. + assert(dlen >= slen * 2 && + "not enough space provided for hex encode"); + + dlen = slen * 2; + for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) { + static const char hex[] = "0123456789abcdef"; + uint8_t val = static_cast(src[i]); + dst[k + 0] = hex[val >> 4]; + dst[k + 1] = hex[val & 15]; + } + + return dlen; +} + + + +static Local Encode(const char* buf, + size_t buflen, + enum Encoding encoding) { + assert(buflen <= node::Buffer::kMaxLength); + if (!buflen && encoding != BUFFER) + return New("").ToLocalChecked(); + + Local val; + switch (encoding) { + case BUFFER: + return CopyBuffer(buf, buflen).ToLocalChecked(); + + case ASCII: + if (contains_non_ascii(buf, buflen)) { + char* out = new char[buflen]; + force_ascii(buf, out, buflen); + val = New(out, buflen).ToLocalChecked(); + delete[] out; + } else { + val = New(buf, buflen).ToLocalChecked(); + } + break; + + case UTF8: + val = New(buf, buflen).ToLocalChecked(); + break; + + case BINARY: { + // TODO(isaacs) use ExternalTwoByteString? + const unsigned char *cbuf = reinterpret_cast(buf); + uint16_t * twobytebuf = new uint16_t[buflen]; + for (size_t i = 0; i < buflen; i++) { + // XXX is the following line platform independent? + twobytebuf[i] = cbuf[i]; + } + val = New(twobytebuf, buflen).ToLocalChecked(); + delete[] twobytebuf; + break; + } + + case BASE64: { + size_t dlen = base64_encoded_size(buflen); + char* dst = new char[dlen]; + + size_t written = base64_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = New(dst, dlen).ToLocalChecked(); + delete[] dst; + break; + } + + case UCS2: { + const uint16_t* data = reinterpret_cast(buf); + val = New(data, buflen / 2).ToLocalChecked(); + break; + } + + case HEX: { + size_t dlen = buflen * 2; + char* dst = new char[dlen]; + size_t written = hex_encode(buf, buflen, dst, dlen); + assert(written == dlen); + + val = New(dst, dlen).ToLocalChecked(); + delete[] dst; + break; + } + + default: + assert(0 && "unknown encoding"); + break; + } + + return val; +} + +#undef base64_encoded_size + +} // end of namespace imp + +#endif // NAN_STRING_BYTES_H_ diff --git a/test/gc/node_modules/nan/nan_typedarray_contents.h b/test/gc/node_modules/nan/nan_typedarray_contents.h new file mode 100644 index 00000000000000..6a7f8b512f34ce --- /dev/null +++ b/test/gc/node_modules/nan/nan_typedarray_contents.h @@ -0,0 +1,87 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_TYPEDARRAY_CONTENTS_H_ +#define NAN_TYPEDARRAY_CONTENTS_H_ + +template +class TypedArrayContents { + public: + NAN_INLINE explicit TypedArrayContents(v8::Local from) : + length_(0), data_(NULL) { + + size_t length = 0; + void* data = NULL; + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + + if (from->IsArrayBufferView()) { + v8::Local array = + v8::Local::Cast(from); + + const size_t byte_length = array->ByteLength(); + const ptrdiff_t byte_offset = array->ByteOffset(); + v8::Local buffer = array->Buffer(); + + length = byte_length / sizeof(T); + data = static_cast(buffer->GetContents().Data()) + byte_offset; + } + +#else + + if (from->IsObject() && !from->IsNull()) { + v8::Local array = v8::Local::Cast(from); + + MaybeLocal buffer = Get(array, + New("buffer").ToLocalChecked()); + MaybeLocal byte_length = Get(array, + New("byteLength").ToLocalChecked()); + MaybeLocal byte_offset = Get(array, + New("byteOffset").ToLocalChecked()); + + if (!buffer.IsEmpty() && + !byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() && + !byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) { + data = array->GetIndexedPropertiesExternalArrayData(); + if(data) { + length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T); + } + } + } + +#endif + +#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L + assert(reinterpret_cast(data) % alignof (T) == 0); +#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__) + assert(reinterpret_cast(data) % __alignof(T) == 0); +#else + assert(reinterpret_cast(data) % sizeof (T) == 0); +#endif + + length_ = length; + data_ = static_cast(data); + } + + NAN_INLINE size_t length() const { return length_; } + NAN_INLINE T* operator*() { return data_; } + NAN_INLINE const T* operator*() const { return data_; } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents) + + //Disable heap allocation + void *operator new(size_t size); + void operator delete(void *, size_t); + + size_t length_; + T* data_; +}; + +#endif // NAN_TYPEDARRAY_CONTENTS_H_ diff --git a/test/gc/node_modules/nan/nan_weak.h b/test/gc/node_modules/nan/nan_weak.h new file mode 100644 index 00000000000000..ed3f92e2d0f4e6 --- /dev/null +++ b/test/gc/node_modules/nan/nan_weak.h @@ -0,0 +1,422 @@ +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +#ifndef NAN_WEAK_H_ +#define NAN_WEAK_H_ + +static const int kInternalFieldsInWeakCallback = 2; +static const int kNoInternalFieldIndex = -1; + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \ + v8::WeakCallbackInfo > const& +# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \ + NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ +#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION +# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \ + v8::PhantomCallbackData > const& +# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \ + NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ +#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION +# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \ + v8::PhantomCallbackData > const& +# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \ + v8::InternalFieldsCallbackData, void> const& +# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ +#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION +# define NAN_WEAK_CALLBACK_DATA_TYPE_ \ + v8::WeakCallbackData > const& +# define NAN_WEAK_CALLBACK_SIG_ NAN_WEAK_CALLBACK_DATA_TYPE_ +#else +# define NAN_WEAK_CALLBACK_DATA_TYPE_ void * +# define NAN_WEAK_CALLBACK_SIG_ \ + v8::Persistent, NAN_WEAK_CALLBACK_DATA_TYPE_ +#endif + +template +class WeakCallbackInfo { + public: + typedef void (*Callback)(const WeakCallbackInfo& data); + WeakCallbackInfo( + Persistent *persistent + , Callback callback + , void *parameter + , void *field1 = 0 + , void *field2 = 0) : + callback_(callback), isolate_(0), parameter_(parameter) { + std::memcpy(&persistent_, persistent, sizeof (v8::Persistent)); + internal_fields_[0] = field1; + internal_fields_[1] = field2; + } + NAN_INLINE v8::Isolate *GetIsolate() const { return isolate_; } + NAN_INLINE T *GetParameter() const { return static_cast(parameter_); } + NAN_INLINE void *GetInternalField(int index) const { + assert((index == 0 || index == 1) && "internal field index out of bounds"); + if (index == 0) { + return internal_fields_[0]; + } else { + return internal_fields_[1]; + } + } + + private: + NAN_DISALLOW_ASSIGN_COPY_MOVE(WeakCallbackInfo) + Callback callback_; + v8::Isolate *isolate_; + void *parameter_; + void *internal_fields_[kInternalFieldsInWeakCallback]; + v8::Persistent persistent_; + template friend class Persistent; + template friend class PersistentBase; +#if NODE_MODULE_VERSION <= NODE_0_12_MODULE_VERSION +# if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + template + static void invoke(NAN_WEAK_CALLBACK_SIG_ data); + template + static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data); +# else + static void invoke(NAN_WEAK_CALLBACK_SIG_ data); + static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data); +# endif +#else + static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data); + static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data); + static WeakCallbackInfo *unwrapparameter( + NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data); + static WeakCallbackInfo *unwraptwofield( + NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data); +#endif +}; + + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + +template +void +WeakCallbackInfo::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwrapparameter(data); + if (data.IsFirstPass()) { + cbinfo->persistent_.Reset(); + data.SetSecondPassCallback(invokeparameter); + } else { + cbinfo->callback_(*cbinfo); + delete cbinfo; + } +} + +template +void +WeakCallbackInfo::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwraptwofield(data); + if (data.IsFirstPass()) { + cbinfo->persistent_.Reset(); + data.SetSecondPassCallback(invoketwofield); + } else { + cbinfo->callback_(*cbinfo); + delete cbinfo; + } +} + +template +WeakCallbackInfo *WeakCallbackInfo::unwrapparameter( + NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) { + WeakCallbackInfo *cbinfo = + static_cast*>(data.GetParameter()); + cbinfo->isolate_ = data.GetIsolate(); + return cbinfo; +} + +template +WeakCallbackInfo *WeakCallbackInfo::unwraptwofield( + NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) { + WeakCallbackInfo *cbinfo = + static_cast*>(data.GetInternalField(0)); + cbinfo->isolate_ = data.GetIsolate(); + return cbinfo; +} + +#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_ +#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_ +#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ +# elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION + +template +void +WeakCallbackInfo::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwrapparameter(data); + cbinfo->persistent_.Reset(); + cbinfo->callback_(*cbinfo); + delete cbinfo; +} + +template +void +WeakCallbackInfo::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwraptwofield(data); + cbinfo->persistent_.Reset(); + cbinfo->callback_(*cbinfo); + delete cbinfo; +} + +template +WeakCallbackInfo *WeakCallbackInfo::unwrapparameter( + NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) { + WeakCallbackInfo *cbinfo = + static_cast*>(data.GetParameter()); + cbinfo->isolate_ = data.GetIsolate(); + return cbinfo; +} + +template +WeakCallbackInfo *WeakCallbackInfo::unwraptwofield( + NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) { + WeakCallbackInfo *cbinfo = + static_cast*>(data.GetInternalField1()); + cbinfo->isolate_ = data.GetIsolate(); + return cbinfo; +} + +#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_ +#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_ +#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ +#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ +#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION + +template +template +void WeakCallbackInfo::invoke(NAN_WEAK_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwrap(data); + cbinfo->persistent_.Reset(); + cbinfo->callback_(*cbinfo); + delete cbinfo; +} + +template +template +WeakCallbackInfo *WeakCallbackInfo::unwrap( + NAN_WEAK_CALLBACK_DATA_TYPE_ data) { + void *parameter = data.GetParameter(); + WeakCallbackInfo *cbinfo = + static_cast*>(parameter); + cbinfo->isolate_ = data.GetIsolate(); + return cbinfo; +} + +#undef NAN_WEAK_CALLBACK_SIG_ +#undef NAN_WEAK_CALLBACK_DATA_TYPE_ +#else + +template +void WeakCallbackInfo::invoke(NAN_WEAK_CALLBACK_SIG_ data) { + WeakCallbackInfo *cbinfo = unwrap(data); + cbinfo->persistent_.Dispose(); + cbinfo->persistent_.Clear(); + cbinfo->callback_(*cbinfo); + delete cbinfo; +} + +template +WeakCallbackInfo *WeakCallbackInfo::unwrap( + NAN_WEAK_CALLBACK_DATA_TYPE_ data) { + WeakCallbackInfo *cbinfo = + static_cast*>(data); + cbinfo->isolate_ = v8::Isolate::GetCurrent(); + return cbinfo; +} + +#undef NAN_WEAK_CALLBACK_SIG_ +#undef NAN_WEAK_CALLBACK_DATA_TYPE_ +#endif + +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) +template +template +NAN_INLINE void Persistent::SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + WeakCallbackInfo

    *wcbd; + if (type == WeakCallbackType::kParameter) { + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , parameter); + v8::PersistentBase::SetWeak( + wcbd + , WeakCallbackInfo

    ::invokeparameter + , type); + } else { + v8::Local* self = reinterpret_cast*>(this); + assert((*self)->IsObject()); + int count = (*self)->InternalFieldCount(); + void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0}; + for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) { + internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i); + } + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , 0 + , internal_fields[0] + , internal_fields[1]); + (*self)->SetAlignedPointerInInternalField(0, wcbd); + v8::PersistentBase::SetWeak( + static_cast*>(0) + , WeakCallbackInfo

    ::invoketwofield + , type); + } +} +#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION +template +template +NAN_INLINE void Persistent::SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + WeakCallbackInfo

    *wcbd; + if (type == WeakCallbackType::kParameter) { + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , parameter); + v8::PersistentBase::SetPhantom( + wcbd + , WeakCallbackInfo

    ::invokeparameter); + } else { + v8::Local* self = reinterpret_cast*>(this); + assert((*self)->IsObject()); + int count = (*self)->InternalFieldCount(); + void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0}; + for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) { + internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i); + } + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , 0 + , internal_fields[0] + , internal_fields[1]); + (*self)->SetAlignedPointerInInternalField(0, wcbd); + v8::PersistentBase::SetPhantom( + static_cast*>(0) + , WeakCallbackInfo

    ::invoketwofield + , 0 + , count > 1 ? 1 : kNoInternalFieldIndex); + } +} +#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION +template +template +NAN_INLINE void Persistent::SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + WeakCallbackInfo

    *wcbd; + if (type == WeakCallbackType::kParameter) { + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , parameter); + v8::PersistentBase::SetPhantom( + wcbd + , WeakCallbackInfo

    ::invokeparameter); + } else { + v8::Local* self = reinterpret_cast*>(this); + assert((*self)->IsObject()); + int count = (*self)->InternalFieldCount(); + void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0}; + for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) { + internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i); + } + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , 0 + , internal_fields[0] + , internal_fields[1]); + (*self)->SetAlignedPointerInInternalField(0, wcbd); + v8::PersistentBase::SetPhantom( + WeakCallbackInfo

    ::invoketwofield + , 0 + , count > 1 ? 1 : kNoInternalFieldIndex); + } +} +#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION +template +template +NAN_INLINE void Persistent::SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + WeakCallbackInfo

    *wcbd; + if (type == WeakCallbackType::kParameter) { + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , parameter); + v8::PersistentBase::SetWeak(wcbd, WeakCallbackInfo

    ::invoke); + } else { + v8::Local* self = reinterpret_cast*>(this); + assert((*self)->IsObject()); + int count = (*self)->InternalFieldCount(); + void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0}; + for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) { + internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i); + } + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , 0 + , internal_fields[0] + , internal_fields[1]); + v8::PersistentBase::SetWeak(wcbd, WeakCallbackInfo

    ::invoke); + } +} +#else +template +template +NAN_INLINE void PersistentBase::SetWeak( + P *parameter + , typename WeakCallbackInfo

    ::Callback callback + , WeakCallbackType type) { + WeakCallbackInfo

    *wcbd; + if (type == WeakCallbackType::kParameter) { + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , parameter); + persistent.MakeWeak(wcbd, WeakCallbackInfo

    ::invoke); + } else { + v8::Local* self = reinterpret_cast*>(this); + assert((*self)->IsObject()); + int count = (*self)->InternalFieldCount(); + void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0}; + for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) { + internal_fields[i] = (*self)->GetPointerFromInternalField(i); + } + wcbd = new WeakCallbackInfo

    ( + reinterpret_cast*>(this) + , callback + , 0 + , internal_fields[0] + , internal_fields[1]); + persistent.MakeWeak(wcbd, WeakCallbackInfo

    ::invoke); + } +} +#endif + +#endif // NAN_WEAK_H_ diff --git a/test/gc/node_modules/nan/package.json b/test/gc/node_modules/nan/package.json new file mode 100644 index 00000000000000..65d397c1e834d9 --- /dev/null +++ b/test/gc/node_modules/nan/package.json @@ -0,0 +1,121 @@ +{ + "_args": [ + [ + "nan@^2.0.5", + "/Users/trott/io.js/test/gc/node_modules/weak" + ] + ], + "_from": "nan@>=2.0.5 <3.0.0", + "_id": "nan@2.3.3", + "_inCache": true, + "_installable": true, + "_location": "/nan", + "_nodeVersion": "5.0.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/nan-2.3.3.tgz_1462313618725_0.044748055282980204" + }, + "_npmUser": { + "email": "bbyholm@abo.fi", + "name": "kkoopa" + }, + "_npmVersion": "3.3.6", + "_phantomChildren": {}, + "_requested": { + "name": "nan", + "raw": "nan@^2.0.5", + "rawSpec": "^2.0.5", + "scope": null, + "spec": ">=2.0.5 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/weak" + ], + "_resolved": "https://registry.npmjs.org/nan/-/nan-2.3.3.tgz", + "_shasum": "64dd83c9704a83648b6c72b401f6384bd94ef16f", + "_shrinkwrap": null, + "_spec": "nan@^2.0.5", + "_where": "/Users/trott/io.js/test/gc/node_modules/weak", + "bugs": { + "url": "https://github.com/nodejs/nan/issues" + }, + "contributors": [ + { + "email": "r@va.gg", + "name": "Rod Vagg", + "url": "https://github.com/rvagg" + }, + { + "email": "bbyholm@abo.fi", + "name": "Benjamin Byholm", + "url": "https://github.com/kkoopa/" + }, + { + "email": "trev.norris@gmail.com", + "name": "Trevor Norris", + "url": "https://github.com/trevnorris" + }, + { + "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", + "url": "https://github.com/TooTallNate" + }, + { + "email": "brett19@gmail.com", + "name": "Brett Lawson", + "url": "https://github.com/brett19" + }, + { + "email": "info@bnoordhuis.nl", + "name": "Ben Noordhuis", + "url": "https://github.com/bnoordhuis" + }, + { + "email": "david@artcom.de", + "name": "David Siegel", + "url": "https://github.com/agnat" + } + ], + "dependencies": {}, + "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 6 compatibility", + "devDependencies": { + "bindings": "~1.2.1", + "commander": "^2.8.1", + "glob": "^5.0.14", + "node-gyp": "~3.0.1", + "tap": "~0.7.1", + "xtend": "~4.0.0" + }, + "directories": {}, + "dist": { + "shasum": "64dd83c9704a83648b6c72b401f6384bd94ef16f", + "tarball": "https://registry.npmjs.org/nan/-/nan-2.3.3.tgz" + }, + "homepage": "https://github.com/nodejs/nan#readme", + "license": "MIT", + "main": "include_dirs.js", + "maintainers": [ + { + "email": "rod@vagg.org", + "name": "rvagg" + }, + { + "email": "bbyholm@abo.fi", + "name": "kkoopa" + } + ], + "name": "nan", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/nodejs/nan.git" + }, + "scripts": { + "docs": "doc/.build.sh", + "rebuild-tests": "node-gyp rebuild --msvs_version=2013 --directory test", + "test": "tap --gc --stderr test/js/*-test.js" + }, + "version": "2.3.3" +} diff --git a/test/gc/node_modules/nan/tools/1to2.js b/test/gc/node_modules/nan/tools/1to2.js new file mode 100755 index 00000000000000..15d156481873f7 --- /dev/null +++ b/test/gc/node_modules/nan/tools/1to2.js @@ -0,0 +1,412 @@ +#!/usr/bin/env node +/********************************************************************* + * NAN - Native Abstractions for Node.js + * + * Copyright (c) 2016 NAN contributors + * + * MIT License + ********************************************************************/ + +var commander = require('commander'), + fs = require('fs'), + glob = require('glob'), + groups = [], + total = 0, + warning1 = '/* ERROR: Rewrite using Buffer */\n', + warning2 = '\\/\\* ERROR\\: Rewrite using Buffer \\*\\/\\n', + length, + i; + +fs.readFile(__dirname + '/package.json', 'utf8', function (err, data) { + if (err) { + throw err; + } + + commander + .version(JSON.parse(data).version) + .usage('[options] ') + .parse(process.argv); + + if (!process.argv.slice(2).length) { + commander.outputHelp(); + } +}); + +/* construct strings representing regular expressions + each expression contains a unique group allowing for identification of the match + the index of this key group, relative to the regular expression in question, + is indicated by the first array member */ + +/* simple substistutions, key group is the entire match, 0 */ +groups.push([0, [ + '_NAN_', + 'NODE_SET_METHOD', + 'NODE_SET_PROTOTYPE_METHOD', + 'NanAsciiString', + 'NanEscapeScope', + 'NanReturnValue', + 'NanUcs2String'].join('|')]); + +/* substitutions of parameterless macros, key group is 1 */ +groups.push([1, ['(', [ + 'NanEscapableScope', + 'NanReturnNull', + 'NanReturnUndefined', + 'NanScope'].join('|'), ')\\(\\)'].join('')]); + +/* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */ +groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']); + +/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */ +groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]); + +/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */ +groups.push([2, ['(', warning2, ')?', '^.*?(', [ + 'GetIndexedPropertiesExternalArrayDataLength', + 'GetIndexedPropertiesExternalArrayData', + 'GetIndexedPropertiesExternalArrayDataType', + 'GetIndexedPropertiesPixelData', + 'GetIndexedPropertiesPixelDataLength', + 'HasIndexedPropertiesInExternalArrayData', + 'HasIndexedPropertiesInPixelData', + 'SetIndexedPropertiesToExternalArrayData', + 'SetIndexedPropertiesToPixelData'].join('|'), ')'].join('')]); + +/* No need for NanScope in V8-exposed methods, key group 2 */ +groups.push([2, ['((', [ + 'NAN_METHOD', + 'NAN_GETTER', + 'NAN_SETTER', + 'NAN_PROPERTY_GETTER', + 'NAN_PROPERTY_SETTER', + 'NAN_PROPERTY_ENUMERATOR', + 'NAN_PROPERTY_DELETER', + 'NAN_PROPERTY_QUERY', + 'NAN_INDEX_GETTER', + 'NAN_INDEX_SETTER', + 'NAN_INDEX_ENUMERATOR', + 'NAN_INDEX_DELETER', + 'NAN_INDEX_QUERY'].join('|'), ')\\([^\\)]*\\)\\s*\\{)\\s*NanScope\\(\\)\\s*;'].join('')]); + +/* v8::Value::ToXXXXXXX returns v8::MaybeLocal, key group 3 */ +groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->(', [ + 'Boolean', + 'Number', + 'String', + 'Object', + 'Integer', + 'Uint32', + 'Int32'].join('|'), ')\\('].join('')]); + +/* v8::Value::XXXXXXXValue returns v8::Maybe, key group 3 */ +groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->((?:', [ + 'Boolean', + 'Number', + 'Integer', + 'Uint32', + 'Int32'].join('|'), ')Value)\\('].join('')]); + +/* NAN_WEAK_CALLBACK macro was removed, write out callback definition, key group 1 */ +groups.push([1, '(NAN_WEAK_CALLBACK)\\(([^\\s\\)]+)\\)']); + +/* node::ObjectWrap and v8::Persistent have been replaced with Nan implementations, key group 1 */ +groups.push([1, ['(', [ + 'NanDisposePersistent', + 'NanObjectWrapHandle'].join('|'), ')\\s*\\(\\s*([^\\s\\)]+)'].join('')]); + +/* Since NanPersistent there is no need for NanMakeWeakPersistent, key group 1 */ +groups.push([1, '(NanMakeWeakPersistent)\\s*\\(\\s*([^\\s,]+)\\s*,\\s*']); + +/* Many methods of v8::Object and others now return v8::MaybeLocal, key group 3 */ +groups.push([3, ['([\\s])([^\\s]+)->(', [ + 'GetEndColumn', + 'GetFunction', + 'GetLineNumber', + 'NewInstance', + 'GetPropertyNames', + 'GetOwnPropertyNames', + 'GetSourceLine', + 'GetStartColumn', + 'ObjectProtoToString', + 'ToArrayIndex', + 'ToDetailString', + 'CallAsConstructor', + 'CallAsFunction', + 'CloneElementAt', + 'Delete', + 'ForceSet', + 'Get', + 'GetPropertyAttributes', + 'GetRealNamedProperty', + 'GetRealNamedPropertyInPrototypeChain', + 'Has', + 'HasOwnProperty', + 'HasRealIndexedProperty', + 'HasRealNamedCallbackProperty', + 'HasRealNamedProperty', + 'Set', + 'SetAccessor', + 'SetIndexedPropertyHandler', + 'SetNamedPropertyHandler', + 'SetPrototype'].join('|'), ')\\('].join('')]); + +/* You should get an error if any of these fail anyways, + or handle the error better, it is indicated either way, key group 2 */ +groups.push([2, ['NanNew(<(?:v8\\:\\:)?(', ['Date', 'String', 'RegExp'].join('|'), ')>)(\\([^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]); + +/* v8::Value::Equals now returns a v8::Maybe, key group 3 */ +groups.push([3, '([\\s\\(\\)])([^\\s\\(\\)]+)->(Equals)\\(([^\\s\\)]+)']); + +/* NanPersistent makes this unnecessary, key group 1 */ +groups.push([1, '(NanAssignPersistent)(?:]+>)?\\(([^,]+),\\s*']); + +/* args has been renamed to info, key group 2 */ +groups.push([2, '(\\W)(args)(\\W)']) + +/* node::ObjectWrap was replaced with NanObjectWrap, key group 2 */ +groups.push([2, '(\\W)(?:node\\:\\:)?(ObjectWrap)(\\W)']); + +/* v8::Persistent was replaced with NanPersistent, key group 2 */ +groups.push([2, '(\\W)(?:v8\\:\\:)?(Persistent)(\\W)']); + +/* counts the number of capturing groups in a well-formed regular expression, + ignoring non-capturing groups and escaped parentheses */ +function groupcount(s) { + var positive = s.match(/\((?!\?)/g), + negative = s.match(/\\\(/g); + return (positive ? positive.length : 0) - (negative ? negative.length : 0); +} + +/* compute the absolute position of each key group in the joined master RegExp */ +for (i = 1, length = groups.length; i < length; i++) { + total += groupcount(groups[i - 1][1]); + groups[i][0] += total; +} + +/* create the master RegExp, whis is the union of all the groups' expressions */ +master = new RegExp(groups.map(function (a) { return a[1]; }).join('|'), 'gm'); + +/* replacement function for String.replace, receives 21 arguments */ +function replace() { + /* simple expressions */ + switch (arguments[groups[0][0]]) { + case '_NAN_': + return 'NAN_'; + case 'NODE_SET_METHOD': + return 'NanSetMethod'; + case 'NODE_SET_PROTOTYPE_METHOD': + return 'NanSetPrototypeMethod'; + case 'NanAsciiString': + return 'NanUtf8String'; + case 'NanEscapeScope': + return 'scope.Escape'; + case 'NanReturnNull': + return 'info.GetReturnValue().SetNull'; + case 'NanReturnValue': + return 'info.GetReturnValue().Set'; + case 'NanUcs2String': + return 'v8::String::Value'; + default: + } + + /* macros without arguments */ + switch (arguments[groups[1][0]]) { + case 'NanEscapableScope': + return 'NanEscapableScope scope' + case 'NanReturnUndefined': + return 'return'; + case 'NanScope': + return 'NanScope scope'; + default: + } + + /* TryCatch, emulate negative backref */ + if (arguments[groups[2][0]] === 'TryCatch') { + return arguments[groups[2][0] - 1] ? arguments[0] : 'NanTryCatch'; + } + + /* NanNew("foo") --> NanNew("foo").ToLocalChecked() */ + if (arguments[groups[3][0]] === 'NanNew') { + return [arguments[0], '.ToLocalChecked()'].join(''); + } + + /* insert warning for removed functions as comment on new line above */ + switch (arguments[groups[4][0]]) { + case 'GetIndexedPropertiesExternalArrayData': + case 'GetIndexedPropertiesExternalArrayDataLength': + case 'GetIndexedPropertiesExternalArrayDataType': + case 'GetIndexedPropertiesPixelData': + case 'GetIndexedPropertiesPixelDataLength': + case 'HasIndexedPropertiesInExternalArrayData': + case 'HasIndexedPropertiesInPixelData': + case 'SetIndexedPropertiesToExternalArrayData': + case 'SetIndexedPropertiesToPixelData': + return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join(''); + default: + } + + /* remove unnecessary NanScope() */ + switch (arguments[groups[5][0]]) { + case 'NAN_GETTER': + case 'NAN_METHOD': + case 'NAN_SETTER': + case 'NAN_INDEX_DELETER': + case 'NAN_INDEX_ENUMERATOR': + case 'NAN_INDEX_GETTER': + case 'NAN_INDEX_QUERY': + case 'NAN_INDEX_SETTER': + case 'NAN_PROPERTY_DELETER': + case 'NAN_PROPERTY_ENUMERATOR': + case 'NAN_PROPERTY_GETTER': + case 'NAN_PROPERTY_QUERY': + case 'NAN_PROPERTY_SETTER': + return arguments[groups[5][0] - 1]; + default: + } + + /* Value converstion */ + switch (arguments[groups[6][0]]) { + case 'Boolean': + case 'Int32': + case 'Integer': + case 'Number': + case 'Object': + case 'String': + case 'Uint32': + return [arguments[groups[6][0] - 2], 'NanTo(', arguments[groups[6][0] - 1]].join(''); + default: + } + + /* other value conversion */ + switch (arguments[groups[7][0]]) { + case 'BooleanValue': + return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); + case 'Int32Value': + return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); + case 'IntegerValue': + return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); + case 'Uint32Value': + return [arguments[groups[7][0] - 2], 'NanTo(', arguments[groups[7][0] - 1]].join(''); + default: + } + + /* NAN_WEAK_CALLBACK */ + if (arguments[groups[8][0]] === 'NAN_WEAK_CALLBACK') { + return ['template\nvoid ', + arguments[groups[8][0] + 1], '(const NanWeakCallbackInfo &data)'].join(''); + } + + /* use methods on NAN classes instead */ + switch (arguments[groups[9][0]]) { + case 'NanDisposePersistent': + return [arguments[groups[9][0] + 1], '.Reset('].join(''); + case 'NanObjectWrapHandle': + return [arguments[groups[9][0] + 1], '->handle('].join(''); + default: + } + + /* use method on NanPersistent instead */ + if (arguments[groups[10][0]] === 'NanMakeWeakPersistent') { + return arguments[groups[10][0] + 1] + '.SetWeak('; + } + + /* These return Maybes, the upper ones take no arguments */ + switch (arguments[groups[11][0]]) { + case 'GetEndColumn': + case 'GetFunction': + case 'GetLineNumber': + case 'GetOwnPropertyNames': + case 'GetPropertyNames': + case 'GetSourceLine': + case 'GetStartColumn': + case 'NewInstance': + case 'ObjectProtoToString': + case 'ToArrayIndex': + case 'ToDetailString': + return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1]].join(''); + case 'CallAsConstructor': + case 'CallAsFunction': + case 'CloneElementAt': + case 'Delete': + case 'ForceSet': + case 'Get': + case 'GetPropertyAttributes': + case 'GetRealNamedProperty': + case 'GetRealNamedPropertyInPrototypeChain': + case 'Has': + case 'HasOwnProperty': + case 'HasRealIndexedProperty': + case 'HasRealNamedCallbackProperty': + case 'HasRealNamedProperty': + case 'Set': + case 'SetAccessor': + case 'SetIndexedPropertyHandler': + case 'SetNamedPropertyHandler': + case 'SetPrototype': + return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1], ', '].join(''); + default: + } + + /* Automatic ToLocalChecked(), take it or leave it */ + switch (arguments[groups[12][0]]) { + case 'Date': + case 'String': + case 'RegExp': + return ['NanNew', arguments[groups[12][0] - 1], arguments[groups[12][0] + 1], '.ToLocalChecked()'].join(''); + default: + } + + /* NanEquals is now required for uniformity */ + if (arguments[groups[13][0]] === 'Equals') { + return [arguments[groups[13][0] - 1], 'NanEquals(', arguments[groups[13][0] - 1], ', ', arguments[groups[13][0] + 1]].join(''); + } + + /* use method on replacement class instead */ + if (arguments[groups[14][0]] === 'NanAssignPersistent') { + return [arguments[groups[14][0] + 1], '.Reset('].join(''); + } + + /* args --> info */ + if (arguments[groups[15][0]] === 'args') { + return [arguments[groups[15][0] - 1], 'info', arguments[groups[15][0] + 1]].join(''); + } + + /* ObjectWrap --> NanObjectWrap */ + if (arguments[groups[16][0]] === 'ObjectWrap') { + return [arguments[groups[16][0] - 1], 'NanObjectWrap', arguments[groups[16][0] + 1]].join(''); + } + + /* Persistent --> NanPersistent */ + if (arguments[groups[17][0]] === 'Persistent') { + return [arguments[groups[17][0] - 1], 'NanPersistent', arguments[groups[17][0] + 1]].join(''); + } + + /* This should not happen. A switch is probably missing a case if it does. */ + throw 'Unhandled match: ' + arguments[0]; +} + +/* reads a file, runs replacement and writes it back */ +function processFile(file) { + fs.readFile(file, {encoding: 'utf8'}, function (err, data) { + if (err) { + throw err; + } + + /* run replacement twice, might need more runs */ + fs.writeFile(file, data.replace(master, replace).replace(master, replace), function (err) { + if (err) { + throw err; + } + }); + }); +} + +/* process file names from command line and process the identified files */ +for (i = 2, length = process.argv.length; i < length; i++) { + glob(process.argv[i], function (err, matches) { + if (err) { + throw err; + } + matches.forEach(processFile); + }); +} diff --git a/test/gc/node_modules/nan/tools/README.md b/test/gc/node_modules/nan/tools/README.md new file mode 100644 index 00000000000000..7f07e4b8256dd1 --- /dev/null +++ b/test/gc/node_modules/nan/tools/README.md @@ -0,0 +1,14 @@ +1to2 naively converts source code files from NAN 1 to NAN 2. There will be erroneous conversions, +false positives and missed opportunities. The input files are rewritten in place. Make sure that +you have backups. You will have to manually review the changes afterwards and do some touchups. + +```sh +$ tools/1to2.js + + Usage: 1to2 [options] + + Options: + + -h, --help output usage information + -V, --version output the version number +``` diff --git a/test/gc/node_modules/nan/tools/package.json b/test/gc/node_modules/nan/tools/package.json new file mode 100644 index 00000000000000..2dcdd789394965 --- /dev/null +++ b/test/gc/node_modules/nan/tools/package.json @@ -0,0 +1,19 @@ +{ + "name": "1to2", + "version": "1.0.0", + "description": "NAN 1 -> 2 Migration Script", + "main": "1to2.js", + "repository": { + "type": "git", + "url": "git://github.com/nodejs/nan.git" + }, + "contributors": [ + "Benjamin Byholm (https://github.com/kkoopa/)", + "Mathias Küsel (https://github.com/mathiask88/)" + ], + "dependencies": { + "glob": "~5.0.10", + "commander": "~2.8.1" + }, + "license": "MIT" +} diff --git a/test/gc/node_modules/weak/.gitignore b/test/gc/node_modules/weak/.gitignore deleted file mode 100644 index 796b96d1c40232..00000000000000 --- a/test/gc/node_modules/weak/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/test/gc/node_modules/weak/LICENSE b/test/gc/node_modules/weak/LICENSE index 834ec929b0b05b..6fc8b65191e3a7 100644 --- a/test/gc/node_modules/weak/LICENSE +++ b/test/gc/node_modules/weak/LICENSE @@ -10,4 +10,4 @@ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/test/gc/node_modules/weak/README.md b/test/gc/node_modules/weak/README.md index 9e8a9166bca08a..c153bb509c737a 100644 --- a/test/gc/node_modules/weak/README.md +++ b/test/gc/node_modules/weak/README.md @@ -1,7 +1,8 @@ node-weak ========= ### Make weak references to JavaScript Objects. -[![Build Status](https://secure.travis-ci.org/TooTallNate/node-weak.png)](http://travis-ci.org/TooTallNate/node-weak) +[![Build Status](https://travis-ci.org/TooTallNate/node-weak.svg?branch=master)](https://travis-ci.org/TooTallNate/node-weak) +[![Build Status](https://ci.appveyor.com/api/projects/status/09lf09d1a5hm24bq?svg=true)](https://ci.appveyor.com/project/TooTallNate/node-weak) On certain rarer occasions, you run into the need to be notified when a JavaScript object is going to be garbage collected. This feature is exposed to V8's C++ API, @@ -44,18 +45,10 @@ var obj = { , foo: 'bar' } -// The function to call before Garbage Collection. -// Note that by the time this is called, 'obj' has been set to `null`. -function cleanup (o) { - delete o.a - delete o.foo -} - // Here's where we set up the weak reference var ref = weak(obj, function () { - // `this` inside the callback is the 'obj'. DO NOT store any new references - // to the object, and DO NOT use the object in any async functions. - cleanup(this) + // `this` inside the callback is the EventEmitter. + console.log('"obj" has been garbage collected!') }) // While `obj` is alive, `ref` proxies everything to it, so: @@ -74,41 +67,97 @@ typeof ref.foo === 'undefined' ``` +Weak Callback Function "Best Practices" +--------------------------------------- + +It's important to be careful when using the "callbacks" feature of `node-weak`, +otherwise you can end up in a situation where the watched object will never +be garbage collected. + +You _should **not**_ define the callback function in the same scope as the +object that is being watched. It's often best to define the callback function +at the highest scope possible (top-level being the best). Named functions +work really well for this: + +``` js +var http = require('http') + , weak = require('weak') + +http.createServer(function (req, res) { + weak(req, gcReq) + weak(res, gcRes) + res.end('Hello World\n') +}).listen(3000) + +function gcReq () { + console.log('GC\'d `req` object') +} + +function gcRes () { + console.log('GC\'d `res` object') +} +``` + + API --- -### weakref weak(Object obj [, Function callback]) +### Weakref weak(Object obj [, Function callback]) The main exports is the function that creates the weak reference. The first argument is the Object that should be monitored. The Object can be a regular Object, an Array, a Function, a RegExp, or any of the primitive types or constructor function created with `new`. + Optionally, you can set a callback function to be invoked before the object is garbage collected. -### Object weak.get(weakref ref) +### Object weak.get(Weakref ref) `get()` returns the actual reference to the Object that this weak reference was created with. If this is called with a dead reference, `undefined` is returned. -### Boolean weak.isDead(weakref ref) +### Boolean weak.isDead(Weakref ref) Checks to see if `ref` is a dead reference. Returns `true` if the original Object has already been GC'd, `false` otherwise. -### null weak.addCallback(weakref ref, Function callback) +### Boolean weak.isNearDeath(Weakref ref) + +Checks to see if `ref` is "near death". This will be `true` exactly during the +weak reference callback function, and `false` any other time. + + +### Boolean weak.isWeakRef(Object obj) + +Checks to see if `obj` is "weak reference" instance. Returns `true` if the +passed in object is a "weak reference", `false` otherwise. + + +### EventEmitter weak.addCallback(Weakref ref, Function callback) Adds `callback` to the Array of callback functions that will be invoked before the -Objects gets garbage collected. The callbacks get executed in the order that they +Object gets garbage collected. The callbacks get executed in the order that they are added. -### Array weak.callbacks(weakref ref) +### EventEmitter weak.removeCallback(Weakref ref, Function callback) + +Removes `callback` from the Array of callback functions that will be invoked before +the Object gets garbage collected. + + +### EventEmitter weak.removeCallbacks(Weakref ref) + +Empties the Array of callback functions that will be invoked before the Object gets +garbage collected. + + +### Array weak.callbacks(Weakref ref) -Returns the internal `Array` that `ref` iterates through to invoke the GC -callbacks. The array can be `push()`ed or `unshift()`ed onto, to have more control -over the execution order of the callbacks. This is similar in concept to node's -`EventEmitter#listeners()` function. +Returns an Array that `ref` iterates through to invoke the GC callbacks. This +utilizes node's `EventEmitter#listeners()` function and therefore returns a copy +in node 0.10 and newer. diff --git a/test/gc/node_modules/weak/appveyor.yml b/test/gc/node_modules/weak/appveyor.yml new file mode 100644 index 00000000000000..ba8a361993d9cc --- /dev/null +++ b/test/gc/node_modules/weak/appveyor.yml @@ -0,0 +1,49 @@ +# http://www.appveyor.com/docs/appveyor-yml + +# Test against these versions of Node.js. +environment: + # Visual Studio Version + MSVS_VERSION: 2013 + # Test against these versions of Node.js and io.js + matrix: + # node.js + - nodejs_version: "0.8" + - nodejs_version: "0.10" + - nodejs_version: "0.12" + # io.js + - nodejs_version: "2" + - nodejs_version: "3" + - nodejs_version: "4" + - nodejs_version: "5" + +platform: + - x86 + - x64 + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node 0.STABLE.latest + - ps: if($env:nodejs_version -eq "0.8") {Install-Product node $env:nodejs_version} + - ps: if($env:nodejs_version -ne "0.8") {Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)} + # Node 0.8 comes with a too obsolete npm + - IF %nodejs_version% == 0.8 (npm install -g npm@1.4.28) + # Install latest NPM only for node.js versions until built in node-gyp adds io.js support + # Update is required for node.js 0.8 because built in npm(node-gyp) does not know VS2013 + - IF %nodejs_version% LSS 1 (npm install -g npm@2) + - IF %nodejs_version% LSS 1 set PATH=%APPDATA%\npm;%PATH% + # Typical npm stuff. + - npm install --msvs_version=%MSVS_VERSION% + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - node --version + - npm --version + # run tests + - npm test + +# Don't actually build. +build: off + +# Set build version format here instead of in the admin panel. +version: "{build}" diff --git a/test/gc/node_modules/weak/binding.gyp b/test/gc/node_modules/weak/binding.gyp index 68e9eb19913779..7f64dc1b08a24a 100644 --- a/test/gc/node_modules/weak/binding.gyp +++ b/test/gc/node_modules/weak/binding.gyp @@ -1,8 +1,9 @@ { - 'targets': [ - { - 'target_name': 'weakref', - 'sources': [ 'src/weakref.cc' ] - } - ] + 'targets': [{ + 'target_name': 'weakref', + 'sources': [ 'src/weakref.cc' ], + 'include_dirs': [ + '> $(depfile) +# Add extra rules as in (2). +# We remove slashes and replace spaces with new lines; +# remove blank lines; +# delete the first line and append a colon to the remaining lines. +sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ + grep -v '^$$' |\ + sed -e 1d -e 's|$$|:|' \ + >> $(depfile) +rm $(depfile).raw +endef + +# Command definitions: +# - cmd_foo is the actual command to run; +# - quiet_cmd_foo is the brief-output summary of the command. + +quiet_cmd_cc = CC($(TOOLSET)) $@ +cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< + +quiet_cmd_cxx = CXX($(TOOLSET)) $@ +cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< + +quiet_cmd_objc = CXX($(TOOLSET)) $@ +cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< + +quiet_cmd_objcxx = CXX($(TOOLSET)) $@ +cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< + +# Commands for precompiled header files. +quiet_cmd_pch_c = CXX($(TOOLSET)) $@ +cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< +quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ +cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< +quiet_cmd_pch_m = CXX($(TOOLSET)) $@ +cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< +quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ +cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< + +# gyp-mac-tool is written next to the root Makefile by gyp. +# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd +# already. +quiet_cmd_mac_tool = MACTOOL $(4) $< +cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" + +quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ +cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) + +quiet_cmd_infoplist = INFOPLIST $@ +cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" + +quiet_cmd_touch = TOUCH $@ +cmd_touch = touch $@ + +quiet_cmd_copy = COPY $@ +# send stderr to /dev/null to ignore messages when linking directories. +cmd_copy = rm -rf "$@" && cp -af "$<" "$@" + +quiet_cmd_alink = LIBTOOL-STATIC $@ +cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) + +quiet_cmd_link = LINK($(TOOLSET)) $@ +cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink = SOLINK($(TOOLSET)) $@ +cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ +cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) + + +# Define an escape_quotes function to escape single quotes. +# This allows us to handle quotes properly as long as we always use +# use single quotes and escape_quotes. +escape_quotes = $(subst ','\'',$(1)) +# This comment is here just to include a ' to unconfuse syntax highlighting. +# Define an escape_vars function to escape '$' variable syntax. +# This allows us to read/write command lines with shell variables (e.g. +# $LD_LIBRARY_PATH), without triggering make substitution. +escape_vars = $(subst $$,$$$$,$(1)) +# Helper that expands to a shell command to echo a string exactly as it is in +# make. This uses printf instead of echo because printf's behaviour with respect +# to escape sequences is more portable than echo's across different shells +# (e.g., dash, bash). +exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' + +# Helper to compare the command we're about to run against the command +# we logged the last time we ran the command. Produces an empty +# string (false) when the commands match. +# Tricky point: Make has no string-equality test function. +# The kernel uses the following, but it seems like it would have false +# positives, where one string reordered its arguments. +# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ +# $(filter-out $(cmd_$@), $(cmd_$(1)))) +# We instead substitute each for the empty string into the other, and +# say they're equal if both substitutions produce the empty string. +# .d files contain ? instead of spaces, take that into account. +command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ + $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) + +# Helper that is non-empty when a prerequisite changes. +# Normally make does this implicitly, but we force rules to always run +# so we can check their command lines. +# $? -- new prerequisites +# $| -- order-only dependencies +prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) + +# Helper that executes all postbuilds until one fails. +define do_postbuilds + @E=0;\ + for p in $(POSTBUILDS); do\ + eval $$p;\ + E=$$?;\ + if [ $$E -ne 0 ]; then\ + break;\ + fi;\ + done;\ + if [ $$E -ne 0 ]; then\ + rm -rf "$@";\ + exit $$E;\ + fi +endef + +# do_cmd: run a command via the above cmd_foo names, if necessary. +# Should always run for a given target to handle command-line changes. +# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. +# Third argument, if non-zero, makes it do POSTBUILDS processing. +# Note: We intentionally do NOT call dirx for depfile, since it contains ? for +# spaces already and dirx strips the ? characters. +define do_cmd +$(if $(or $(command_changed),$(prereq_changed)), + @$(call exact_echo, $($(quiet)cmd_$(1))) + @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" + $(if $(findstring flock,$(word 2,$(cmd_$1))), + @$(cmd_$(1)) + @echo " $(quiet_cmd_$(1)): Finished", + @$(cmd_$(1)) + ) + @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) + @$(if $(2),$(fixup_dep)) + $(if $(and $(3), $(POSTBUILDS)), + $(call do_postbuilds) + ) +) +endef + +# Declare the "all" target first so it is the default, +# even though we don't have the deps yet. +.PHONY: all +all: + +# make looks for ways to re-generate included makefiles, but in our case, we +# don't have a direct way. Explicitly telling make that it has nothing to do +# for them makes it go faster. +%.d: ; + +# Use FORCE_DO_CMD to force a target to run. Should be coupled with +# do_cmd. +.PHONY: FORCE_DO_CMD +FORCE_DO_CMD: + +TOOLSET := target +# Suffix rules, putting all outputs into $(obj). +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + +# Try building from generated source, too. +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + +$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD + @$(call do_cmd,cxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD + @$(call do_cmd,objc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD + @$(call do_cmd,objcxx,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD + @$(call do_cmd,cc,1) +$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD + @$(call do_cmd,cc,1) + + +ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ + $(findstring $(join ^,$(prefix)),\ + $(join ^,weakref.target.mk)))),) + include weakref.target.mk +endif + +quiet_cmd_regen_makefile = ACTION Regenerating $@ +cmd_regen_makefile = cd $(srcdir); /Users/trott/io.js/deps/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/trott/io.js/test/gc/node_modules/weak/build/config.gypi -I/Users/trott/io.js/deps/npm/node_modules/node-gyp/addon.gypi -I/Users/trott/io.js/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/trott/io.js" "-Dnode_gyp_dir=/Users/trott/io.js/deps/npm/node_modules/node-gyp" "-Dnode_lib_file=node.lib" "-Dmodule_root_dir=/Users/trott/io.js/test/gc/node_modules/weak" binding.gyp +Makefile: $(srcdir)/../../../../deps/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../common.gypi + $(call do_cmd,regen_makefile) + +# "all" is a concatenation of the "all" targets from all the included +# sub-makefiles. This is just here to clarify. +all: + +# Add in dependency-tracking rules. $(all_deps) is the list of every single +# target in our tree. Only consider the ones with .d (dependency) info: +d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) +ifneq ($(d_files),) + include $(d_files) +endif diff --git a/test/gc/node_modules/weak/build/binding.Makefile b/test/gc/node_modules/weak/build/binding.Makefile new file mode 100644 index 00000000000000..a3963920496181 --- /dev/null +++ b/test/gc/node_modules/weak/build/binding.Makefile @@ -0,0 +1,6 @@ +# This file is generated by gyp; do not edit. + +export builddir_name ?= ./build/. +.PHONY: all +all: + $(MAKE) weakref diff --git a/test/gc/node_modules/weak/build/config.gypi b/test/gc/node_modules/weak/build/config.gypi new file mode 100644 index 00000000000000..9354987d41ab17 --- /dev/null +++ b/test/gc/node_modules/weak/build/config.gypi @@ -0,0 +1,56 @@ +# Do not edit. File was generated by node-gyp's "configure" step +{ + "target_defaults": { + "cflags": [], + "default_configuration": "Release", + "defines": [], + "include_dirs": [], + "libraries": [] + }, + "variables": { + "asan": 0, + "host_arch": "x64", + "icu_data_file": "icudt57l.dat", + "icu_data_in": "../../deps/icu-small/source/data/in/icudt57l.dat", + "icu_endianness": "l", + "icu_gyp_path": "tools/icu/icu-generic.gyp", + "icu_locales": "en,root", + "icu_path": "deps/icu-small", + "icu_small": "true", + "icu_ver_major": "57", + "llvm_version": 0, + "node_byteorder": "little", + "node_enable_v8_vtunejit": "false", + "node_install_npm": "true", + "node_no_browser_globals": "false", + "node_prefix": "/usr/local", + "node_release_urlbase": "", + "node_shared_cares": "false", + "node_shared_http_parser": "false", + "node_shared_libuv": "false", + "node_shared_openssl": "false", + "node_shared_zlib": "false", + "node_tag": "", + "node_use_dtrace": "true", + "node_use_etw": "false", + "node_use_lttng": "false", + "node_use_openssl": "true", + "node_use_perfctr": "false", + "openssl_fips": "", + "openssl_no_asm": 0, + "target_arch": "x64", + "uv_parent_path": "/deps/uv/", + "uv_use_dtrace": "true", + "v8_enable_gdbjit": 0, + "v8_enable_i18n_support": 1, + "v8_no_strict_aliasing": 1, + "v8_optimized_debug": 0, + "v8_random_seed": 0, + "v8_use_snapshot": "true", + "want_separate_host_toolset": 0, + "xcode_version": "7.0", + "nodedir": "/Users/trott/io.js", + "copy_dev_lib": "false", + "standalone_static_library": 1 + } +} diff --git a/test/gc/node_modules/weak/build/gyp-mac-tool b/test/gc/node_modules/weak/build/gyp-mac-tool new file mode 100755 index 00000000000000..8ef02b0493a003 --- /dev/null +++ b/test/gc/node_modules/weak/build/gyp-mac-tool @@ -0,0 +1,611 @@ +#!/usr/bin/env python +# Generated by gyp. Do not edit. +# Copyright (c) 2012 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Utility functions to perform Xcode-style build steps. + +These functions are executed via gyp-mac-tool when using the Makefile generator. +""" + +import fcntl +import fnmatch +import glob +import json +import os +import plistlib +import re +import shutil +import string +import subprocess +import sys +import tempfile + + +def main(args): + executor = MacTool() + exit_code = executor.Dispatch(args) + if exit_code is not None: + sys.exit(exit_code) + + +class MacTool(object): + """This class performs all the Mac tooling steps. The methods can either be + executed directly, or dispatched from an argument list.""" + + def Dispatch(self, args): + """Dispatches a string command to a method.""" + if len(args) < 1: + raise Exception("Not enough arguments") + + method = "Exec%s" % self._CommandifyName(args[0]) + return getattr(self, method)(*args[1:]) + + def _CommandifyName(self, name_string): + """Transforms a tool name like copy-info-plist to CopyInfoPlist""" + return name_string.title().replace('-', '') + + def ExecCopyBundleResource(self, source, dest, convert_to_binary): + """Copies a resource file to the bundle/Resources directory, performing any + necessary compilation on each resource.""" + extension = os.path.splitext(source)[1].lower() + if os.path.isdir(source): + # Copy tree. + # TODO(thakis): This copies file attributes like mtime, while the + # single-file branch below doesn't. This should probably be changed to + # be consistent with the single-file branch. + if os.path.exists(dest): + shutil.rmtree(dest) + shutil.copytree(source, dest) + elif extension == '.xib': + return self._CopyXIBFile(source, dest) + elif extension == '.storyboard': + return self._CopyXIBFile(source, dest) + elif extension == '.strings': + self._CopyStringsFile(source, dest, convert_to_binary) + else: + shutil.copy(source, dest) + + def _CopyXIBFile(self, source, dest): + """Compiles a XIB file with ibtool into a binary plist in the bundle.""" + + # ibtool sometimes crashes with relative paths. See crbug.com/314728. + base = os.path.dirname(os.path.realpath(__file__)) + if os.path.relpath(source): + source = os.path.join(base, source) + if os.path.relpath(dest): + dest = os.path.join(base, dest) + + args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', + '--output-format', 'human-readable-text', '--compile', dest, source] + ibtool_section_re = re.compile(r'/\*.*\*/') + ibtool_re = re.compile(r'.*note:.*is clipping its content') + ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE) + current_section_header = None + for line in ibtoolout.stdout: + if ibtool_section_re.match(line): + current_section_header = line + elif not ibtool_re.match(line): + if current_section_header: + sys.stdout.write(current_section_header) + current_section_header = None + sys.stdout.write(line) + return ibtoolout.returncode + + def _ConvertToBinary(self, dest): + subprocess.check_call([ + 'xcrun', 'plutil', '-convert', 'binary1', '-o', dest, dest]) + + def _CopyStringsFile(self, source, dest, convert_to_binary): + """Copies a .strings file using iconv to reconvert the input into UTF-16.""" + input_code = self._DetectInputEncoding(source) or "UTF-8" + + # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call + # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints + # CFPropertyListCreateFromXMLData(): Old-style plist parser: missing + # semicolon in dictionary. + # on invalid files. Do the same kind of validation. + import CoreFoundation + s = open(source, 'rb').read() + d = CoreFoundation.CFDataCreate(None, s, len(s)) + _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None) + if error: + return + + fp = open(dest, 'wb') + fp.write(s.decode(input_code).encode('UTF-16')) + fp.close() + + if convert_to_binary == 'True': + self._ConvertToBinary(dest) + + def _DetectInputEncoding(self, file_name): + """Reads the first few bytes from file_name and tries to guess the text + encoding. Returns None as a guess if it can't detect it.""" + fp = open(file_name, 'rb') + try: + header = fp.read(3) + except e: + fp.close() + return None + fp.close() + if header.startswith("\xFE\xFF"): + return "UTF-16" + elif header.startswith("\xFF\xFE"): + return "UTF-16" + elif header.startswith("\xEF\xBB\xBF"): + return "UTF-8" + else: + return None + + def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys): + """Copies the |source| Info.plist to the destination directory |dest|.""" + # Read the source Info.plist into memory. + fd = open(source, 'r') + lines = fd.read() + fd.close() + + # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). + plist = plistlib.readPlistFromString(lines) + if keys: + plist = dict(plist.items() + json.loads(keys[0]).items()) + lines = plistlib.writePlistToString(plist) + + # Go through all the environment variables and replace them as variables in + # the file. + IDENT_RE = re.compile(r'[/\s]') + for key in os.environ: + if key.startswith('_'): + continue + evar = '${%s}' % key + evalue = os.environ[key] + lines = string.replace(lines, evar, evalue) + + # Xcode supports various suffices on environment variables, which are + # all undocumented. :rfc1034identifier is used in the standard project + # template these days, and :identifier was used earlier. They are used to + # convert non-url characters into things that look like valid urls -- + # except that the replacement character for :identifier, '_' isn't valid + # in a URL either -- oops, hence :rfc1034identifier was born. + evar = '${%s:identifier}' % key + evalue = IDENT_RE.sub('_', os.environ[key]) + lines = string.replace(lines, evar, evalue) + + evar = '${%s:rfc1034identifier}' % key + evalue = IDENT_RE.sub('-', os.environ[key]) + lines = string.replace(lines, evar, evalue) + + # Remove any keys with values that haven't been replaced. + lines = lines.split('\n') + for i in range(len(lines)): + if lines[i].strip().startswith("${"): + lines[i] = None + lines[i - 1] = None + lines = '\n'.join(filter(lambda x: x is not None, lines)) + + # Write out the file with variables replaced. + fd = open(dest, 'w') + fd.write(lines) + fd.close() + + # Now write out PkgInfo file now that the Info.plist file has been + # "compiled". + self._WritePkgInfo(dest) + + if convert_to_binary == 'True': + self._ConvertToBinary(dest) + + def _WritePkgInfo(self, info_plist): + """This writes the PkgInfo file from the data stored in Info.plist.""" + plist = plistlib.readPlist(info_plist) + if not plist: + return + + # Only create PkgInfo for executable types. + package_type = plist['CFBundlePackageType'] + if package_type != 'APPL': + return + + # The format of PkgInfo is eight characters, representing the bundle type + # and bundle signature, each four characters. If that is missing, four + # '?' characters are used instead. + signature_code = plist.get('CFBundleSignature', '????') + if len(signature_code) != 4: # Wrong length resets everything, too. + signature_code = '?' * 4 + + dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') + fp = open(dest, 'w') + fp.write('%s%s' % (package_type, signature_code)) + fp.close() + + def ExecFlock(self, lockfile, *cmd_list): + """Emulates the most basic behavior of Linux's flock(1).""" + # Rely on exception handling to report errors. + fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) + fcntl.flock(fd, fcntl.LOCK_EX) + return subprocess.call(cmd_list) + + def ExecFilterLibtool(self, *cmd_list): + """Calls libtool and filters out '/path/to/libtool: file: foo.o has no + symbols'.""" + libtool_re = re.compile(r'^.*libtool: file: .* has no symbols$') + libtool_re5 = re.compile( + r'^.*libtool: warning for library: ' + + r'.* the table of contents is empty ' + + r'\(no object file members in the library define global symbols\)$') + env = os.environ.copy() + # Ref: + # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c + # The problem with this flag is that it resets the file mtime on the file to + # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on timezone. + env['ZERO_AR_DATE'] = '1' + libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env) + _, err = libtoolout.communicate() + for line in err.splitlines(): + if not libtool_re.match(line) and not libtool_re5.match(line): + print >>sys.stderr, line + # Unconditionally touch the output .a file on the command line if present + # and the command succeeded. A bit hacky. + if not libtoolout.returncode: + for i in range(len(cmd_list) - 1): + if cmd_list[i] == "-o" and cmd_list[i+1].endswith('.a'): + os.utime(cmd_list[i+1], None) + break + return libtoolout.returncode + + def ExecPackageFramework(self, framework, version): + """Takes a path to Something.framework and the Current version of that and + sets up all the symlinks.""" + # Find the name of the binary based on the part before the ".framework". + binary = os.path.basename(framework).split('.')[0] + + CURRENT = 'Current' + RESOURCES = 'Resources' + VERSIONS = 'Versions' + + if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): + # Binary-less frameworks don't seem to contain symlinks (see e.g. + # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). + return + + # Move into the framework directory to set the symlinks correctly. + pwd = os.getcwd() + os.chdir(framework) + + # Set up the Current version. + self._Relink(version, os.path.join(VERSIONS, CURRENT)) + + # Set up the root symlinks. + self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) + self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) + + # Back to where we were before! + os.chdir(pwd) + + def _Relink(self, dest, link): + """Creates a symlink to |dest| named |link|. If |link| already exists, + it is overwritten.""" + if os.path.lexists(link): + os.remove(link) + os.symlink(dest, link) + + def ExecCompileXcassets(self, keys, *inputs): + """Compiles multiple .xcassets files into a single .car file. + + This invokes 'actool' to compile all the inputs .xcassets files. The + |keys| arguments is a json-encoded dictionary of extra arguments to + pass to 'actool' when the asset catalogs contains an application icon + or a launch image. + + Note that 'actool' does not create the Assets.car file if the asset + catalogs does not contains imageset. + """ + command_line = [ + 'xcrun', 'actool', '--output-format', 'human-readable-text', + '--compress-pngs', '--notices', '--warnings', '--errors', + ] + is_iphone_target = 'IPHONEOS_DEPLOYMENT_TARGET' in os.environ + if is_iphone_target: + platform = os.environ['CONFIGURATION'].split('-')[-1] + if platform not in ('iphoneos', 'iphonesimulator'): + platform = 'iphonesimulator' + command_line.extend([ + '--platform', platform, '--target-device', 'iphone', + '--target-device', 'ipad', '--minimum-deployment-target', + os.environ['IPHONEOS_DEPLOYMENT_TARGET'], '--compile', + os.path.abspath(os.environ['CONTENTS_FOLDER_PATH']), + ]) + else: + command_line.extend([ + '--platform', 'macosx', '--target-device', 'mac', + '--minimum-deployment-target', os.environ['MACOSX_DEPLOYMENT_TARGET'], + '--compile', + os.path.abspath(os.environ['UNLOCALIZED_RESOURCES_FOLDER_PATH']), + ]) + if keys: + keys = json.loads(keys) + for key, value in keys.iteritems(): + arg_name = '--' + key + if isinstance(value, bool): + if value: + command_line.append(arg_name) + elif isinstance(value, list): + for v in value: + command_line.append(arg_name) + command_line.append(str(v)) + else: + command_line.append(arg_name) + command_line.append(str(value)) + # Note: actool crashes if inputs path are relative, so use os.path.abspath + # to get absolute path name for inputs. + command_line.extend(map(os.path.abspath, inputs)) + subprocess.check_call(command_line) + + def ExecMergeInfoPlist(self, output, *inputs): + """Merge multiple .plist files into a single .plist file.""" + merged_plist = {} + for path in inputs: + plist = self._LoadPlistMaybeBinary(path) + self._MergePlist(merged_plist, plist) + plistlib.writePlist(merged_plist, output) + + def ExecCodeSignBundle(self, key, resource_rules, entitlements, provisioning): + """Code sign a bundle. + + This function tries to code sign an iOS bundle, following the same + algorithm as Xcode: + 1. copy ResourceRules.plist from the user or the SDK into the bundle, + 2. pick the provisioning profile that best match the bundle identifier, + and copy it into the bundle as embedded.mobileprovision, + 3. copy Entitlements.plist from user or SDK next to the bundle, + 4. code sign the bundle. + """ + resource_rules_path = self._InstallResourceRules(resource_rules) + substitutions, overrides = self._InstallProvisioningProfile( + provisioning, self._GetCFBundleIdentifier()) + entitlements_path = self._InstallEntitlements( + entitlements, substitutions, overrides) + subprocess.check_call([ + 'codesign', '--force', '--sign', key, '--resource-rules', + resource_rules_path, '--entitlements', entitlements_path, + os.path.join( + os.environ['TARGET_BUILD_DIR'], + os.environ['FULL_PRODUCT_NAME'])]) + + def _InstallResourceRules(self, resource_rules): + """Installs ResourceRules.plist from user or SDK into the bundle. + + Args: + resource_rules: string, optional, path to the ResourceRules.plist file + to use, default to "${SDKROOT}/ResourceRules.plist" + + Returns: + Path to the copy of ResourceRules.plist into the bundle. + """ + source_path = resource_rules + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['CONTENTS_FOLDER_PATH'], + 'ResourceRules.plist') + if not source_path: + source_path = os.path.join( + os.environ['SDKROOT'], 'ResourceRules.plist') + shutil.copy2(source_path, target_path) + return target_path + + def _InstallProvisioningProfile(self, profile, bundle_identifier): + """Installs embedded.mobileprovision into the bundle. + + Args: + profile: string, optional, short name of the .mobileprovision file + to use, if empty or the file is missing, the best file installed + will be used + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + + Returns: + A tuple containing two dictionary: variables substitutions and values + to overrides when generating the entitlements file. + """ + source_path, provisioning_data, team_id = self._FindProvisioningProfile( + profile, bundle_identifier) + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['CONTENTS_FOLDER_PATH'], + 'embedded.mobileprovision') + shutil.copy2(source_path, target_path) + substitutions = self._GetSubstitutions(bundle_identifier, team_id + '.') + return substitutions, provisioning_data['Entitlements'] + + def _FindProvisioningProfile(self, profile, bundle_identifier): + """Finds the .mobileprovision file to use for signing the bundle. + + Checks all the installed provisioning profiles (or if the user specified + the PROVISIONING_PROFILE variable, only consult it) and select the most + specific that correspond to the bundle identifier. + + Args: + profile: string, optional, short name of the .mobileprovision file + to use, if empty or the file is missing, the best file installed + will be used + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + + Returns: + A tuple of the path to the selected provisioning profile, the data of + the embedded plist in the provisioning profile and the team identifier + to use for code signing. + + Raises: + SystemExit: if no .mobileprovision can be used to sign the bundle. + """ + profiles_dir = os.path.join( + os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles') + if not os.path.isdir(profiles_dir): + print >>sys.stderr, ( + 'cannot find mobile provisioning for %s' % bundle_identifier) + sys.exit(1) + provisioning_profiles = None + if profile: + profile_path = os.path.join(profiles_dir, profile + '.mobileprovision') + if os.path.exists(profile_path): + provisioning_profiles = [profile_path] + if not provisioning_profiles: + provisioning_profiles = glob.glob( + os.path.join(profiles_dir, '*.mobileprovision')) + valid_provisioning_profiles = {} + for profile_path in provisioning_profiles: + profile_data = self._LoadProvisioningProfile(profile_path) + app_id_pattern = profile_data.get( + 'Entitlements', {}).get('application-identifier', '') + for team_identifier in profile_data.get('TeamIdentifier', []): + app_id = '%s.%s' % (team_identifier, bundle_identifier) + if fnmatch.fnmatch(app_id, app_id_pattern): + valid_provisioning_profiles[app_id_pattern] = ( + profile_path, profile_data, team_identifier) + if not valid_provisioning_profiles: + print >>sys.stderr, ( + 'cannot find mobile provisioning for %s' % bundle_identifier) + sys.exit(1) + # If the user has multiple provisioning profiles installed that can be + # used for ${bundle_identifier}, pick the most specific one (ie. the + # provisioning profile whose pattern is the longest). + selected_key = max(valid_provisioning_profiles, key=lambda v: len(v)) + return valid_provisioning_profiles[selected_key] + + def _LoadProvisioningProfile(self, profile_path): + """Extracts the plist embedded in a provisioning profile. + + Args: + profile_path: string, path to the .mobileprovision file + + Returns: + Content of the plist embedded in the provisioning profile as a dictionary. + """ + with tempfile.NamedTemporaryFile() as temp: + subprocess.check_call([ + 'security', 'cms', '-D', '-i', profile_path, '-o', temp.name]) + return self._LoadPlistMaybeBinary(temp.name) + + def _MergePlist(self, merged_plist, plist): + """Merge |plist| into |merged_plist|.""" + for key, value in plist.iteritems(): + if isinstance(value, dict): + merged_value = merged_plist.get(key, {}) + if isinstance(merged_value, dict): + self._MergePlist(merged_value, value) + merged_plist[key] = merged_value + else: + merged_plist[key] = value + else: + merged_plist[key] = value + + def _LoadPlistMaybeBinary(self, plist_path): + """Loads into a memory a plist possibly encoded in binary format. + + This is a wrapper around plistlib.readPlist that tries to convert the + plist to the XML format if it can't be parsed (assuming that it is in + the binary format). + + Args: + plist_path: string, path to a plist file, in XML or binary format + + Returns: + Content of the plist as a dictionary. + """ + try: + # First, try to read the file using plistlib that only supports XML, + # and if an exception is raised, convert a temporary copy to XML and + # load that copy. + return plistlib.readPlist(plist_path) + except: + pass + with tempfile.NamedTemporaryFile() as temp: + shutil.copy2(plist_path, temp.name) + subprocess.check_call(['plutil', '-convert', 'xml1', temp.name]) + return plistlib.readPlist(temp.name) + + def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix): + """Constructs a dictionary of variable substitutions for Entitlements.plist. + + Args: + bundle_identifier: string, value of CFBundleIdentifier from Info.plist + app_identifier_prefix: string, value for AppIdentifierPrefix + + Returns: + Dictionary of substitutions to apply when generating Entitlements.plist. + """ + return { + 'CFBundleIdentifier': bundle_identifier, + 'AppIdentifierPrefix': app_identifier_prefix, + } + + def _GetCFBundleIdentifier(self): + """Extracts CFBundleIdentifier value from Info.plist in the bundle. + + Returns: + Value of CFBundleIdentifier in the Info.plist located in the bundle. + """ + info_plist_path = os.path.join( + os.environ['TARGET_BUILD_DIR'], + os.environ['INFOPLIST_PATH']) + info_plist_data = self._LoadPlistMaybeBinary(info_plist_path) + return info_plist_data['CFBundleIdentifier'] + + def _InstallEntitlements(self, entitlements, substitutions, overrides): + """Generates and install the ${BundleName}.xcent entitlements file. + + Expands variables "$(variable)" pattern in the source entitlements file, + add extra entitlements defined in the .mobileprovision file and the copy + the generated plist to "${BundlePath}.xcent". + + Args: + entitlements: string, optional, path to the Entitlements.plist template + to use, defaults to "${SDKROOT}/Entitlements.plist" + substitutions: dictionary, variable substitutions + overrides: dictionary, values to add to the entitlements + + Returns: + Path to the generated entitlements file. + """ + source_path = entitlements + target_path = os.path.join( + os.environ['BUILT_PRODUCTS_DIR'], + os.environ['PRODUCT_NAME'] + '.xcent') + if not source_path: + source_path = os.path.join( + os.environ['SDKROOT'], + 'Entitlements.plist') + shutil.copy2(source_path, target_path) + data = self._LoadPlistMaybeBinary(target_path) + data = self._ExpandVariables(data, substitutions) + if overrides: + for key in overrides: + if key not in data: + data[key] = overrides[key] + plistlib.writePlist(data, target_path) + return target_path + + def _ExpandVariables(self, data, substitutions): + """Expands variables "$(variable)" in data. + + Args: + data: object, can be either string, list or dictionary + substitutions: dictionary, variable substitutions to perform + + Returns: + Copy of data where each references to "$(variable)" has been replaced + by the corresponding value found in substitutions, or left intact if + the key was not found. + """ + if isinstance(data, str): + for key, value in substitutions.iteritems(): + data = data.replace('$(%s)' % key, value) + return data + if isinstance(data, list): + return [self._ExpandVariables(v, substitutions) for v in data] + if isinstance(data, dict): + return {k: self._ExpandVariables(data[k], substitutions) for k in data} + return data + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/test/gc/node_modules/weak/build/weakref.target.mk b/test/gc/node_modules/weak/build/weakref.target.mk new file mode 100644 index 00000000000000..a3a98860645bf8 --- /dev/null +++ b/test/gc/node_modules/weak/build/weakref.target.mk @@ -0,0 +1,168 @@ +# This file is generated by gyp; do not edit. + +TOOLSET := target +TARGET := weakref +DEFS_Debug := \ + '-DNODE_GYP_MODULE_NAME=weakref' \ + '-D_DARWIN_USE_64_BIT_INODE=1' \ + '-D_LARGEFILE_SOURCE' \ + '-D_FILE_OFFSET_BITS=64' \ + '-DBUILDING_NODE_EXTENSION' \ + '-DDEBUG' \ + '-D_DEBUG' + +# Flags passed to all source files. +CFLAGS_Debug := \ + -O0 \ + -gdwarf-2 \ + -mmacosx-version-min=10.7 \ + -arch x86_64 \ + -Wall \ + -Wendif-labels \ + -W \ + -Wno-unused-parameter + +# Flags passed to only C files. +CFLAGS_C_Debug := \ + -fno-strict-aliasing + +# Flags passed to only C++ files. +CFLAGS_CC_Debug := \ + -std=gnu++0x \ + -fno-rtti \ + -fno-exceptions \ + -fno-threadsafe-statics \ + -fno-strict-aliasing + +# Flags passed to only ObjC files. +CFLAGS_OBJC_Debug := + +# Flags passed to only ObjC++ files. +CFLAGS_OBJCC_Debug := + +INCS_Debug := \ + -I/Users/trott/io.js/include/node \ + -I/Users/trott/io.js/src \ + -I/Users/trott/io.js/deps/uv/include \ + -I/Users/trott/io.js/deps/v8/include \ + -I$(srcdir)/../nan + +DEFS_Release := \ + '-DNODE_GYP_MODULE_NAME=weakref' \ + '-D_DARWIN_USE_64_BIT_INODE=1' \ + '-D_LARGEFILE_SOURCE' \ + '-D_FILE_OFFSET_BITS=64' \ + '-DBUILDING_NODE_EXTENSION' + +# Flags passed to all source files. +CFLAGS_Release := \ + -Os \ + -gdwarf-2 \ + -mmacosx-version-min=10.7 \ + -arch x86_64 \ + -Wall \ + -Wendif-labels \ + -W \ + -Wno-unused-parameter + +# Flags passed to only C files. +CFLAGS_C_Release := \ + -fno-strict-aliasing + +# Flags passed to only C++ files. +CFLAGS_CC_Release := \ + -std=gnu++0x \ + -fno-rtti \ + -fno-exceptions \ + -fno-threadsafe-statics \ + -fno-strict-aliasing + +# Flags passed to only ObjC files. +CFLAGS_OBJC_Release := + +# Flags passed to only ObjC++ files. +CFLAGS_OBJCC_Release := + +INCS_Release := \ + -I/Users/trott/io.js/include/node \ + -I/Users/trott/io.js/src \ + -I/Users/trott/io.js/deps/uv/include \ + -I/Users/trott/io.js/deps/v8/include \ + -I$(srcdir)/../nan + +OBJS := \ + $(obj).target/$(TARGET)/src/weakref.o + +# Add to the list of files we specially track dependencies for. +all_deps += $(OBJS) + +# CFLAGS et al overrides must be target-local. +# See "Target-specific Variable Values" in the GNU Make manual. +$(OBJS): TOOLSET := $(TOOLSET) +$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) +$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) +$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) +$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) + +# Suffix rules, putting all outputs into $(obj). + +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) + +# Try building from generated source, too. + +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) + +$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD + @$(call do_cmd,cxx,1) + +# End of this set of suffix rules +### Rules for final target. +LDFLAGS_Debug := \ + -undefined dynamic_lookup \ + -Wl,-no_pie \ + -Wl,-search_paths_first \ + -mmacosx-version-min=10.7 \ + -arch x86_64 \ + -L$(builddir) + +LIBTOOLFLAGS_Debug := \ + -undefined dynamic_lookup \ + -Wl,-no_pie \ + -Wl,-search_paths_first + +LDFLAGS_Release := \ + -undefined dynamic_lookup \ + -Wl,-no_pie \ + -Wl,-search_paths_first \ + -mmacosx-version-min=10.7 \ + -arch x86_64 \ + -L$(builddir) + +LIBTOOLFLAGS_Release := \ + -undefined dynamic_lookup \ + -Wl,-no_pie \ + -Wl,-search_paths_first + +LIBS := + +$(builddir)/weakref.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) +$(builddir)/weakref.node: LIBS := $(LIBS) +$(builddir)/weakref.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE)) +$(builddir)/weakref.node: TOOLSET := $(TOOLSET) +$(builddir)/weakref.node: $(OBJS) FORCE_DO_CMD + $(call do_cmd,solink_module) + +all_deps += $(builddir)/weakref.node +# Add target alias +.PHONY: weakref +weakref: $(builddir)/weakref.node + +# Short alias for building this executable. +.PHONY: weakref.node +weakref.node: $(builddir)/weakref.node + +# Add executable to "all" target. +.PHONY: all +all: $(builddir)/weakref.node diff --git a/test/gc/node_modules/weak/lib/weak.js b/test/gc/node_modules/weak/lib/weak.js index 535caf615c648e..5502b0de201372 100644 --- a/test/gc/node_modules/weak/lib/weak.js +++ b/test/gc/node_modules/weak/lib/weak.js @@ -1,19 +1,110 @@ -'use strict'; -var bindings -try { - bindings = require('../build/Release/weakref.node') -} catch (e) { - if (e.code === 'MODULE_NOT_FOUND') { - bindings = require('../build/Debug/weakref.node') - } else { - throw e + +/** + * Module dependencies. + */ + +var Emitter = require('events').EventEmitter; +var bindings = require('bindings')('weakref.node'); + +/** + * Set global weak callback function. + */ + +bindings._setCallback(callback); + +/** + * Module exports. + */ + +exports = module.exports = create; +exports.addCallback = exports.addListener = addCallback; +exports.removeCallback = exports.removeListener = removeCallback; +exports.removeCallbacks = exports.removeListeners = removeCallbacks; +exports.callbacks = exports.listeners = callbacks; + +// backwards-compat with node-weakref +exports.weaken = exports.create = exports; + +// re-export all the binding functions onto the exports +Object.keys(bindings).forEach(function (name) { + exports[name] = bindings[name]; +}); + +/** + * Internal emitter event name. + * This is completely arbitrary... + * Could be any value.... + */ + +var CB = '_CB'; + +/** + * Creates and returns a new Weakref instance. Optionally attaches + * a weak callback to invoke when the Object gets garbage collected. + * + * @api public + */ + +function create (obj, fn) { + var weakref = bindings._create(obj, new Emitter()); + if ('function' == typeof fn) { + exports.addCallback(weakref, fn); } + return weakref; } -module.exports = bindings.create -// backwards-compat with node-weakref -bindings.weaken = bindings.create +/** + * Adds a weak callback function to the Weakref instance. + * + * @api public + */ -Object.keys(bindings).forEach(function(name) { - module.exports[name] = bindings[name] -}) +function addCallback (weakref, fn) { + var emitter = bindings._getEmitter(weakref); + return emitter.on(CB, fn); +} + +/** + * Removes a weak callback function from the Weakref instance. + * + * @api public + */ + +function removeCallback (weakref, fn) { + var emitter = bindings._getEmitter(weakref); + return emitter.removeListener(CB, fn); +} + +/** + * Returns a copy of the listeners on the Weakref instance. + * + * @api public + */ + +function callbacks (weakref) { + var emitter = bindings._getEmitter(weakref); + return emitter.listeners(CB); +} + + +/** + * Removes all callbacks on the Weakref instance. + * + * @api public + */ + +function removeCallbacks (weakref) { + var emitter = bindings._getEmitter(weakref); + return emitter.removeAllListeners(CB); +} + +/** + * Common weak callback function. + * + * @api private + */ + +function callback (emitter) { + emitter.emit(CB); + emitter = null; +} diff --git a/test/gc/node_modules/weak/package.json b/test/gc/node_modules/weak/package.json index f2e952bc876635..3f8977d9b94beb 100644 --- a/test/gc/node_modules/weak/package.json +++ b/test/gc/node_modules/weak/package.json @@ -1,17 +1,68 @@ { + "_args": [ + [ + "weak", + "/Users/trott/io.js/test/gc" + ] + ], + "_from": "weak@latest", + "_id": "weak@1.0.1", + "_inCache": true, + "_installable": true, + "_location": "/weak", + "_nodeVersion": "5.3.0", + "_npmUser": { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + }, + "_npmVersion": "3.3.12", + "_phantomChildren": {}, + "_requested": { + "name": "weak", + "raw": "weak", + "rawSpec": "", + "scope": null, + "spec": "latest", + "type": "tag" + }, + "_requiredBy": [ + "#USER" + ], + "_resolved": "https://registry.npmjs.org/weak/-/weak-1.0.1.tgz", + "_shasum": "ab99aab30706959aa0200cb8cf545bb9cb33b99e", + "_shrinkwrap": null, + "_spec": "weak", + "_where": "/Users/trott/io.js/test/gc", "author": { - "name": "Ben Noordhuis", - "email": "info@bnoordhuis.nl" + "email": "info@bnoordhuis.nl", + "name": "Ben Noordhuis" + }, + "bugs": { + "url": "https://github.com/TooTallNate/node-weak/issues" }, "contributors": [ { - "name": "Nathan Rajlich", "email": "nathan@tootallnate.net", + "name": "Nathan Rajlich", "url": "http://tootallnate.net" } ], - "name": "weak", + "dependencies": { + "bindings": "^1.2.1", + "nan": "^2.0.5" + }, "description": "Make weak references to JavaScript Objects.", + "devDependencies": { + "mocha": "~2.1.0" + }, + "directories": {}, + "dist": { + "shasum": "ab99aab30706959aa0200cb8cf545bb9cb33b99e", + "tarball": "http://registry.npmjs.org/weak/-/weak-1.0.1.tgz" + }, + "gitHead": "1c3b0376dab966782e5d1fcf06f9fcb1309cb2c0", + "gypfile": true, + "homepage": "https://github.com/TooTallNate/node-weak#readme", "keywords": [ "weak", "reference", @@ -21,35 +72,28 @@ "function", "callback" ], - "version": "0.2.1", + "license": "MIT", + "main": "lib/weak.js", + "maintainers": [ + { + "email": "nathan@tootallnate.net", + "name": "TooTallNate" + }, + { + "email": "nathan@tootallnate.net", + "name": "tootallnate" + } + ], + "name": "weak", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", "repository": { "type": "git", "url": "git://github.com/TooTallNate/node-weak.git" }, - "main": "./lib/weak.js", "scripts": { - "test": "mocha -gc --reporter spec", - "install": "node-gyp rebuild" - }, - "engines": { - "node": "*" + "install": "node-gyp rebuild", + "test": "mocha -gc --reporter spec" }, - "dependencies": { - "bindings": "*" - }, - "devDependencies": { - "mocha": "> 0.7.0", - "should": "*" - }, - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_id": "weak@0.2.1", - "optionalDependencies": {}, - "_engineSupported": true, - "_npmVersion": "1.1.25", - "_nodeVersion": "v0.7.10", - "_defaultsLoaded": true, - "_from": "weak" + "version": "1.0.1" } diff --git a/test/gc/node_modules/weak/src/weakref.cc b/test/gc/node_modules/weak/src/weakref.cc index 64629b48d75b9e..4eea618fefe77e 100644 --- a/test/gc/node_modules/weak/src/weakref.cc +++ b/test/gc/node_modules/weak/src/weakref.cc @@ -15,45 +15,31 @@ */ #include -#include "v8.h" -#include "node.h" +#include + +using namespace v8; namespace { -using node::FatalException; -using v8::Array; -using v8::Boolean; -using v8::Exception; -using v8::Function; -using v8::FunctionTemplate; -using v8::FunctionCallbackInfo; -using v8::HandleScope; -using v8::Integer; -using v8::Isolate; -using v8::Local; -using v8::None; -using v8::Object; -using v8::ObjectTemplate; -using v8::Persistent; -using v8::PropertyCallbackInfo; -using v8::Value; -using v8::String; -using v8::TryCatch; - -typedef struct proxy_container { - Persistent proxy; - Persistent target; - Persistent callbacks; -} proxy_container; - - -Persistent proxyClass; + +class proxy_container { +public: + Nan::Persistent proxy; + Nan::Persistent emitter; + Nan::Persistent target; +}; + + +Nan::Persistent proxyClass; + +Nan::Callback *globalCallback; bool IsDead(Local proxy) { assert(proxy->InternalFieldCount() == 1); proxy_container *cont = reinterpret_cast( - proxy->GetAlignedPointerFromInternalField(0)); + Nan::GetInternalFieldPointer(proxy, 0) + ); return cont == NULL || cont->target.IsEmpty(); } @@ -61,160 +47,133 @@ bool IsDead(Local proxy) { Local Unwrap(Local proxy) { assert(!IsDead(proxy)); proxy_container *cont = reinterpret_cast( - proxy->GetAlignedPointerFromInternalField(0)); - Isolate* isolate = Isolate::GetCurrent(); - return Local::New(isolate, cont->target); + Nan::GetInternalFieldPointer(proxy, 0) + ); + Local _target = Nan::New(cont->target); + return _target; } -Local GetCallbacks(Local proxy) { +Local GetEmitter(Local proxy) { proxy_container *cont = reinterpret_cast( - proxy->GetAlignedPointerFromInternalField(0)); + Nan::GetInternalFieldPointer(proxy, 0) + ); assert(cont != NULL); - Isolate* isolate = Isolate::GetCurrent(); - return Local::New(isolate, cont->callbacks); + Local _emitter = Nan::New(cont->emitter); + return _emitter; } #define UNWRAP \ - HandleScope scope(info.GetIsolate()); \ - Local obj; \ + Local obj; \ const bool dead = IsDead(info.This()); \ if (!dead) obj = Unwrap(info.This()); \ -void ThrowTypeError(Isolate* isolate, const char* message) { - HandleScope scope(isolate); - Local emessage = String::NewFromUtf8(isolate, message); - isolate->ThrowException(v8::Exception::TypeError(emessage)); -} - - -void WeakNamedPropertyGetter(Local property, - const PropertyCallbackInfo& info) { +NAN_PROPERTY_GETTER(WeakNamedPropertyGetter) { UNWRAP - if (!dead) info.GetReturnValue().Set(obj->Get(property)); + info.GetReturnValue().Set(dead ? Local() : Nan::Get(obj, property).ToLocalChecked()); } -void WeakNamedPropertySetter(Local property, - Local value, - const PropertyCallbackInfo& info) { +NAN_PROPERTY_SETTER(WeakNamedPropertySetter) { UNWRAP - if (!dead) obj->Set(property, value); + if (!dead) Nan::Set(obj, property, value); + info.GetReturnValue().Set(value); } -void WeakNamedPropertyQuery(Local property, - const PropertyCallbackInfo& info) { +NAN_PROPERTY_QUERY(WeakNamedPropertyQuery) { info.GetReturnValue().Set(None); } -void WeakNamedPropertyDeleter(Local property, - const PropertyCallbackInfo& info) { +NAN_PROPERTY_DELETER(WeakNamedPropertyDeleter) { UNWRAP - info.GetReturnValue().Set(!dead && obj->Delete(property)); + info.GetReturnValue().Set(!dead && Nan::Delete(obj, property).FromJust()); } -void WeakIndexedPropertyGetter(uint32_t index, - const PropertyCallbackInfo& info) { +NAN_INDEX_GETTER(WeakIndexedPropertyGetter) { UNWRAP - if (!dead) info.GetReturnValue().Set(obj->Get(index)); + info.GetReturnValue().Set(dead ? Local() : Nan::Get(obj, index).ToLocalChecked()); } -void WeakIndexedPropertySetter(uint32_t index, - Local value, - const PropertyCallbackInfo& info) { +NAN_INDEX_SETTER(WeakIndexedPropertySetter) { UNWRAP - if (!dead) obj->Set(index, value); + if (!dead) Nan::Set(obj, index, value); + info.GetReturnValue().Set(value); } -void WeakIndexedPropertyQuery(uint32_t index, - const PropertyCallbackInfo& info) { +NAN_INDEX_QUERY(WeakIndexedPropertyQuery) { info.GetReturnValue().Set(None); } -void WeakIndexedPropertyDeleter(uint32_t index, - const PropertyCallbackInfo& info) { +NAN_INDEX_DELETER(WeakIndexedPropertyDeleter) { UNWRAP - info.GetReturnValue().Set(!dead && obj->Delete(index)); + info.GetReturnValue().Set(!dead && Nan::Delete(obj, index).FromJust()); } -void WeakPropertyEnumerator(const PropertyCallbackInfo& info) { - UNWRAP - info.GetReturnValue().Set(dead ? Array::New(0) : obj->GetPropertyNames()); -} - +/** + * Only one "enumerator" function needs to be defined. This function is used for + * both the property and indexed enumerator functions. + */ -void AddCallback(Isolate* isolate, Local proxy, Local callback) { - Local callbacks = GetCallbacks(proxy); - callbacks->Set(Integer::New(isolate, callbacks->Length()), callback); +NAN_PROPERTY_ENUMERATOR(WeakPropertyEnumerator) { + UNWRAP + info.GetReturnValue().Set(dead ? Nan::New(0) : Nan::GetPropertyNames(obj).ToLocalChecked()); } +/** + * Weakref callback function. Invokes the "global" callback function, + * which emits the _CB event on the per-object EventEmitter. + */ -static void TargetCallback(const v8::WeakCallbackData& data) { - Isolate* isolate = data.GetIsolate(); - HandleScope scope(isolate); - - Local target = data.GetValue(); - proxy_container* cont = data.GetParameter(); - - // invoke any listening callbacks - Local callbacks = Local::New(isolate, cont->callbacks); - uint32_t len = callbacks->Length(); - Local argv[1]; - argv[0] = target; - for (uint32_t i=0; i cb = Local::Cast( - callbacks->Get(Integer::New(isolate, i))); - - TryCatch try_catch; - - cb->Call(target, 1, argv); - - if (try_catch.HasCaught()) { - FatalException(try_catch); - } - } - +static void TargetCallback(const Nan::WeakCallbackInfo &info) { + Nan::HandleScope scope; + proxy_container *cont = info.GetParameter(); + + // invoke global callback function + Local argv[] = { + Nan::New(cont->emitter) + }; + // Invoke callback directly, not via Nan::Callback->Call() which uses + // node::MakeCallback() which calls into process._tickCallback() + // too. Those other callbacks are not safe to run from here. + v8::Local globalCallbackDirect = globalCallback->GetFunction(); + globalCallbackDirect->Call(Nan::GetCurrentContext()->Global(), 1, argv); + + // clean everything up + Local proxy = Nan::New(cont->proxy); + Nan::SetInternalFieldPointer(proxy, 0, NULL); cont->proxy.Reset(); - cont->target.Reset(); - cont->callbacks.Reset(); + cont->emitter.Reset(); delete cont; } +/** + * `_create(obj, emitter)` JS function. + */ -void Create(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); - - if (!args[0]->IsObject()) { - ThrowTypeError(args.GetIsolate(), "Object expected"); - return; - } - - proxy_container *cont = new proxy_container; +NAN_METHOD(Create) { + if (!info[0]->IsObject()) return Nan::ThrowTypeError("Object expected"); - Isolate* isolate = args.GetIsolate(); - Local tmpl = Local::New(isolate, proxyClass); - Local proxy = tmpl->NewInstance(); - proxy->SetAlignedPointerInInternalField(0, cont); + proxy_container *cont = new proxy_container(); - cont->proxy.Reset(Isolate::GetCurrent(), proxy); - cont->target.Reset(isolate, args[0].As()); - cont->callbacks.Reset(isolate, Array::New(args.GetIsolate())); - cont->target.SetWeak(cont, TargetCallback); + Local _target = info[0].As(); + Local _emitter = info[1].As(); + Local proxy = Nan::New(proxyClass)->NewInstance(); + cont->proxy.Reset(proxy); + cont->emitter.Reset(_emitter); + cont->target.Reset(_target); + Nan::SetInternalFieldPointer(proxy, 0, cont); - if (args.Length() >= 2) { - AddCallback(args.GetIsolate(), proxy, Local::Cast(args[1])); - } + cont->target.SetWeak(cont, TargetCallback, Nan::WeakCallbackType::kParameter); - args.GetReturnValue().Set(proxy); + info.GetReturnValue().Set(proxy); } /** @@ -222,109 +181,109 @@ void Create(const FunctionCallbackInfo& args) { */ bool isWeakRef (Local val) { - return val->IsObject() && val->ToObject()->InternalFieldCount() == 1; + return val->IsObject() && val.As()->InternalFieldCount() == 1; } -void IsWeakRef (const FunctionCallbackInfo& args) { - args.GetReturnValue().Set(isWeakRef(args[0])); -} +/** + * `isWeakRef()` JS function. + */ -void Get(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); +NAN_METHOD(IsWeakRef) { + info.GetReturnValue().Set(isWeakRef(info[0])); +} - if (!isWeakRef(args[0])) { - ThrowTypeError(args.GetIsolate(), "Weakref instance expected"); - return; - } +#define WEAKREF_FIRST_ARG \ + if (!isWeakRef(info[0])) { \ + return Nan::ThrowTypeError("Weakref instance expected"); \ + } \ + Local proxy = info[0].As(); - Local proxy = args[0]->ToObject(); - if (IsDead(proxy)) return; +/** + * `get(weakref)` JS function. + */ - Local obj = Unwrap(proxy); - args.GetReturnValue().Set(obj); +NAN_METHOD(Get) { + WEAKREF_FIRST_ARG + if (!IsDead(proxy)) + info.GetReturnValue().Set(Unwrap(proxy)); } -void IsNearDeath(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); +/** + * `isNearDeath(weakref)` JS function. + */ - if (!isWeakRef(args[0])) { - ThrowTypeError(args.GetIsolate(), "Weakref instance expected"); - return; - } +NAN_METHOD(IsNearDeath) { + WEAKREF_FIRST_ARG - Local proxy = args[0]->ToObject(); - proxy_container *cont = static_cast( - proxy->GetAlignedPointerFromInternalField(0)); + proxy_container *cont = reinterpret_cast( + Nan::GetInternalFieldPointer(proxy, 0) + ); assert(cont != NULL); - args.GetReturnValue().Set(cont->target.IsNearDeath()); -} - -void IsDead(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); + Local rtn = Nan::New(cont->target.IsNearDeath()); - if (!isWeakRef(args[0])) { - ThrowTypeError(args.GetIsolate(), "Weakref instance expected"); - return; - } - - Local proxy = args[0]->ToObject(); - args.GetReturnValue().Set(IsDead(proxy)); + info.GetReturnValue().Set(rtn); } +/** + * `isDead(weakref)` JS function. + */ -void AddCallback(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); +NAN_METHOD(IsDead) { + WEAKREF_FIRST_ARG + info.GetReturnValue().Set(IsDead(proxy)); +} - if (!isWeakRef(args[0])) { - ThrowTypeError(args.GetIsolate(), "Weakref instance expected"); - return; - } +/** + * `_getEmitter(weakref)` JS function. + */ - Local proxy = args[0]->ToObject(); - AddCallback(args.GetIsolate(), proxy, Local::Cast(args[1])); +NAN_METHOD(GetEmitter) { + WEAKREF_FIRST_ARG + info.GetReturnValue().Set(GetEmitter(proxy)); } -void Callbacks(const FunctionCallbackInfo& args) { - HandleScope scope(args.GetIsolate()); - - if (!isWeakRef(args[0])) { - ThrowTypeError(args.GetIsolate(), "Weakref instance expected"); - return; - } +/** + * Sets the global weak callback function. + */ - Local proxy = args[0]->ToObject(); - args.GetReturnValue().Set(GetCallbacks(proxy)); +NAN_METHOD(SetCallback) { + Local callbackHandle = info[0].As(); + globalCallback = new Nan::Callback(callbackHandle); } +/** + * Init function. + */ -void Initialize(Local target) { - HandleScope scope(target->CreationContext()->GetIsolate()); - - Local tmpl = ObjectTemplate::New(); - tmpl->SetNamedPropertyHandler(WeakNamedPropertyGetter, - WeakNamedPropertySetter, - WeakNamedPropertyQuery, - WeakNamedPropertyDeleter, - WeakPropertyEnumerator); - tmpl->SetIndexedPropertyHandler(WeakIndexedPropertyGetter, - WeakIndexedPropertySetter, - WeakIndexedPropertyQuery, - WeakIndexedPropertyDeleter, - WeakPropertyEnumerator); - tmpl->SetInternalFieldCount(1); - proxyClass.Reset(Isolate::GetCurrent(), tmpl); - - NODE_SET_METHOD(target, "get", Get); - NODE_SET_METHOD(target, "create", Create); - NODE_SET_METHOD(target, "isWeakRef", IsWeakRef); - NODE_SET_METHOD(target, "isNearDeath", IsNearDeath); - NODE_SET_METHOD(target, "isDead", IsDead); - NODE_SET_METHOD(target, "callbacks", Callbacks); - NODE_SET_METHOD(target, "addCallback", AddCallback); - +NAN_MODULE_INIT(Initialize) { + Nan::HandleScope scope; + + Local p = Nan::New(); + proxyClass.Reset(p); + Nan::SetNamedPropertyHandler(p, + WeakNamedPropertyGetter, + WeakNamedPropertySetter, + WeakNamedPropertyQuery, + WeakNamedPropertyDeleter, + WeakPropertyEnumerator); + Nan::SetIndexedPropertyHandler(p, + WeakIndexedPropertyGetter, + WeakIndexedPropertySetter, + WeakIndexedPropertyQuery, + WeakIndexedPropertyDeleter, + WeakPropertyEnumerator); + p->SetInternalFieldCount(1); + + Nan::SetMethod(target, "get", Get); + Nan::SetMethod(target, "isWeakRef", IsWeakRef); + Nan::SetMethod(target, "isNearDeath", IsNearDeath); + Nan::SetMethod(target, "isDead", IsDead); + Nan::SetMethod(target, "_create", Create); + Nan::SetMethod(target, "_getEmitter", GetEmitter); + Nan::SetMethod(target, "_setCallback", SetCallback); } } // anonymous namespace -NODE_MODULE(weakref, Initialize); +NODE_MODULE(weakref, Initialize) From e3097b7cdf1096db65eaf2607bf6e0c04a60f202 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 25 Jun 2016 15:18:04 -0700 Subject: [PATCH 154/261] test: test isFullWidthCodePoint with invalid input Code coverage information shows that we are only testing the happy path for the internal readline `isFullWidthCodePoint()` function. Test it with invalid input. PR-URL: https://github.com/nodejs/node/pull/7422 Reviewed-By: Anna Henningsen Reviewed-By: Brian White Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- test/parallel/test-readline-interface.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 4997b6e9bdb60b..8c7a4d12d100ce 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -304,6 +304,11 @@ function isWarned(emitter) { rli.close(); } + // isFullWidthCodePoint() should return false for non-numeric values + [true, false, null, undefined, {}, [], 'あ'].forEach((v) => { + assert.strictEqual(readline.isFullWidthCodePoint('あ'), false); + }); + // wide characters should be treated as two columns. assert.equal(readline.isFullWidthCodePoint('a'.charCodeAt(0)), false); assert.equal(readline.isFullWidthCodePoint('あ'.charCodeAt(0)), true); From 75e4f74c54e7f7a9433486a8d3e8f3a4b4e824fe Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 15 Jun 2016 10:08:53 -0400 Subject: [PATCH 155/261] doc: fix cluster worker 'message' event This commit adds the missing handle argument to the cluster worker 'message' event. It also adds a link to the process 'message' event for reference. Refs: https://github.com/nodejs/node/pull/7297 PR-URL: https://github.com/nodejs/node/pull/7309 Reviewed-By: Brian White --- doc/api/cluster.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 104897660f7107..d3fb499b89f45b 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -167,12 +167,12 @@ It is not emitted in the worker. ### Event: 'message' * `message` {Object} +* `handle` {undefined|Object} -Similar to the `cluster.on('message')` event, but specific to this worker. - -This event is the same as the one provided by [`child_process.fork()`][]. +Similar to the `cluster.on('message')` event, but specific to this worker. In a +worker you can also use `process.on('message')`. -In a worker you can also use `process.on('message')`. +See [`process` event: `'message'`][]. As an example, here is a cluster that keeps count of the number of requests in the master process using the message system: @@ -689,3 +689,4 @@ socket.on('data', (id) => { [Child Process module]: child_process.html#child_process_child_process_fork_modulepath_args_options [child_process event: 'exit']: child_process.html#child_process_event_exit [child_process event: 'message']: child_process.html#child_process_event_message +[`process` event: `'message'`]: process.html#process_event_message From 9c31c738fc566a8674fc8bb6a3e5f3aa5ba9ad94 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 4 May 2016 20:41:42 +0200 Subject: [PATCH 156/261] src: remove unused #include statement strcasecmp() is not used in src/node_http_parser.cc so there is no need to include its header file. PR-URL: https://github.com/nodejs/node/pull/6582 Reviewed-By: Anna Henningsen Reviewed-By: Fedor Indutny Reviewed-By: James M Snell --- src/node_http_parser.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index c062feea535604..b094ce5f2fbac7 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -16,12 +16,6 @@ #include // free() #include // strdup() -#if defined(_MSC_VER) -#define strcasecmp _stricmp -#else -#include // strcasecmp() -#endif - // This is a binding to http_parser (https://github.com/joyent/http-parser) // The goal is to decouple sockets from parsing for more javascript-level // agility. A Buffer is read from a socket and passed to parser.execute(). From 2b0dce5a5bf226bbad7ded3c476fa77dbc2e1218 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 4 May 2016 20:56:04 +0200 Subject: [PATCH 157/261] src: don't use locale-sensitive strcasecmp() strcasecmp() is affected by the current locale as configured through e.g. the LC_ALL environment variable and the setlocale() libc function. It can result in unpredictable results across systems so replace it with a function that isn't susceptible to that. PR-URL: https://github.com/nodejs/node/pull/6582 Reviewed-By: Anna Henningsen Reviewed-By: Fedor Indutny Reviewed-By: James M Snell --- src/node.cc | 27 +++++++++++++-------------- src/node_crypto.cc | 6 +----- src/util-inl.h | 12 ++++++++++++ src/util.h | 6 ++++++ test/cctest/util.cc | 18 ++++++++++++++++++ 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/node.cc b/src/node.cc index 12219b026d63b7..9be6fa5c507196 100644 --- a/src/node.cc +++ b/src/node.cc @@ -69,7 +69,6 @@ #if defined(_MSC_VER) #include #include -#define strcasecmp _stricmp #define getpid GetCurrentProcessId #define umask _umask typedef int mode_t; @@ -1350,35 +1349,35 @@ enum encoding ParseEncoding(const char* encoding, break; } - if (strcasecmp(encoding, "utf8") == 0) { + if (StringEqualNoCase(encoding, "utf8")) { return UTF8; - } else if (strcasecmp(encoding, "utf-8") == 0) { + } else if (StringEqualNoCase(encoding, "utf-8")) { return UTF8; - } else if (strcasecmp(encoding, "ascii") == 0) { + } else if (StringEqualNoCase(encoding, "ascii")) { return ASCII; - } else if (strcasecmp(encoding, "base64") == 0) { + } else if (StringEqualNoCase(encoding, "base64")) { return BASE64; - } else if (strcasecmp(encoding, "ucs2") == 0) { + } else if (StringEqualNoCase(encoding, "ucs2")) { return UCS2; - } else if (strcasecmp(encoding, "ucs-2") == 0) { + } else if (StringEqualNoCase(encoding, "ucs-2")) { return UCS2; - } else if (strcasecmp(encoding, "utf16le") == 0) { + } else if (StringEqualNoCase(encoding, "utf16le")) { return UCS2; - } else if (strcasecmp(encoding, "utf-16le") == 0) { + } else if (StringEqualNoCase(encoding, "utf-16le")) { return UCS2; - } else if (strcasecmp(encoding, "binary") == 0) { + } else if (StringEqualNoCase(encoding, "binary")) { return BINARY; - } else if (strcasecmp(encoding, "buffer") == 0) { + } else if (StringEqualNoCase(encoding, "buffer")) { return BUFFER; - } else if (strcasecmp(encoding, "hex") == 0) { + } else if (StringEqualNoCase(encoding, "hex")) { return HEX; - } else if (strcasecmp(encoding, "raw") == 0) { + } else if (StringEqualNoCase(encoding, "raw") == 0) { if (!no_deprecation) { fprintf(stderr, "'raw' (array of integers) has been removed. " "Use 'binary'.\n"); } return BINARY; - } else if (strcasecmp(encoding, "raws") == 0) { + } else if (StringEqualNoCase(encoding, "raws") == 0) { if (!no_deprecation) { fprintf(stderr, "'raws' encoding has been renamed to 'binary'. " "Please update your code.\n"); diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 21e4d33cab9316..2d508d2cc3d527 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -24,10 +24,6 @@ #include #include -#if defined(_MSC_VER) -#define strcasecmp _stricmp -#endif - #if OPENSSL_VERSION_NUMBER >= 0x10000000L #define OPENSSL_CONST const #else @@ -4232,7 +4228,7 @@ void DiffieHellman::DiffieHellmanGroup( for (size_t i = 0; i < arraysize(modp_groups); ++i) { const modp_group* it = modp_groups + i; - if (strcasecmp(*group_name, it->name) != 0) + if (!StringEqualNoCase(*group_name, it->name)) continue; initialized = diffieHellman->Init(it->prime, diff --git a/src/util-inl.h b/src/util-inl.h index 69dc5b2a61a1a9..7051659a5e0e6a 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -203,7 +203,19 @@ void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen) { dst[i] = (src[i] << 8) | (src[i] >> 8); } +char ToLower(char c) { + return c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c; +} +bool StringEqualNoCase(const char* a, const char* b) { + do { + if (*a == '\0') + return *b == '\0'; + if (*b == '\0') + return *a == '\0'; + } while (ToLower(*a++) == ToLower(*b++)); + return false; +} } // namespace node diff --git a/src/util.h b/src/util.h index 7b2bc0f1a270ba..671b98dd25b191 100644 --- a/src/util.h +++ b/src/util.h @@ -178,6 +178,12 @@ inline TypeName* Unwrap(v8::Local object); inline void SwapBytes(uint16_t* dst, const uint16_t* src, size_t buflen); +// tolower() is locale-sensitive. Use ToLower() instead. +inline char ToLower(char c); + +// strcasecmp() is locale-sensitive. Use StringEqualNoCase() instead. +inline bool StringEqualNoCase(const char* a, const char* b); + class Utf8Value { public: explicit Utf8Value(v8::Isolate* isolate, v8::Local value); diff --git a/test/cctest/util.cc b/test/cctest/util.cc index fe966d9b34073c..37133aca562b72 100644 --- a/test/cctest/util.cc +++ b/test/cctest/util.cc @@ -56,3 +56,21 @@ TEST(UtilTest, ListHead) { EXPECT_TRUE(list.IsEmpty()); EXPECT_FALSE(list.begin() != list.end()); } + +TEST(UtilTest, StringEqualNoCase) { + using node::StringEqualNoCase; + EXPECT_FALSE(StringEqualNoCase("a", "b")); + EXPECT_TRUE(StringEqualNoCase("", "")); + EXPECT_TRUE(StringEqualNoCase("equal", "equal")); + EXPECT_TRUE(StringEqualNoCase("equal", "EQUAL")); + EXPECT_TRUE(StringEqualNoCase("EQUAL", "EQUAL")); + EXPECT_FALSE(StringEqualNoCase("equal", "equals")); + EXPECT_FALSE(StringEqualNoCase("equals", "equal")); +} + +TEST(UtilTest, ToLower) { + using node::ToLower; + EXPECT_EQ('0', ToLower('0')); + EXPECT_EQ('a', ToLower('a')); + EXPECT_EQ('a', ToLower('A')); +} From efadf7639ffed7d31c54cfb86ec6971325adb83d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 11:48:58 +0200 Subject: [PATCH 158/261] tools: update certdata.txt This is the certdata.txt[0] that ships in Firefox 47 and NSS 3.23, last updated on 2016-02-26. [0] https://hg.mozilla.org/mozilla-central/raw-file/1f84dea6508d/security/nss/lib/ckfw/builtins/certdata.txt PR-URL: https://github.com/nodejs/node/pull/7363 Reviewed-By: Fedor Indutny Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- tools/certdata.txt | 4938 ++++++++++++-------------------------------- 1 file changed, 1290 insertions(+), 3648 deletions(-) diff --git a/tools/certdata.txt b/tools/certdata.txt index d3209db50f0a2d..8effa748d2eb05 100644 --- a/tools/certdata.txt +++ b/tools/certdata.txt @@ -187,9 +187,9 @@ END CKA_SERIAL_NUMBER MULTILINE_OCTAL \002\004\065\336\364\317 END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # Distrust "Distrust a pb.com certificate that does not comply with the baseline requirements." @@ -220,252 +220,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "Digital Signature Trust Co. Global CA 1" -# -# Issuer: OU=DSTCA E1,O=Digital Signature Trust Co.,C=US -# Serial Number: 913315222 (0x36701596) -# Subject: OU=DSTCA E1,O=Digital Signature Trust Co.,C=US -# Not Valid Before: Thu Dec 10 18:10:23 1998 -# Not Valid After : Mon Dec 10 18:40:23 2018 -# Fingerprint (MD5): 25:7A:BA:83:2E:B6:A2:0B:DA:FE:F5:02:0F:08:D7:AD -# Fingerprint (SHA1): 81:96:8B:3A:EF:1C:DC:70:F5:FA:32:69:C2:92:A3:63:5B:D1:23:D3 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Digital Signature Trust Co. Global CA 1" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\061 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\061 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\066\160\025\226 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\051\060\202\002\222\240\003\002\001\002\002\004\066 -\160\025\226\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\060\106\061\013\060\011\006\003\125\004\006\023\002\125 -\123\061\044\060\042\006\003\125\004\012\023\033\104\151\147\151 -\164\141\154\040\123\151\147\156\141\164\165\162\145\040\124\162 -\165\163\164\040\103\157\056\061\021\060\017\006\003\125\004\013 -\023\010\104\123\124\103\101\040\105\061\060\036\027\015\071\070 -\061\062\061\060\061\070\061\060\062\063\132\027\015\061\070\061 -\062\061\060\061\070\064\060\062\063\132\060\106\061\013\060\011 -\006\003\125\004\006\023\002\125\123\061\044\060\042\006\003\125 -\004\012\023\033\104\151\147\151\164\141\154\040\123\151\147\156 -\141\164\165\162\145\040\124\162\165\163\164\040\103\157\056\061 -\021\060\017\006\003\125\004\013\023\010\104\123\124\103\101\040 -\105\061\060\201\235\060\015\006\011\052\206\110\206\367\015\001 -\001\001\005\000\003\201\213\000\060\201\207\002\201\201\000\240 -\154\201\251\317\064\036\044\335\376\206\050\314\336\203\057\371 -\136\324\102\322\350\164\140\146\023\230\006\034\251\121\022\151 -\157\061\125\271\111\162\000\010\176\323\245\142\104\067\044\231 -\217\331\203\110\217\231\155\225\023\273\103\073\056\111\116\210 -\067\301\273\130\177\376\341\275\370\273\141\315\363\107\300\231 -\246\361\363\221\350\170\174\000\313\141\311\104\047\161\151\125 -\112\176\111\115\355\242\243\276\002\114\000\312\002\250\356\001 -\002\061\144\017\122\055\023\164\166\066\265\172\264\055\161\002 -\001\003\243\202\001\044\060\202\001\040\060\021\006\011\140\206 -\110\001\206\370\102\001\001\004\004\003\002\000\007\060\150\006 -\003\125\035\037\004\141\060\137\060\135\240\133\240\131\244\127 -\060\125\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\061\061\015\060\013\006\003\125\004 -\003\023\004\103\122\114\061\060\053\006\003\125\035\020\004\044 -\060\042\200\017\061\071\071\070\061\062\061\060\061\070\061\060 -\062\063\132\201\017\062\060\061\070\061\062\061\060\061\070\061 -\060\062\063\132\060\013\006\003\125\035\017\004\004\003\002\001 -\006\060\037\006\003\125\035\043\004\030\060\026\200\024\152\171 -\176\221\151\106\030\023\012\002\167\245\131\133\140\230\045\016 -\242\370\060\035\006\003\125\035\016\004\026\004\024\152\171\176 -\221\151\106\030\023\012\002\167\245\131\133\140\230\045\016\242 -\370\060\014\006\003\125\035\023\004\005\060\003\001\001\377\060 -\031\006\011\052\206\110\206\366\175\007\101\000\004\014\060\012 -\033\004\126\064\056\060\003\002\004\220\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\003\201\201\000\042\022\330 -\172\035\334\201\006\266\011\145\262\207\310\037\136\264\057\351 -\304\036\362\074\301\273\004\220\021\112\203\116\176\223\271\115 -\102\307\222\046\240\134\064\232\070\162\370\375\153\026\076\040 -\356\202\213\061\052\223\066\205\043\210\212\074\003\150\323\311 -\011\017\115\374\154\244\332\050\162\223\016\211\200\260\175\376 -\200\157\145\155\030\063\227\213\302\153\211\356\140\075\310\233 -\357\177\053\062\142\163\223\313\074\343\173\342\166\170\105\274 -\241\223\004\273\206\237\072\133\103\172\303\212\145 -END - -# Trust for Certificate "Digital Signature Trust Co. Global CA 1" -# Issuer: OU=DSTCA E1,O=Digital Signature Trust Co.,C=US -# Serial Number: 913315222 (0x36701596) -# Subject: OU=DSTCA E1,O=Digital Signature Trust Co.,C=US -# Not Valid Before: Thu Dec 10 18:10:23 1998 -# Not Valid After : Mon Dec 10 18:40:23 2018 -# Fingerprint (MD5): 25:7A:BA:83:2E:B6:A2:0B:DA:FE:F5:02:0F:08:D7:AD -# Fingerprint (SHA1): 81:96:8B:3A:EF:1C:DC:70:F5:FA:32:69:C2:92:A3:63:5B:D1:23:D3 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Digital Signature Trust Co. Global CA 1" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\201\226\213\072\357\034\334\160\365\372\062\151\302\222\243\143 -\133\321\043\323 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\045\172\272\203\056\266\242\013\332\376\365\002\017\010\327\255 -END -CKA_ISSUER MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\061 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\066\160\025\226 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "Digital Signature Trust Co. Global CA 3" -# -# Issuer: OU=DSTCA E2,O=Digital Signature Trust Co.,C=US -# Serial Number: 913232846 (0x366ed3ce) -# Subject: OU=DSTCA E2,O=Digital Signature Trust Co.,C=US -# Not Valid Before: Wed Dec 09 19:17:26 1998 -# Not Valid After : Sun Dec 09 19:47:26 2018 -# Fingerprint (MD5): 93:C2:8E:11:7B:D4:F3:03:19:BD:28:75:13:4A:45:4A -# Fingerprint (SHA1): AB:48:F3:33:DB:04:AB:B9:C0:72:DA:5B:0C:C1:D0:57:F0:36:9B:46 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Digital Signature Trust Co. Global CA 3" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\062 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\062 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\066\156\323\316 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\051\060\202\002\222\240\003\002\001\002\002\004\066 -\156\323\316\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\060\106\061\013\060\011\006\003\125\004\006\023\002\125 -\123\061\044\060\042\006\003\125\004\012\023\033\104\151\147\151 -\164\141\154\040\123\151\147\156\141\164\165\162\145\040\124\162 -\165\163\164\040\103\157\056\061\021\060\017\006\003\125\004\013 -\023\010\104\123\124\103\101\040\105\062\060\036\027\015\071\070 -\061\062\060\071\061\071\061\067\062\066\132\027\015\061\070\061 -\062\060\071\061\071\064\067\062\066\132\060\106\061\013\060\011 -\006\003\125\004\006\023\002\125\123\061\044\060\042\006\003\125 -\004\012\023\033\104\151\147\151\164\141\154\040\123\151\147\156 -\141\164\165\162\145\040\124\162\165\163\164\040\103\157\056\061 -\021\060\017\006\003\125\004\013\023\010\104\123\124\103\101\040 -\105\062\060\201\235\060\015\006\011\052\206\110\206\367\015\001 -\001\001\005\000\003\201\213\000\060\201\207\002\201\201\000\277 -\223\217\027\222\357\063\023\030\353\020\177\116\026\277\377\006 -\217\052\205\274\136\371\044\246\044\210\266\003\267\301\303\137 -\003\133\321\157\256\176\102\352\146\043\270\143\203\126\373\050 -\055\341\070\213\264\356\250\001\341\316\034\266\210\052\042\106 -\205\373\237\247\160\251\107\024\077\316\336\145\360\250\161\367 -\117\046\154\214\274\306\265\357\336\111\047\377\110\052\175\350 -\115\003\314\307\262\122\306\027\061\023\073\265\115\333\310\304 -\366\303\017\044\052\332\014\235\347\221\133\200\315\224\235\002 -\001\003\243\202\001\044\060\202\001\040\060\021\006\011\140\206 -\110\001\206\370\102\001\001\004\004\003\002\000\007\060\150\006 -\003\125\035\037\004\141\060\137\060\135\240\133\240\131\244\127 -\060\125\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\062\061\015\060\013\006\003\125\004 -\003\023\004\103\122\114\061\060\053\006\003\125\035\020\004\044 -\060\042\200\017\061\071\071\070\061\062\060\071\061\071\061\067 -\062\066\132\201\017\062\060\061\070\061\062\060\071\061\071\061 -\067\062\066\132\060\013\006\003\125\035\017\004\004\003\002\001 -\006\060\037\006\003\125\035\043\004\030\060\026\200\024\036\202 -\115\050\145\200\074\311\101\156\254\065\056\132\313\336\356\370 -\071\133\060\035\006\003\125\035\016\004\026\004\024\036\202\115 -\050\145\200\074\311\101\156\254\065\056\132\313\336\356\370\071 -\133\060\014\006\003\125\035\023\004\005\060\003\001\001\377\060 -\031\006\011\052\206\110\206\366\175\007\101\000\004\014\060\012 -\033\004\126\064\056\060\003\002\004\220\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\003\201\201\000\107\215\203 -\255\142\362\333\260\236\105\042\005\271\242\326\003\016\070\162 -\347\236\374\173\346\223\266\232\245\242\224\310\064\035\221\321 -\305\327\364\012\045\017\075\170\201\236\017\261\147\304\220\114 -\143\335\136\247\342\272\237\365\367\115\245\061\173\234\051\055 -\114\376\144\076\354\266\123\376\352\233\355\202\333\164\165\113 -\007\171\156\036\330\031\203\163\336\365\076\320\265\336\347\113 -\150\175\103\056\052\040\341\176\240\170\104\236\010\365\230\371 -\307\177\033\033\326\006\040\002\130\241\303\242\003 -END - -# Trust for Certificate "Digital Signature Trust Co. Global CA 3" -# Issuer: OU=DSTCA E2,O=Digital Signature Trust Co.,C=US -# Serial Number: 913232846 (0x366ed3ce) -# Subject: OU=DSTCA E2,O=Digital Signature Trust Co.,C=US -# Not Valid Before: Wed Dec 09 19:17:26 1998 -# Not Valid After : Sun Dec 09 19:47:26 2018 -# Fingerprint (MD5): 93:C2:8E:11:7B:D4:F3:03:19:BD:28:75:13:4A:45:4A -# Fingerprint (SHA1): AB:48:F3:33:DB:04:AB:B9:C0:72:DA:5B:0C:C1:D0:57:F0:36:9B:46 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Digital Signature Trust Co. Global CA 3" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\253\110\363\063\333\004\253\271\300\162\332\133\014\301\320\127 -\360\066\233\106 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\223\302\216\021\173\324\363\003\031\275\050\165\023\112\105\112 -END -CKA_ISSUER MULTILINE_OCTAL -\060\106\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\044\060\042\006\003\125\004\012\023\033\104\151\147\151\164\141 -\154\040\123\151\147\156\141\164\165\162\145\040\124\162\165\163 -\164\040\103\157\056\061\021\060\017\006\003\125\004\013\023\010 -\104\123\124\103\101\040\105\062 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\066\156\323\316 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "Verisign Class 3 Public Primary Certification Authority" # @@ -582,153 +336,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "Verisign Class 1 Public Primary Certification Authority - G2" -# -# Issuer: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 1 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Serial Number:4c:c7:ea:aa:98:3e:71:d3:93:10:f8:3d:3a:89:91:92 -# Subject: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 1 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon May 18 00:00:00 1998 -# Not Valid After : Tue Aug 01 23:59:59 2028 -# Fingerprint (MD5): DB:23:3D:F9:69:FA:4B:B9:95:80:44:73:5E:7D:41:83 -# Fingerprint (SHA1): 27:3E:E1:24:57:FD:C4:F9:0C:55:E8:2B:56:16:7F:62:F5:32:E5:47 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 1 Public Primary Certification Authority - G2" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\061\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\061\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\114\307\352\252\230\076\161\323\223\020\370\075\072\211 -\221\222 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\002\060\202\002\153\002\020\114\307\352\252\230\076 -\161\323\223\020\370\075\072\211\221\222\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\060\201\301\061\013\060\011 -\006\003\125\004\006\023\002\125\123\061\027\060\025\006\003\125 -\004\012\023\016\126\145\162\151\123\151\147\156\054\040\111\156 -\143\056\061\074\060\072\006\003\125\004\013\023\063\103\154\141 -\163\163\040\061\040\120\165\142\154\151\143\040\120\162\151\155 -\141\162\171\040\103\145\162\164\151\146\151\143\141\164\151\157 -\156\040\101\165\164\150\157\162\151\164\171\040\055\040\107\062 -\061\072\060\070\006\003\125\004\013\023\061\050\143\051\040\061 -\071\071\070\040\126\145\162\151\123\151\147\156\054\040\111\156 -\143\056\040\055\040\106\157\162\040\141\165\164\150\157\162\151 -\172\145\144\040\165\163\145\040\157\156\154\171\061\037\060\035 -\006\003\125\004\013\023\026\126\145\162\151\123\151\147\156\040 -\124\162\165\163\164\040\116\145\164\167\157\162\153\060\036\027 -\015\071\070\060\065\061\070\060\060\060\060\060\060\132\027\015 -\062\070\060\070\060\061\062\063\065\071\065\071\132\060\201\301 -\061\013\060\011\006\003\125\004\006\023\002\125\123\061\027\060 -\025\006\003\125\004\012\023\016\126\145\162\151\123\151\147\156 -\054\040\111\156\143\056\061\074\060\072\006\003\125\004\013\023 -\063\103\154\141\163\163\040\061\040\120\165\142\154\151\143\040 -\120\162\151\155\141\162\171\040\103\145\162\164\151\146\151\143 -\141\164\151\157\156\040\101\165\164\150\157\162\151\164\171\040 -\055\040\107\062\061\072\060\070\006\003\125\004\013\023\061\050 -\143\051\040\061\071\071\070\040\126\145\162\151\123\151\147\156 -\054\040\111\156\143\056\040\055\040\106\157\162\040\141\165\164 -\150\157\162\151\172\145\144\040\165\163\145\040\157\156\154\171 -\061\037\060\035\006\003\125\004\013\023\026\126\145\162\151\123 -\151\147\156\040\124\162\165\163\164\040\116\145\164\167\157\162 -\153\060\201\237\060\015\006\011\052\206\110\206\367\015\001\001 -\001\005\000\003\201\215\000\060\201\211\002\201\201\000\252\320 -\272\276\026\055\270\203\324\312\322\017\274\166\061\312\224\330 -\035\223\214\126\002\274\331\157\032\157\122\066\156\165\126\012 -\125\323\337\103\207\041\021\145\212\176\217\275\041\336\153\062 -\077\033\204\064\225\005\235\101\065\353\222\353\226\335\252\131 -\077\001\123\155\231\117\355\345\342\052\132\220\301\271\304\246 -\025\317\310\105\353\246\135\216\234\076\360\144\044\166\245\315 -\253\032\157\266\330\173\121\141\156\246\177\207\310\342\267\345 -\064\334\101\210\352\011\100\276\163\222\075\153\347\165\002\003 -\001\000\001\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\003\201\201\000\251\117\303\015\307\147\276\054\313\331 -\250\315\055\165\347\176\025\236\073\162\353\176\353\134\055\011 -\207\326\153\155\140\174\345\256\305\220\043\014\134\112\320\257 -\261\135\363\307\266\012\333\340\025\223\015\335\003\274\307\166 -\212\265\335\117\303\233\023\165\270\001\300\346\311\133\153\245 -\270\211\334\254\244\335\162\355\116\241\367\117\274\006\323\352 -\310\144\164\173\302\225\101\234\145\163\130\361\220\232\074\152 -\261\230\311\304\207\274\317\105\155\105\342\156\042\077\376\274 -\017\061\134\350\362\331 -END - -# Trust for Certificate "Verisign Class 1 Public Primary Certification Authority - G2" -# Issuer: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 1 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Serial Number:4c:c7:ea:aa:98:3e:71:d3:93:10:f8:3d:3a:89:91:92 -# Subject: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 1 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon May 18 00:00:00 1998 -# Not Valid After : Tue Aug 01 23:59:59 2028 -# Fingerprint (MD5): DB:23:3D:F9:69:FA:4B:B9:95:80:44:73:5E:7D:41:83 -# Fingerprint (SHA1): 27:3E:E1:24:57:FD:C4:F9:0C:55:E8:2B:56:16:7F:62:F5:32:E5:47 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 1 Public Primary Certification Authority - G2" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\047\076\341\044\127\375\304\371\014\125\350\053\126\026\177\142 -\365\062\345\107 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\333\043\075\371\151\372\113\271\225\200\104\163\136\175\101\203 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\061\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\114\307\352\252\230\076\161\323\223\020\370\075\072\211 -\221\222 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "Verisign Class 2 Public Primary Certification Authority - G2" # @@ -876,153 +483,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "Verisign Class 3 Public Primary Certification Authority - G2" -# -# Issuer: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 3 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Serial Number:7d:d9:fe:07:cf:a8:1e:b7:10:79:67:fb:a7:89:34:c6 -# Subject: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 3 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon May 18 00:00:00 1998 -# Not Valid After : Tue Aug 01 23:59:59 2028 -# Fingerprint (MD5): A2:33:9B:4C:74:78:73:D4:6C:E7:C1:F3:8D:CB:5C:E9 -# Fingerprint (SHA1): 85:37:1C:A6:E5:50:14:3D:CE:28:03:47:1B:DE:3A:09:E8:F8:77:0F -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 3 Public Primary Certification Authority - G2" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\063\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\063\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\175\331\376\007\317\250\036\267\020\171\147\373\247\211 -\064\306 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\002\060\202\002\153\002\020\175\331\376\007\317\250 -\036\267\020\171\147\373\247\211\064\306\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\060\201\301\061\013\060\011 -\006\003\125\004\006\023\002\125\123\061\027\060\025\006\003\125 -\004\012\023\016\126\145\162\151\123\151\147\156\054\040\111\156 -\143\056\061\074\060\072\006\003\125\004\013\023\063\103\154\141 -\163\163\040\063\040\120\165\142\154\151\143\040\120\162\151\155 -\141\162\171\040\103\145\162\164\151\146\151\143\141\164\151\157 -\156\040\101\165\164\150\157\162\151\164\171\040\055\040\107\062 -\061\072\060\070\006\003\125\004\013\023\061\050\143\051\040\061 -\071\071\070\040\126\145\162\151\123\151\147\156\054\040\111\156 -\143\056\040\055\040\106\157\162\040\141\165\164\150\157\162\151 -\172\145\144\040\165\163\145\040\157\156\154\171\061\037\060\035 -\006\003\125\004\013\023\026\126\145\162\151\123\151\147\156\040 -\124\162\165\163\164\040\116\145\164\167\157\162\153\060\036\027 -\015\071\070\060\065\061\070\060\060\060\060\060\060\132\027\015 -\062\070\060\070\060\061\062\063\065\071\065\071\132\060\201\301 -\061\013\060\011\006\003\125\004\006\023\002\125\123\061\027\060 -\025\006\003\125\004\012\023\016\126\145\162\151\123\151\147\156 -\054\040\111\156\143\056\061\074\060\072\006\003\125\004\013\023 -\063\103\154\141\163\163\040\063\040\120\165\142\154\151\143\040 -\120\162\151\155\141\162\171\040\103\145\162\164\151\146\151\143 -\141\164\151\157\156\040\101\165\164\150\157\162\151\164\171\040 -\055\040\107\062\061\072\060\070\006\003\125\004\013\023\061\050 -\143\051\040\061\071\071\070\040\126\145\162\151\123\151\147\156 -\054\040\111\156\143\056\040\055\040\106\157\162\040\141\165\164 -\150\157\162\151\172\145\144\040\165\163\145\040\157\156\154\171 -\061\037\060\035\006\003\125\004\013\023\026\126\145\162\151\123 -\151\147\156\040\124\162\165\163\164\040\116\145\164\167\157\162 -\153\060\201\237\060\015\006\011\052\206\110\206\367\015\001\001 -\001\005\000\003\201\215\000\060\201\211\002\201\201\000\314\136 -\321\021\135\134\151\320\253\323\271\152\114\231\037\131\230\060 -\216\026\205\040\106\155\107\077\324\205\040\204\341\155\263\370 -\244\355\014\361\027\017\073\371\247\371\045\327\301\317\204\143 -\362\174\143\317\242\107\362\306\133\063\216\144\100\004\150\301 -\200\271\144\034\105\167\307\330\156\365\225\051\074\120\350\064 -\327\170\037\250\272\155\103\221\225\217\105\127\136\176\305\373 -\312\244\004\353\352\227\067\124\060\157\273\001\107\062\063\315 -\334\127\233\144\151\141\370\233\035\034\211\117\134\147\002\003 -\001\000\001\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\003\201\201\000\121\115\315\276\134\313\230\031\234\025 -\262\001\071\170\056\115\017\147\160\160\231\306\020\132\224\244 -\123\115\124\155\053\257\015\135\100\213\144\323\327\356\336\126 -\141\222\137\246\304\035\020\141\066\323\054\047\074\350\051\011 -\271\021\144\164\314\265\163\237\034\110\251\274\141\001\356\342 -\027\246\014\343\100\010\073\016\347\353\104\163\052\232\361\151 -\222\357\161\024\303\071\254\161\247\221\011\157\344\161\006\263 -\272\131\127\046\171\000\366\370\015\242\063\060\050\324\252\130 -\240\235\235\151\221\375 -END - -# Trust for Certificate "Verisign Class 3 Public Primary Certification Authority - G2" -# Issuer: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 3 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Serial Number:7d:d9:fe:07:cf:a8:1e:b7:10:79:67:fb:a7:89:34:c6 -# Subject: OU=VeriSign Trust Network,OU="(c) 1998 VeriSign, Inc. - For authorized use only",OU=Class 3 Public Primary Certification Authority - G2,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon May 18 00:00:00 1998 -# Not Valid After : Tue Aug 01 23:59:59 2028 -# Fingerprint (MD5): A2:33:9B:4C:74:78:73:D4:6C:E7:C1:F3:8D:CB:5C:E9 -# Fingerprint (SHA1): 85:37:1C:A6:E5:50:14:3D:CE:28:03:47:1B:DE:3A:09:E8:F8:77:0F -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 3 Public Primary Certification Authority - G2" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\205\067\034\246\345\120\024\075\316\050\003\107\033\336\072\011 -\350\370\167\017 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\242\063\233\114\164\170\163\324\154\347\301\363\215\313\134\351 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\301\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\074\060\072\006\003\125 -\004\013\023\063\103\154\141\163\163\040\063\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\062\061\072\060\070\006\003\125\004\013 -\023\061\050\143\051\040\061\071\071\070\040\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\040\055\040\106\157\162\040 -\141\165\164\150\157\162\151\172\145\144\040\165\163\145\040\157 -\156\154\171\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\175\331\376\007\317\250\036\267\020\171\147\373\247\211 -\064\306 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "GlobalSign Root CA" # @@ -1891,179 +1351,15 @@ CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # -# Certificate "Verisign Class 4 Public Primary Certification Authority - G3" +# Certificate "Entrust.net Premium 2048 Secure Server CA" # -# Issuer: CN=VeriSign Class 4 Public Primary Certification Authority - G3,OU="(c) 1999 VeriSign, Inc. - For authorized use only",OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US -# Serial Number:00:ec:a0:a7:8b:6e:75:6a:01:cf:c4:7c:cc:2f:94:5e:d7 -# Subject: CN=VeriSign Class 4 Public Primary Certification Authority - G3,OU="(c) 1999 VeriSign, Inc. - For authorized use only",OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US -# Not Valid Before: Fri Oct 01 00:00:00 1999 -# Not Valid After : Wed Jul 16 23:59:59 2036 -# Fingerprint (MD5): DB:C8:F2:27:2E:B1:EA:6A:29:23:5D:FE:56:3E:33:DF -# Fingerprint (SHA1): C8:EC:8C:87:92:69:CB:4B:AB:39:E9:8D:7E:57:67:F3:14:95:73:9D -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 4 Public Primary Certification Authority - G3" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\312\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\037\060\035\006\003\125 -\004\013\023\026\126\145\162\151\123\151\147\156\040\124\162\165 -\163\164\040\116\145\164\167\157\162\153\061\072\060\070\006\003 -\125\004\013\023\061\050\143\051\040\061\071\071\071\040\126\145 -\162\151\123\151\147\156\054\040\111\156\143\056\040\055\040\106 -\157\162\040\141\165\164\150\157\162\151\172\145\144\040\165\163 -\145\040\157\156\154\171\061\105\060\103\006\003\125\004\003\023 -\074\126\145\162\151\123\151\147\156\040\103\154\141\163\163\040 -\064\040\120\165\142\154\151\143\040\120\162\151\155\141\162\171 -\040\103\145\162\164\151\146\151\143\141\164\151\157\156\040\101 -\165\164\150\157\162\151\164\171\040\055\040\107\063 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\312\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\037\060\035\006\003\125 -\004\013\023\026\126\145\162\151\123\151\147\156\040\124\162\165 -\163\164\040\116\145\164\167\157\162\153\061\072\060\070\006\003 -\125\004\013\023\061\050\143\051\040\061\071\071\071\040\126\145 -\162\151\123\151\147\156\054\040\111\156\143\056\040\055\040\106 -\157\162\040\141\165\164\150\157\162\151\172\145\144\040\165\163 -\145\040\157\156\154\171\061\105\060\103\006\003\125\004\003\023 -\074\126\145\162\151\123\151\147\156\040\103\154\141\163\163\040 -\064\040\120\165\142\154\151\143\040\120\162\151\155\141\162\171 -\040\103\145\162\164\151\146\151\143\141\164\151\157\156\040\101 -\165\164\150\157\162\151\164\171\040\055\040\107\063 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\021\000\354\240\247\213\156\165\152\001\317\304\174\314\057 -\224\136\327 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\032\060\202\003\002\002\021\000\354\240\247\213\156 -\165\152\001\317\304\174\314\057\224\136\327\060\015\006\011\052 -\206\110\206\367\015\001\001\005\005\000\060\201\312\061\013\060 -\011\006\003\125\004\006\023\002\125\123\061\027\060\025\006\003 -\125\004\012\023\016\126\145\162\151\123\151\147\156\054\040\111 -\156\143\056\061\037\060\035\006\003\125\004\013\023\026\126\145 -\162\151\123\151\147\156\040\124\162\165\163\164\040\116\145\164 -\167\157\162\153\061\072\060\070\006\003\125\004\013\023\061\050 -\143\051\040\061\071\071\071\040\126\145\162\151\123\151\147\156 -\054\040\111\156\143\056\040\055\040\106\157\162\040\141\165\164 -\150\157\162\151\172\145\144\040\165\163\145\040\157\156\154\171 -\061\105\060\103\006\003\125\004\003\023\074\126\145\162\151\123 -\151\147\156\040\103\154\141\163\163\040\064\040\120\165\142\154 -\151\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151 -\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 -\164\171\040\055\040\107\063\060\036\027\015\071\071\061\060\060 -\061\060\060\060\060\060\060\132\027\015\063\066\060\067\061\066 -\062\063\065\071\065\071\132\060\201\312\061\013\060\011\006\003 -\125\004\006\023\002\125\123\061\027\060\025\006\003\125\004\012 -\023\016\126\145\162\151\123\151\147\156\054\040\111\156\143\056 -\061\037\060\035\006\003\125\004\013\023\026\126\145\162\151\123 -\151\147\156\040\124\162\165\163\164\040\116\145\164\167\157\162 -\153\061\072\060\070\006\003\125\004\013\023\061\050\143\051\040 -\061\071\071\071\040\126\145\162\151\123\151\147\156\054\040\111 -\156\143\056\040\055\040\106\157\162\040\141\165\164\150\157\162 -\151\172\145\144\040\165\163\145\040\157\156\154\171\061\105\060 -\103\006\003\125\004\003\023\074\126\145\162\151\123\151\147\156 -\040\103\154\141\163\163\040\064\040\120\165\142\154\151\143\040 -\120\162\151\155\141\162\171\040\103\145\162\164\151\146\151\143 -\141\164\151\157\156\040\101\165\164\150\157\162\151\164\171\040 -\055\040\107\063\060\202\001\042\060\015\006\011\052\206\110\206 -\367\015\001\001\001\005\000\003\202\001\017\000\060\202\001\012 -\002\202\001\001\000\255\313\245\021\151\306\131\253\361\217\265 -\031\017\126\316\314\265\037\040\344\236\046\045\113\340\163\145 -\211\131\336\320\203\344\365\017\265\273\255\361\174\350\041\374 -\344\350\014\356\174\105\042\031\166\222\264\023\267\040\133\011 -\372\141\256\250\362\245\215\205\302\052\326\336\146\066\322\233 -\002\364\250\222\140\174\234\151\264\217\044\036\320\206\122\366 -\062\234\101\130\036\042\275\315\105\142\225\010\156\320\146\335 -\123\242\314\360\020\334\124\163\213\004\241\106\063\063\134\027 -\100\271\236\115\323\363\276\125\203\350\261\211\216\132\174\232 -\226\042\220\073\210\045\362\322\123\210\002\014\013\170\362\346 -\067\027\113\060\106\007\344\200\155\246\330\226\056\350\054\370 -\021\263\070\015\146\246\233\352\311\043\133\333\216\342\363\023 -\216\032\131\055\252\002\360\354\244\207\146\334\301\077\365\330 -\271\364\354\202\306\322\075\225\035\345\300\117\204\311\331\243 -\104\050\006\152\327\105\254\360\153\152\357\116\137\370\021\202 -\036\070\143\064\146\120\324\076\223\163\372\060\303\146\255\377 -\223\055\227\357\003\002\003\001\000\001\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\003\202\001\001\000\217\372 -\045\153\117\133\344\244\116\047\125\253\042\025\131\074\312\265 -\012\324\112\333\253\335\241\137\123\305\240\127\071\302\316\107 -\053\276\072\310\126\277\302\331\047\020\072\261\005\074\300\167 -\061\273\072\323\005\173\155\232\034\060\214\200\313\223\223\052 -\203\253\005\121\202\002\000\021\147\153\363\210\141\107\137\003 -\223\325\133\015\340\361\324\241\062\065\205\262\072\333\260\202 -\253\321\313\012\274\117\214\133\305\113\000\073\037\052\202\246 -\176\066\205\334\176\074\147\000\265\344\073\122\340\250\353\135 -\025\371\306\155\360\255\035\016\205\267\251\232\163\024\132\133 -\217\101\050\300\325\350\055\115\244\136\315\252\331\355\316\334 -\330\325\074\102\035\027\301\022\135\105\070\303\070\363\374\205 -\056\203\106\110\262\327\040\137\222\066\217\347\171\017\230\136 -\231\350\360\320\244\273\365\123\275\052\316\131\260\257\156\177 -\154\273\322\036\000\260\041\355\370\101\142\202\271\330\262\304 -\273\106\120\363\061\305\217\001\250\164\353\365\170\047\332\347 -\367\146\103\363\236\203\076\040\252\303\065\140\221\316 -END - -# Trust for Certificate "Verisign Class 4 Public Primary Certification Authority - G3" -# Issuer: CN=VeriSign Class 4 Public Primary Certification Authority - G3,OU="(c) 1999 VeriSign, Inc. - For authorized use only",OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US -# Serial Number:00:ec:a0:a7:8b:6e:75:6a:01:cf:c4:7c:cc:2f:94:5e:d7 -# Subject: CN=VeriSign Class 4 Public Primary Certification Authority - G3,OU="(c) 1999 VeriSign, Inc. - For authorized use only",OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US -# Not Valid Before: Fri Oct 01 00:00:00 1999 -# Not Valid After : Wed Jul 16 23:59:59 2036 -# Fingerprint (MD5): DB:C8:F2:27:2E:B1:EA:6A:29:23:5D:FE:56:3E:33:DF -# Fingerprint (SHA1): C8:EC:8C:87:92:69:CB:4B:AB:39:E9:8D:7E:57:67:F3:14:95:73:9D -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 4 Public Primary Certification Authority - G3" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\310\354\214\207\222\151\313\113\253\071\351\215\176\127\147\363 -\024\225\163\235 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\333\310\362\047\056\261\352\152\051\043\135\376\126\076\063\337 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\312\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123 -\151\147\156\054\040\111\156\143\056\061\037\060\035\006\003\125 -\004\013\023\026\126\145\162\151\123\151\147\156\040\124\162\165 -\163\164\040\116\145\164\167\157\162\153\061\072\060\070\006\003 -\125\004\013\023\061\050\143\051\040\061\071\071\071\040\126\145 -\162\151\123\151\147\156\054\040\111\156\143\056\040\055\040\106 -\157\162\040\141\165\164\150\157\162\151\172\145\144\040\165\163 -\145\040\157\156\154\171\061\105\060\103\006\003\125\004\003\023 -\074\126\145\162\151\123\151\147\156\040\103\154\141\163\163\040 -\064\040\120\165\142\154\151\143\040\120\162\151\155\141\162\171 -\040\103\145\162\164\151\146\151\143\141\164\151\157\156\040\101 -\165\164\150\157\162\151\164\171\040\055\040\107\063 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\021\000\354\240\247\213\156\165\152\001\317\304\174\314\057 -\224\136\327 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "Entrust.net Premium 2048 Secure Server CA" -# -# Issuer: CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net -# Serial Number: 946069240 (0x3863def8) -# Subject: CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net -# Not Valid Before: Fri Dec 24 17:50:51 1999 -# Not Valid After : Tue Jul 24 14:15:12 2029 -# Fingerprint (MD5): EE:29:31:BC:32:7E:9A:E6:E8:B5:F7:51:B4:34:71:90 -# Fingerprint (SHA1): 50:30:06:09:1D:97:D4:F5:AE:39:F7:CB:E7:92:7D:7D:65:2D:34:31 +# Issuer: CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net +# Serial Number: 946069240 (0x3863def8) +# Subject: CN=Entrust.net Certification Authority (2048),OU=(c) 1999 Entrust.net Limited,OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),O=Entrust.net +# Not Valid Before: Fri Dec 24 17:50:51 1999 +# Not Valid After : Tue Jul 24 14:15:12 2029 +# Fingerprint (MD5): EE:29:31:BC:32:7E:9A:E6:E8:B5:F7:51:B4:34:71:90 +# Fingerprint (SHA1): 50:30:06:09:1D:97:D4:F5:AE:39:F7:CB:E7:92:7D:7D:65:2D:34:31 CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE CKA_TOKEN CK_BBOOL CK_TRUE CKA_PRIVATE CK_BBOOL CK_FALSE @@ -4024,169 +3320,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "UTN-USER First-Network Applications" -# -# Issuer: CN=UTN-USERFirst-Network Applications,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Serial Number:44:be:0c:8b:50:00:24:b4:11:d3:36:30:4b:c0:33:77 -# Subject: CN=UTN-USERFirst-Network Applications,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Fri Jul 09 18:48:39 1999 -# Not Valid After : Tue Jul 09 18:57:49 2019 -# Fingerprint (MD5): BF:60:59:A3:5B:BA:F6:A7:76:42:DA:6F:1A:7B:50:CF -# Fingerprint (SHA1): 5D:98:9C:DB:15:96:11:36:51:65:64:1B:56:0F:DB:EA:2A:C2:3E:F1 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "UTN-USER First-Network Applications" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\243\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\053\060\051\006\003\125 -\004\003\023\042\125\124\116\055\125\123\105\122\106\151\162\163 -\164\055\116\145\164\167\157\162\153\040\101\160\160\154\151\143 -\141\164\151\157\156\163 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\243\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\053\060\051\006\003\125 -\004\003\023\042\125\124\116\055\125\123\105\122\106\151\162\163 -\164\055\116\145\164\167\157\162\153\040\101\160\160\154\151\143 -\141\164\151\157\156\163 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\104\276\014\213\120\000\044\264\021\323\066\060\113\300 -\063\167 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\144\060\202\003\114\240\003\002\001\002\002\020\104 -\276\014\213\120\000\044\264\021\323\066\060\113\300\063\167\060 -\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060\201 -\243\061\013\060\011\006\003\125\004\006\023\002\125\123\061\013 -\060\011\006\003\125\004\010\023\002\125\124\061\027\060\025\006 -\003\125\004\007\023\016\123\141\154\164\040\114\141\153\145\040 -\103\151\164\171\061\036\060\034\006\003\125\004\012\023\025\124 -\150\145\040\125\123\105\122\124\122\125\123\124\040\116\145\164 -\167\157\162\153\061\041\060\037\006\003\125\004\013\023\030\150 -\164\164\160\072\057\057\167\167\167\056\165\163\145\162\164\162 -\165\163\164\056\143\157\155\061\053\060\051\006\003\125\004\003 -\023\042\125\124\116\055\125\123\105\122\106\151\162\163\164\055 -\116\145\164\167\157\162\153\040\101\160\160\154\151\143\141\164 -\151\157\156\163\060\036\027\015\071\071\060\067\060\071\061\070 -\064\070\063\071\132\027\015\061\071\060\067\060\071\061\070\065 -\067\064\071\132\060\201\243\061\013\060\011\006\003\125\004\006 -\023\002\125\123\061\013\060\011\006\003\125\004\010\023\002\125 -\124\061\027\060\025\006\003\125\004\007\023\016\123\141\154\164 -\040\114\141\153\145\040\103\151\164\171\061\036\060\034\006\003 -\125\004\012\023\025\124\150\145\040\125\123\105\122\124\122\125 -\123\124\040\116\145\164\167\157\162\153\061\041\060\037\006\003 -\125\004\013\023\030\150\164\164\160\072\057\057\167\167\167\056 -\165\163\145\162\164\162\165\163\164\056\143\157\155\061\053\060 -\051\006\003\125\004\003\023\042\125\124\116\055\125\123\105\122 -\106\151\162\163\164\055\116\145\164\167\157\162\153\040\101\160 -\160\154\151\143\141\164\151\157\156\163\060\202\001\042\060\015 -\006\011\052\206\110\206\367\015\001\001\001\005\000\003\202\001 -\017\000\060\202\001\012\002\202\001\001\000\263\373\221\241\344 -\066\125\205\254\006\064\133\240\232\130\262\370\265\017\005\167 -\203\256\062\261\166\222\150\354\043\112\311\166\077\343\234\266 -\067\171\003\271\253\151\215\007\045\266\031\147\344\260\033\030 -\163\141\112\350\176\315\323\057\144\343\246\174\014\372\027\200 -\243\015\107\211\117\121\161\057\356\374\077\371\270\026\200\207 -\211\223\045\040\232\103\202\151\044\166\050\131\065\241\035\300 -\177\203\006\144\026\040\054\323\111\244\205\264\300\141\177\121 -\010\370\150\025\221\200\313\245\325\356\073\072\364\204\004\136 -\140\131\247\214\064\162\356\270\170\305\321\073\022\112\157\176 -\145\047\271\244\125\305\271\157\103\244\305\035\054\231\300\122 -\244\170\114\025\263\100\230\010\153\103\306\001\260\172\173\365 -\153\034\042\077\313\357\377\250\320\072\113\166\025\236\322\321 -\306\056\343\333\127\033\062\242\270\157\350\206\246\077\160\253 -\345\160\222\253\104\036\100\120\373\234\243\142\344\154\156\240 -\310\336\342\200\102\372\351\057\350\316\062\004\217\174\215\267 -\034\243\065\074\025\335\236\303\256\227\245\002\003\001\000\001 -\243\201\221\060\201\216\060\013\006\003\125\035\017\004\004\003 -\002\001\306\060\017\006\003\125\035\023\001\001\377\004\005\060 -\003\001\001\377\060\035\006\003\125\035\016\004\026\004\024\372 -\206\311\333\340\272\351\170\365\113\250\326\025\337\360\323\341 -\152\024\074\060\117\006\003\125\035\037\004\110\060\106\060\104 -\240\102\240\100\206\076\150\164\164\160\072\057\057\143\162\154 -\056\165\163\145\162\164\162\165\163\164\056\143\157\155\057\125 -\124\116\055\125\123\105\122\106\151\162\163\164\055\116\145\164 -\167\157\162\153\101\160\160\154\151\143\141\164\151\157\156\163 -\056\143\162\154\060\015\006\011\052\206\110\206\367\015\001\001 -\005\005\000\003\202\001\001\000\244\363\045\314\321\324\221\203 -\042\320\314\062\253\233\226\116\064\221\124\040\045\064\141\137 -\052\002\025\341\213\252\377\175\144\121\317\012\377\274\175\330 -\041\152\170\313\057\121\157\370\102\035\063\275\353\265\173\224 -\303\303\251\240\055\337\321\051\037\035\376\217\077\273\250\105 -\052\177\321\156\125\044\342\273\002\373\061\077\276\350\274\354 -\100\053\370\001\324\126\070\344\312\104\202\265\141\040\041\147 -\145\366\360\013\347\064\370\245\302\234\243\134\100\037\205\223 -\225\006\336\117\324\047\251\266\245\374\026\315\163\061\077\270 -\145\047\317\324\123\032\360\254\156\237\117\005\014\003\201\247 -\204\051\304\132\275\144\127\162\255\073\317\067\030\246\230\306 -\255\006\264\334\010\243\004\325\051\244\226\232\022\147\112\214 -\140\105\235\361\043\232\260\000\234\150\265\230\120\323\357\216 -\056\222\145\261\110\076\041\276\025\060\052\015\265\014\243\153 -\077\256\177\127\365\037\226\174\337\157\335\202\060\054\145\033 -\100\112\315\150\271\162\354\161\166\354\124\216\037\205\014\001 -\152\372\246\070\254\037\304\204 -END - -# Trust for Certificate "UTN-USER First-Network Applications" -# Issuer: CN=UTN-USERFirst-Network Applications,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Serial Number:44:be:0c:8b:50:00:24:b4:11:d3:36:30:4b:c0:33:77 -# Subject: CN=UTN-USERFirst-Network Applications,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Fri Jul 09 18:48:39 1999 -# Not Valid After : Tue Jul 09 18:57:49 2019 -# Fingerprint (MD5): BF:60:59:A3:5B:BA:F6:A7:76:42:DA:6F:1A:7B:50:CF -# Fingerprint (SHA1): 5D:98:9C:DB:15:96:11:36:51:65:64:1B:56:0F:DB:EA:2A:C2:3E:F1 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "UTN-USER First-Network Applications" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\135\230\234\333\025\226\021\066\121\145\144\033\126\017\333\352 -\052\302\076\361 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\277\140\131\243\133\272\366\247\166\102\332\157\032\173\120\317 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\243\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\053\060\051\006\003\125 -\004\003\023\042\125\124\116\055\125\123\105\122\106\151\162\163 -\164\055\116\145\164\167\157\162\153\040\101\160\160\154\151\143 -\141\164\151\157\156\163 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\104\276\014\213\120\000\044\264\021\323\066\060\113\300 -\063\167 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "Visa eCommerce Root" # @@ -5787,354 +4920,59 @@ CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # -# Certificate "Staat der Nederlanden Root CA" -# -# Issuer: CN=Staat der Nederlanden Root CA,O=Staat der Nederlanden,C=NL -# Serial Number: 10000010 (0x98968a) -# Subject: CN=Staat der Nederlanden Root CA,O=Staat der Nederlanden,C=NL -# Not Valid Before: Tue Dec 17 09:23:49 2002 -# Not Valid After : Wed Dec 16 09:15:38 2015 -# Fingerprint (MD5): 60:84:7C:5A:CE:DB:0C:D4:CB:A7:E9:FE:02:C6:A9:C0 -# Fingerprint (SHA1): 10:1D:FA:3F:D5:0B:CB:BB:9B:B5:60:0C:19:55:A4:1A:F4:73:3A:04 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Staat der Nederlanden Root CA" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\125\061\013\060\011\006\003\125\004\006\023\002\116\114\061 -\036\060\034\006\003\125\004\012\023\025\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\061 -\046\060\044\006\003\125\004\003\023\035\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\040 -\122\157\157\164\040\103\101 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\125\061\013\060\011\006\003\125\004\006\023\002\116\114\061 -\036\060\034\006\003\125\004\012\023\025\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\061 -\046\060\044\006\003\125\004\003\023\035\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\040 -\122\157\157\164\040\103\101 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\000\230\226\212 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\272\060\202\002\242\240\003\002\001\002\002\004\000 -\230\226\212\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\060\125\061\013\060\011\006\003\125\004\006\023\002\116 -\114\061\036\060\034\006\003\125\004\012\023\025\123\164\141\141 -\164\040\144\145\162\040\116\145\144\145\162\154\141\156\144\145 -\156\061\046\060\044\006\003\125\004\003\023\035\123\164\141\141 -\164\040\144\145\162\040\116\145\144\145\162\154\141\156\144\145 -\156\040\122\157\157\164\040\103\101\060\036\027\015\060\062\061 -\062\061\067\060\071\062\063\064\071\132\027\015\061\065\061\062 -\061\066\060\071\061\065\063\070\132\060\125\061\013\060\011\006 -\003\125\004\006\023\002\116\114\061\036\060\034\006\003\125\004 -\012\023\025\123\164\141\141\164\040\144\145\162\040\116\145\144 -\145\162\154\141\156\144\145\156\061\046\060\044\006\003\125\004 -\003\023\035\123\164\141\141\164\040\144\145\162\040\116\145\144 -\145\162\154\141\156\144\145\156\040\122\157\157\164\040\103\101 -\060\202\001\042\060\015\006\011\052\206\110\206\367\015\001\001 -\001\005\000\003\202\001\017\000\060\202\001\012\002\202\001\001 -\000\230\322\265\121\021\172\201\246\024\230\161\155\276\314\347 -\023\033\326\047\016\172\263\152\030\034\266\141\132\325\141\011 -\277\336\220\023\307\147\356\335\363\332\305\014\022\236\065\125 -\076\054\047\210\100\153\367\334\335\042\141\365\302\307\016\365 -\366\325\166\123\115\217\214\274\030\166\067\205\235\350\312\111 -\307\322\117\230\023\011\242\076\042\210\234\177\326\362\020\145 -\264\356\137\030\325\027\343\370\305\375\342\235\242\357\123\016 -\205\167\242\017\341\060\107\356\000\347\063\175\104\147\032\013 -\121\350\213\240\236\120\230\150\064\122\037\056\155\001\362\140 -\105\362\061\353\251\061\150\051\273\172\101\236\306\031\177\224 -\264\121\071\003\177\262\336\247\062\233\264\107\216\157\264\112 -\256\345\257\261\334\260\033\141\274\231\162\336\344\211\267\172 -\046\135\332\063\111\133\122\234\016\365\212\255\303\270\075\350 -\006\152\302\325\052\013\154\173\204\275\126\005\313\206\145\222 -\354\104\053\260\216\271\334\160\013\106\332\255\274\143\210\071 -\372\333\152\376\043\372\274\344\110\364\147\053\152\021\020\041 -\111\002\003\001\000\001\243\201\221\060\201\216\060\014\006\003 -\125\035\023\004\005\060\003\001\001\377\060\117\006\003\125\035 -\040\004\110\060\106\060\104\006\004\125\035\040\000\060\074\060 -\072\006\010\053\006\001\005\005\007\002\001\026\056\150\164\164 -\160\072\057\057\167\167\167\056\160\153\151\157\166\145\162\150 -\145\151\144\056\156\154\057\160\157\154\151\143\151\145\163\057 -\162\157\157\164\055\160\157\154\151\143\171\060\016\006\003\125 -\035\017\001\001\377\004\004\003\002\001\006\060\035\006\003\125 -\035\016\004\026\004\024\250\175\353\274\143\244\164\023\164\000 -\354\226\340\323\064\301\054\277\154\370\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\003\202\001\001\000\005\204 -\207\125\164\066\141\301\273\321\324\306\025\250\023\264\237\244 -\376\273\356\025\264\057\006\014\051\362\250\222\244\141\015\374 -\253\134\010\133\121\023\053\115\302\052\141\310\370\011\130\374 -\055\002\262\071\175\231\146\201\277\156\134\225\105\040\154\346 -\171\247\321\330\034\051\374\302\040\047\121\310\361\174\135\064 -\147\151\205\021\060\306\000\322\327\363\323\174\266\360\061\127 -\050\022\202\163\351\063\057\246\125\264\013\221\224\107\234\372 -\273\172\102\062\350\256\176\055\310\274\254\024\277\331\017\331 -\133\374\301\371\172\225\341\175\176\226\374\161\260\302\114\310 -\337\105\064\311\316\015\362\234\144\010\320\073\303\051\305\262 -\355\220\004\301\261\051\221\305\060\157\301\251\162\063\314\376 -\135\026\027\054\021\151\347\176\376\305\203\010\337\274\334\042 -\072\056\040\151\043\071\126\140\147\220\213\056\166\071\373\021 -\210\227\366\174\275\113\270\040\026\147\005\215\342\073\301\162 -\077\224\225\067\307\135\271\236\330\223\241\027\217\377\014\146 -\025\301\044\174\062\174\003\035\073\241\130\105\062\223 -END - -# Trust for Certificate "Staat der Nederlanden Root CA" -# Issuer: CN=Staat der Nederlanden Root CA,O=Staat der Nederlanden,C=NL -# Serial Number: 10000010 (0x98968a) -# Subject: CN=Staat der Nederlanden Root CA,O=Staat der Nederlanden,C=NL -# Not Valid Before: Tue Dec 17 09:23:49 2002 -# Not Valid After : Wed Dec 16 09:15:38 2015 -# Fingerprint (MD5): 60:84:7C:5A:CE:DB:0C:D4:CB:A7:E9:FE:02:C6:A9:C0 -# Fingerprint (SHA1): 10:1D:FA:3F:D5:0B:CB:BB:9B:B5:60:0C:19:55:A4:1A:F4:73:3A:04 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Staat der Nederlanden Root CA" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\020\035\372\077\325\013\313\273\233\265\140\014\031\125\244\032 -\364\163\072\004 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\140\204\174\132\316\333\014\324\313\247\351\376\002\306\251\300 -END -CKA_ISSUER MULTILINE_OCTAL -\060\125\061\013\060\011\006\003\125\004\006\023\002\116\114\061 -\036\060\034\006\003\125\004\012\023\025\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\061 -\046\060\044\006\003\125\004\003\023\035\123\164\141\141\164\040 -\144\145\162\040\116\145\144\145\162\154\141\156\144\145\156\040 -\122\157\157\164\040\103\101 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\004\000\230\226\212 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "UTN DATACorp SGC Root CA" +# Certificate "UTN USERFirst Email Root CA" # -# Issuer: CN=UTN - DATACorp SGC,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Serial Number:44:be:0c:8b:50:00:21:b4:11:d3:2a:68:06:a9:ad:69 -# Subject: CN=UTN - DATACorp SGC,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Thu Jun 24 18:57:21 1999 -# Not Valid After : Mon Jun 24 19:06:30 2019 -# Fingerprint (MD5): B3:A5:3E:77:21:6D:AC:4A:C0:C9:FB:D5:41:3D:CA:06 -# Fingerprint (SHA1): 58:11:9F:0E:12:82:87:EA:50:FD:D9:87:45:6F:4F:78:DC:FA:D6:D4 +# Issuer: CN=UTN-USERFirst-Client Authentication and Email,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US +# Serial Number:44:be:0c:8b:50:00:24:b4:11:d3:36:25:25:67:c9:89 +# Subject: CN=UTN-USERFirst-Client Authentication and Email,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US +# Not Valid Before: Fri Jul 09 17:28:50 1999 +# Not Valid After : Tue Jul 09 17:36:58 2019 +# Fingerprint (MD5): D7:34:3D:EF:1D:27:09:28:E1:31:02:5B:13:2B:DD:F7 +# Fingerprint (SHA1): B1:72:B1:A5:6D:95:F9:1F:E5:02:87:E1:4D:37:EA:6A:44:63:76:8A CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE CKA_TOKEN CK_BBOOL CK_TRUE CKA_PRIVATE CK_BBOOL CK_FALSE CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "UTN DATACorp SGC Root CA" +CKA_LABEL UTF8 "UTN USERFirst Email Root CA" CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 CKA_SUBJECT MULTILINE_OCTAL -\060\201\223\061\013\060\011\006\003\125\004\006\023\002\125\123 +\060\201\256\061\013\060\011\006\003\125\004\006\023\002\125\123 \061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 \025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 \145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 \025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 \145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 \030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\033\060\031\006\003\125 -\004\003\023\022\125\124\116\040\055\040\104\101\124\101\103\157 -\162\160\040\123\107\103 +\164\162\165\163\164\056\143\157\155\061\066\060\064\006\003\125 +\004\003\023\055\125\124\116\055\125\123\105\122\106\151\162\163 +\164\055\103\154\151\145\156\164\040\101\165\164\150\145\156\164 +\151\143\141\164\151\157\156\040\141\156\144\040\105\155\141\151 +\154 END CKA_ID UTF8 "0" CKA_ISSUER MULTILINE_OCTAL -\060\201\223\061\013\060\011\006\003\125\004\006\023\002\125\123 +\060\201\256\061\013\060\011\006\003\125\004\006\023\002\125\123 \061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 \025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 \145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 \025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 \145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 \030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\033\060\031\006\003\125 -\004\003\023\022\125\124\116\040\055\040\104\101\124\101\103\157 -\162\160\040\123\107\103 +\164\162\165\163\164\056\143\157\155\061\066\060\064\006\003\125 +\004\003\023\055\125\124\116\055\125\123\105\122\106\151\162\163 +\164\055\103\154\151\145\156\164\040\101\165\164\150\145\156\164 +\151\143\141\164\151\157\156\040\141\156\144\040\105\155\141\151 +\154 END CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\104\276\014\213\120\000\041\264\021\323\052\150\006\251 -\255\151 +\002\020\104\276\014\213\120\000\044\264\021\323\066\045\045\147 +\311\211 END CKA_VALUE MULTILINE_OCTAL -\060\202\004\136\060\202\003\106\240\003\002\001\002\002\020\104 -\276\014\213\120\000\041\264\021\323\052\150\006\251\255\151\060 +\060\202\004\242\060\202\003\212\240\003\002\001\002\002\020\104 +\276\014\213\120\000\044\264\021\323\066\045\045\147\311\211\060 \015\006\011\052\206\110\206\367\015\001\001\005\005\000\060\201 -\223\061\013\060\011\006\003\125\004\006\023\002\125\123\061\013 -\060\011\006\003\125\004\010\023\002\125\124\061\027\060\025\006 -\003\125\004\007\023\016\123\141\154\164\040\114\141\153\145\040 -\103\151\164\171\061\036\060\034\006\003\125\004\012\023\025\124 -\150\145\040\125\123\105\122\124\122\125\123\124\040\116\145\164 -\167\157\162\153\061\041\060\037\006\003\125\004\013\023\030\150 -\164\164\160\072\057\057\167\167\167\056\165\163\145\162\164\162 -\165\163\164\056\143\157\155\061\033\060\031\006\003\125\004\003 -\023\022\125\124\116\040\055\040\104\101\124\101\103\157\162\160 -\040\123\107\103\060\036\027\015\071\071\060\066\062\064\061\070 -\065\067\062\061\132\027\015\061\071\060\066\062\064\061\071\060 -\066\063\060\132\060\201\223\061\013\060\011\006\003\125\004\006 -\023\002\125\123\061\013\060\011\006\003\125\004\010\023\002\125 -\124\061\027\060\025\006\003\125\004\007\023\016\123\141\154\164 -\040\114\141\153\145\040\103\151\164\171\061\036\060\034\006\003 -\125\004\012\023\025\124\150\145\040\125\123\105\122\124\122\125 -\123\124\040\116\145\164\167\157\162\153\061\041\060\037\006\003 -\125\004\013\023\030\150\164\164\160\072\057\057\167\167\167\056 -\165\163\145\162\164\162\165\163\164\056\143\157\155\061\033\060 -\031\006\003\125\004\003\023\022\125\124\116\040\055\040\104\101 -\124\101\103\157\162\160\040\123\107\103\060\202\001\042\060\015 -\006\011\052\206\110\206\367\015\001\001\001\005\000\003\202\001 -\017\000\060\202\001\012\002\202\001\001\000\337\356\130\020\242 -\053\156\125\304\216\277\056\106\011\347\340\010\017\056\053\172 -\023\224\033\275\366\266\200\216\145\005\223\000\036\274\257\342 -\017\216\031\015\022\107\354\254\255\243\372\056\160\370\336\156 -\373\126\102\025\236\056\134\357\043\336\041\271\005\166\047\031 -\017\117\326\303\234\264\276\224\031\143\362\246\021\012\353\123 -\110\234\276\362\051\073\026\350\032\240\114\246\311\364\030\131 -\150\300\160\362\123\000\300\136\120\202\245\126\157\066\371\112 -\340\104\206\240\115\116\326\107\156\111\112\313\147\327\246\304 -\005\271\216\036\364\374\377\315\347\066\340\234\005\154\262\063 -\042\025\320\264\340\314\027\300\262\300\364\376\062\077\051\052 -\225\173\330\362\247\116\017\124\174\241\015\200\263\011\003\301 -\377\134\335\136\232\076\274\256\274\107\212\152\256\161\312\037 -\261\052\270\137\102\005\013\354\106\060\321\162\013\312\351\126 -\155\365\357\337\170\276\141\272\262\245\256\004\114\274\250\254 -\151\025\227\275\357\353\264\214\277\065\370\324\303\321\050\016 -\134\072\237\160\030\063\040\167\304\242\257\002\003\001\000\001 -\243\201\253\060\201\250\060\013\006\003\125\035\017\004\004\003 -\002\001\306\060\017\006\003\125\035\023\001\001\377\004\005\060 -\003\001\001\377\060\035\006\003\125\035\016\004\026\004\024\123 -\062\321\263\317\177\372\340\361\240\135\205\116\222\322\236\105 -\035\264\117\060\075\006\003\125\035\037\004\066\060\064\060\062 -\240\060\240\056\206\054\150\164\164\160\072\057\057\143\162\154 -\056\165\163\145\162\164\162\165\163\164\056\143\157\155\057\125 -\124\116\055\104\101\124\101\103\157\162\160\123\107\103\056\143 -\162\154\060\052\006\003\125\035\045\004\043\060\041\006\010\053 -\006\001\005\005\007\003\001\006\012\053\006\001\004\001\202\067 -\012\003\003\006\011\140\206\110\001\206\370\102\004\001\060\015 -\006\011\052\206\110\206\367\015\001\001\005\005\000\003\202\001 -\001\000\047\065\227\000\212\213\050\275\306\063\060\036\051\374 -\342\367\325\230\324\100\273\140\312\277\253\027\054\011\066\177 -\120\372\101\334\256\226\072\012\043\076\211\131\311\243\007\355 -\033\067\255\374\174\276\121\111\132\336\072\012\124\010\026\105 -\302\231\261\207\315\214\150\340\151\003\351\304\116\230\262\073 -\214\026\263\016\240\014\230\120\233\223\251\160\011\310\054\243 -\217\337\002\344\340\161\072\361\264\043\162\240\252\001\337\337 -\230\076\024\120\240\061\046\275\050\351\132\060\046\165\371\173 -\140\034\215\363\315\120\046\155\004\047\232\337\325\015\105\107 -\051\153\054\346\166\331\251\051\175\062\335\311\066\074\275\256 -\065\361\021\236\035\273\220\077\022\107\116\216\327\176\017\142 -\163\035\122\046\070\034\030\111\375\060\164\232\304\345\042\057 -\330\300\215\355\221\172\114\000\217\162\177\135\332\335\033\213 -\105\153\347\335\151\227\250\305\126\114\017\014\366\237\172\221 -\067\366\227\202\340\335\161\151\377\166\077\140\115\074\317\367 -\231\371\306\127\364\311\125\071\170\272\054\171\311\246\210\053 -\364\010 -END - -# Trust for Certificate "UTN DATACorp SGC Root CA" -# Issuer: CN=UTN - DATACorp SGC,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Serial Number:44:be:0c:8b:50:00:21:b4:11:d3:2a:68:06:a9:ad:69 -# Subject: CN=UTN - DATACorp SGC,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Thu Jun 24 18:57:21 1999 -# Not Valid After : Mon Jun 24 19:06:30 2019 -# Fingerprint (MD5): B3:A5:3E:77:21:6D:AC:4A:C0:C9:FB:D5:41:3D:CA:06 -# Fingerprint (SHA1): 58:11:9F:0E:12:82:87:EA:50:FD:D9:87:45:6F:4F:78:DC:FA:D6:D4 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "UTN DATACorp SGC Root CA" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\130\021\237\016\022\202\207\352\120\375\331\207\105\157\117\170 -\334\372\326\324 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\263\245\076\167\041\155\254\112\300\311\373\325\101\075\312\006 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\223\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\033\060\031\006\003\125 -\004\003\023\022\125\124\116\040\055\040\104\101\124\101\103\157 -\162\160\040\123\107\103 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\104\276\014\213\120\000\041\264\021\323\052\150\006\251 -\255\151 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "UTN USERFirst Email Root CA" -# -# Issuer: CN=UTN-USERFirst-Client Authentication and Email,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Serial Number:44:be:0c:8b:50:00:24:b4:11:d3:36:25:25:67:c9:89 -# Subject: CN=UTN-USERFirst-Client Authentication and Email,OU=http://www.usertrust.com,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Fri Jul 09 17:28:50 1999 -# Not Valid After : Tue Jul 09 17:36:58 2019 -# Fingerprint (MD5): D7:34:3D:EF:1D:27:09:28:E1:31:02:5B:13:2B:DD:F7 -# Fingerprint (SHA1): B1:72:B1:A5:6D:95:F9:1F:E5:02:87:E1:4D:37:EA:6A:44:63:76:8A -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "UTN USERFirst Email Root CA" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\256\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\066\060\064\006\003\125 -\004\003\023\055\125\124\116\055\125\123\105\122\106\151\162\163 -\164\055\103\154\151\145\156\164\040\101\165\164\150\145\156\164 -\151\143\141\164\151\157\156\040\141\156\144\040\105\155\141\151 -\154 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\256\061\013\060\011\006\003\125\004\006\023\002\125\123 -\061\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060 -\025\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153 -\145\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023 -\025\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116 -\145\164\167\157\162\153\061\041\060\037\006\003\125\004\013\023 -\030\150\164\164\160\072\057\057\167\167\167\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\061\066\060\064\006\003\125 -\004\003\023\055\125\124\116\055\125\123\105\122\106\151\162\163 -\164\055\103\154\151\145\156\164\040\101\165\164\150\145\156\164 -\151\143\141\164\151\157\156\040\141\156\144\040\105\155\141\151 -\154 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\104\276\014\213\120\000\044\264\021\323\066\045\045\147 -\311\211 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\242\060\202\003\212\240\003\002\001\002\002\020\104 -\276\014\213\120\000\044\264\021\323\066\045\045\147\311\211\060 -\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060\201 -\256\061\013\060\011\006\003\125\004\006\023\002\125\123\061\013 +\256\061\013\060\011\006\003\125\004\006\023\002\125\123\061\013 \060\011\006\003\125\004\010\023\002\125\124\061\027\060\025\006 \003\125\004\007\023\016\123\141\154\164\040\114\141\153\145\040 \103\151\164\171\061\036\060\034\006\003\125\004\012\023\025\124 @@ -6891,755 +5729,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "NetLock Qualified (Class QA) Root" -# -# Issuer: E=info@netlock.hu,CN=NetLock Minositett Kozjegyzoi (Class QA) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 123 (0x7b) -# Subject: E=info@netlock.hu,CN=NetLock Minositett Kozjegyzoi (Class QA) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Sun Mar 30 01:47:11 2003 -# Not Valid After : Thu Dec 15 01:47:11 2022 -# Fingerprint (MD5): D4:80:65:68:24:F9:89:22:28:DB:F5:A4:9A:17:8F:14 -# Fingerprint (SHA1): 01:68:97:E1:A0:B8:F2:C3:B1:34:66:5C:20:A7:27:B7:A1:58:E2:8F -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Qualified (Class QA) Root" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\311\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\102\060\100\006\003\125\004 -\003\023\071\116\145\164\114\157\143\153\040\115\151\156\157\163 -\151\164\145\164\164\040\113\157\172\152\145\147\171\172\157\151 -\040\050\103\154\141\163\163\040\121\101\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157\061\036\060\034 -\006\011\052\206\110\206\367\015\001\011\001\026\017\151\156\146 -\157\100\156\145\164\154\157\143\153\056\150\165 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\311\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\102\060\100\006\003\125\004 -\003\023\071\116\145\164\114\157\143\153\040\115\151\156\157\163 -\151\164\145\164\164\040\113\157\172\152\145\147\171\172\157\151 -\040\050\103\154\141\163\163\040\121\101\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157\061\036\060\034 -\006\011\052\206\110\206\367\015\001\011\001\026\017\151\156\146 -\157\100\156\145\164\154\157\143\153\056\150\165 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\173 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\006\321\060\202\005\271\240\003\002\001\002\002\001\173 -\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060 -\201\311\061\013\060\011\006\003\125\004\006\023\002\110\125\061 -\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160\145 -\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145\164 -\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172\164 -\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030\006 -\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141\156 -\171\153\151\141\144\157\153\061\102\060\100\006\003\125\004\003 -\023\071\116\145\164\114\157\143\153\040\115\151\156\157\163\151 -\164\145\164\164\040\113\157\172\152\145\147\171\172\157\151\040 -\050\103\154\141\163\163\040\121\101\051\040\124\141\156\165\163 -\151\164\166\141\156\171\153\151\141\144\157\061\036\060\034\006 -\011\052\206\110\206\367\015\001\011\001\026\017\151\156\146\157 -\100\156\145\164\154\157\143\153\056\150\165\060\036\027\015\060 -\063\060\063\063\060\060\061\064\067\061\061\132\027\015\062\062 -\061\062\061\065\060\061\064\067\061\061\132\060\201\311\061\013 -\060\011\006\003\125\004\006\023\002\110\125\061\021\060\017\006 -\003\125\004\007\023\010\102\165\144\141\160\145\163\164\061\047 -\060\045\006\003\125\004\012\023\036\116\145\164\114\157\143\153 -\040\110\141\154\157\172\141\164\142\151\172\164\157\156\163\141 -\147\151\040\113\146\164\056\061\032\060\030\006\003\125\004\013 -\023\021\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157\153\061\102\060\100\006\003\125\004\003\023\071\116\145 -\164\114\157\143\153\040\115\151\156\157\163\151\164\145\164\164 -\040\113\157\172\152\145\147\171\172\157\151\040\050\103\154\141 -\163\163\040\121\101\051\040\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\061\036\060\034\006\011\052\206\110 -\206\367\015\001\011\001\026\017\151\156\146\157\100\156\145\164 -\154\157\143\153\056\150\165\060\202\001\042\060\015\006\011\052 -\206\110\206\367\015\001\001\001\005\000\003\202\001\017\000\060 -\202\001\012\002\202\001\001\000\307\122\045\262\330\075\324\204 -\125\011\247\033\275\154\271\024\364\212\002\333\166\374\152\052 -\170\253\345\167\360\156\340\214\043\147\333\245\144\231\271\335 -\001\076\157\357\055\232\074\042\360\135\311\127\240\125\101\177 -\362\103\136\130\202\123\061\145\316\036\362\046\272\000\124\036 -\257\260\274\034\344\122\214\240\062\257\267\067\261\123\147\150 -\164\147\120\366\055\056\144\336\256\046\171\337\337\231\206\253 -\253\177\205\354\240\373\200\314\364\270\014\036\223\105\143\271 -\334\270\133\233\355\133\071\324\137\142\260\247\216\174\146\070 -\054\252\261\010\143\027\147\175\314\275\263\361\303\077\317\120 -\071\355\321\031\203\025\333\207\022\047\226\267\332\352\345\235 -\274\272\352\071\117\213\357\164\232\347\305\320\322\352\206\121 -\034\344\376\144\010\050\004\171\005\353\312\305\161\016\013\357 -\253\352\354\022\021\241\030\005\062\151\321\014\054\032\075\045 -\231\077\265\174\312\155\260\256\231\231\372\010\140\347\031\302 -\362\275\121\323\314\323\002\254\301\021\014\200\316\253\334\224 -\235\153\243\071\123\072\326\205\002\003\000\305\175\243\202\002 -\300\060\202\002\274\060\022\006\003\125\035\023\001\001\377\004 -\010\060\006\001\001\377\002\001\004\060\016\006\003\125\035\017 -\001\001\377\004\004\003\002\001\006\060\202\002\165\006\011\140 -\206\110\001\206\370\102\001\015\004\202\002\146\026\202\002\142 -\106\111\107\131\105\114\105\115\041\040\105\172\145\156\040\164 -\141\156\165\163\151\164\166\141\156\171\040\141\040\116\145\164 -\114\157\143\153\040\113\146\164\056\040\115\151\156\157\163\151 -\164\145\164\164\040\123\172\157\154\147\141\154\164\141\164\141 -\163\151\040\123\172\141\142\141\154\171\172\141\164\141\142\141 -\156\040\154\145\151\162\164\040\145\154\152\141\162\141\163\157 -\153\040\141\154\141\160\152\141\156\040\153\145\163\172\165\154 -\164\056\040\101\040\155\151\156\157\163\151\164\145\164\164\040 -\145\154\145\153\164\162\157\156\151\153\165\163\040\141\154\141 -\151\162\141\163\040\152\157\147\150\141\164\141\163\040\145\162 -\166\145\156\171\145\163\165\154\145\163\145\156\145\153\054\040 -\166\141\154\141\155\151\156\164\040\145\154\146\157\147\141\144 -\141\163\141\156\141\153\040\146\145\154\164\145\164\145\154\145 -\040\141\040\115\151\156\157\163\151\164\145\164\164\040\123\172 -\157\154\147\141\154\164\141\164\141\163\151\040\123\172\141\142 -\141\154\171\172\141\164\142\141\156\054\040\141\172\040\101\154 -\164\141\154\141\156\157\163\040\123\172\145\162\172\157\144\145 -\163\151\040\106\145\154\164\145\164\145\154\145\153\142\145\156 -\040\145\154\157\151\162\164\040\145\154\154\145\156\157\162\172 -\145\163\151\040\145\154\152\141\162\141\163\040\155\145\147\164 -\145\164\145\154\145\056\040\101\040\144\157\153\165\155\145\156 -\164\165\155\157\153\040\155\145\147\164\141\154\141\154\150\141 -\164\157\153\040\141\040\150\164\164\160\163\072\057\057\167\167 -\167\056\156\145\164\154\157\143\153\056\150\165\057\144\157\143 -\163\057\040\143\151\155\145\156\040\166\141\147\171\040\153\145 -\162\150\145\164\157\153\040\141\172\040\151\156\146\157\100\156 -\145\164\154\157\143\153\056\156\145\164\040\145\055\155\141\151 -\154\040\143\151\155\145\156\056\040\127\101\122\116\111\116\107 -\041\040\124\150\145\040\151\163\163\165\141\156\143\145\040\141 -\156\144\040\164\150\145\040\165\163\145\040\157\146\040\164\150 -\151\163\040\143\145\162\164\151\146\151\143\141\164\145\040\141 -\162\145\040\163\165\142\152\145\143\164\040\164\157\040\164\150 -\145\040\116\145\164\114\157\143\153\040\121\165\141\154\151\146 -\151\145\144\040\103\120\123\040\141\166\141\151\154\141\142\154 -\145\040\141\164\040\150\164\164\160\163\072\057\057\167\167\167 -\056\156\145\164\154\157\143\153\056\150\165\057\144\157\143\163 -\057\040\157\162\040\142\171\040\145\055\155\141\151\154\040\141 -\164\040\151\156\146\157\100\156\145\164\154\157\143\153\056\156 -\145\164\060\035\006\003\125\035\016\004\026\004\024\011\152\142 -\026\222\260\132\273\125\016\313\165\062\072\062\345\262\041\311 -\050\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000 -\003\202\001\001\000\221\152\120\234\333\170\201\233\077\213\102 -\343\073\374\246\303\356\103\340\317\363\342\200\065\111\105\166 -\002\342\343\057\005\305\361\052\347\300\101\063\306\266\233\320 -\063\071\315\300\333\241\255\154\067\002\114\130\101\073\362\227 -\222\306\110\250\315\345\212\071\211\141\371\122\227\351\275\366 -\371\224\164\350\161\016\274\167\206\303\006\314\132\174\112\176 -\064\120\060\056\373\177\062\232\215\075\363\040\133\370\152\312 -\206\363\061\114\054\131\200\002\175\376\070\311\060\165\034\267 -\125\343\274\237\272\250\155\204\050\005\165\263\213\015\300\221 -\124\041\347\246\013\264\231\365\121\101\334\315\243\107\042\331 -\307\001\201\304\334\107\117\046\352\037\355\333\315\015\230\364 -\243\234\264\163\062\112\226\231\376\274\177\310\045\130\370\130 -\363\166\146\211\124\244\246\076\304\120\134\272\211\030\202\165 -\110\041\322\117\023\350\140\176\007\166\333\020\265\121\346\252 -\271\150\252\315\366\235\220\165\022\352\070\032\312\104\350\267 -\231\247\052\150\225\146\225\253\255\357\211\313\140\251\006\022 -\306\224\107\351\050 -END - -# Trust for Certificate "NetLock Qualified (Class QA) Root" -# Issuer: E=info@netlock.hu,CN=NetLock Minositett Kozjegyzoi (Class QA) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 123 (0x7b) -# Subject: E=info@netlock.hu,CN=NetLock Minositett Kozjegyzoi (Class QA) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Sun Mar 30 01:47:11 2003 -# Not Valid After : Thu Dec 15 01:47:11 2022 -# Fingerprint (MD5): D4:80:65:68:24:F9:89:22:28:DB:F5:A4:9A:17:8F:14 -# Fingerprint (SHA1): 01:68:97:E1:A0:B8:F2:C3:B1:34:66:5C:20:A7:27:B7:A1:58:E2:8F -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Qualified (Class QA) Root" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\001\150\227\341\240\270\362\303\261\064\146\134\040\247\047\267 -\241\130\342\217 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\324\200\145\150\044\371\211\042\050\333\365\244\232\027\217\024 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\311\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\102\060\100\006\003\125\004 -\003\023\071\116\145\164\114\157\143\153\040\115\151\156\157\163 -\151\164\145\164\164\040\113\157\172\152\145\147\171\172\157\151 -\040\050\103\154\141\163\163\040\121\101\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157\061\036\060\034 -\006\011\052\206\110\206\367\015\001\011\001\026\017\151\156\146 -\157\100\156\145\164\154\157\143\153\056\150\165 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\173 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "NetLock Notary (Class A) Root" -# -# Issuer: CN=NetLock Kozjegyzoi (Class A) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,ST=Hungary,C=HU -# Serial Number: 259 (0x103) -# Subject: CN=NetLock Kozjegyzoi (Class A) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,ST=Hungary,C=HU -# Not Valid Before: Wed Feb 24 23:14:47 1999 -# Not Valid After : Tue Feb 19 23:14:47 2019 -# Fingerprint (MD5): 86:38:6D:5E:49:63:6C:85:5C:DB:6D:DC:94:B7:D0:F7 -# Fingerprint (SHA1): AC:ED:5F:65:53:FD:25:CE:01:5F:1F:7A:48:3B:6A:74:9F:61:78:C6 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Notary (Class A) Root" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\257\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\020\060\016\006\003\125\004\010\023\007\110\165\156\147\141 -\162\171\061\021\060\017\006\003\125\004\007\023\010\102\165\144 -\141\160\145\163\164\061\047\060\045\006\003\125\004\012\023\036 -\116\145\164\114\157\143\153\040\110\141\154\157\172\141\164\142 -\151\172\164\157\156\163\141\147\151\040\113\146\164\056\061\032 -\060\030\006\003\125\004\013\023\021\124\141\156\165\163\151\164 -\166\141\156\171\153\151\141\144\157\153\061\066\060\064\006\003 -\125\004\003\023\055\116\145\164\114\157\143\153\040\113\157\172 -\152\145\147\171\172\157\151\040\050\103\154\141\163\163\040\101 -\051\040\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\257\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\020\060\016\006\003\125\004\010\023\007\110\165\156\147\141 -\162\171\061\021\060\017\006\003\125\004\007\023\010\102\165\144 -\141\160\145\163\164\061\047\060\045\006\003\125\004\012\023\036 -\116\145\164\114\157\143\153\040\110\141\154\157\172\141\164\142 -\151\172\164\157\156\163\141\147\151\040\113\146\164\056\061\032 -\060\030\006\003\125\004\013\023\021\124\141\156\165\163\151\164 -\166\141\156\171\153\151\141\144\157\153\061\066\060\064\006\003 -\125\004\003\023\055\116\145\164\114\157\143\153\040\113\157\172 -\152\145\147\171\172\157\151\040\050\103\154\141\163\163\040\101 -\051\040\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\002\001\003 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\006\175\060\202\005\145\240\003\002\001\002\002\002\001 -\003\060\015\006\011\052\206\110\206\367\015\001\001\004\005\000 -\060\201\257\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\020\060\016\006\003\125\004\010\023\007\110\165\156\147\141 -\162\171\061\021\060\017\006\003\125\004\007\023\010\102\165\144 -\141\160\145\163\164\061\047\060\045\006\003\125\004\012\023\036 -\116\145\164\114\157\143\153\040\110\141\154\157\172\141\164\142 -\151\172\164\157\156\163\141\147\151\040\113\146\164\056\061\032 -\060\030\006\003\125\004\013\023\021\124\141\156\165\163\151\164 -\166\141\156\171\153\151\141\144\157\153\061\066\060\064\006\003 -\125\004\003\023\055\116\145\164\114\157\143\153\040\113\157\172 -\152\145\147\171\172\157\151\040\050\103\154\141\163\163\040\101 -\051\040\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157\060\036\027\015\071\071\060\062\062\064\062\063\061\064 -\064\067\132\027\015\061\071\060\062\061\071\062\063\061\064\064 -\067\132\060\201\257\061\013\060\011\006\003\125\004\006\023\002 -\110\125\061\020\060\016\006\003\125\004\010\023\007\110\165\156 -\147\141\162\171\061\021\060\017\006\003\125\004\007\023\010\102 -\165\144\141\160\145\163\164\061\047\060\045\006\003\125\004\012 -\023\036\116\145\164\114\157\143\153\040\110\141\154\157\172\141 -\164\142\151\172\164\157\156\163\141\147\151\040\113\146\164\056 -\061\032\060\030\006\003\125\004\013\023\021\124\141\156\165\163 -\151\164\166\141\156\171\153\151\141\144\157\153\061\066\060\064 -\006\003\125\004\003\023\055\116\145\164\114\157\143\153\040\113 -\157\172\152\145\147\171\172\157\151\040\050\103\154\141\163\163 -\040\101\051\040\124\141\156\165\163\151\164\166\141\156\171\153 -\151\141\144\157\060\202\001\042\060\015\006\011\052\206\110\206 -\367\015\001\001\001\005\000\003\202\001\017\000\060\202\001\012 -\002\202\001\001\000\274\164\214\017\273\114\364\067\036\251\005 -\202\330\346\341\154\160\352\170\265\156\321\070\104\015\250\203 -\316\135\322\326\325\201\305\324\113\347\133\224\160\046\333\073 -\235\152\114\142\367\161\363\144\326\141\073\075\353\163\243\067 -\331\317\352\214\222\073\315\367\007\334\146\164\227\364\105\042 -\335\364\134\340\277\155\363\276\145\063\344\025\072\277\333\230 -\220\125\070\304\355\246\125\143\013\260\170\004\364\343\156\301 -\077\216\374\121\170\037\222\236\203\302\376\331\260\251\311\274 -\132\000\377\251\250\230\164\373\366\054\076\025\071\015\266\004 -\125\250\016\230\040\102\263\261\045\255\176\232\157\135\123\261 -\253\014\374\353\340\363\172\263\250\263\377\106\366\143\242\330 -\072\230\173\266\254\205\377\260\045\117\164\143\347\023\007\245 -\012\217\005\367\300\144\157\176\247\047\200\226\336\324\056\206 -\140\307\153\053\136\163\173\027\347\221\077\144\014\330\113\042 -\064\053\233\062\362\110\037\237\241\012\204\172\342\302\255\227 -\075\216\325\301\371\126\243\120\351\306\264\372\230\242\356\225 -\346\052\003\214\337\002\003\001\000\001\243\202\002\237\060\202 -\002\233\060\016\006\003\125\035\017\001\001\377\004\004\003\002 -\000\006\060\022\006\003\125\035\023\001\001\377\004\010\060\006 -\001\001\377\002\001\004\060\021\006\011\140\206\110\001\206\370 -\102\001\001\004\004\003\002\000\007\060\202\002\140\006\011\140 -\206\110\001\206\370\102\001\015\004\202\002\121\026\202\002\115 -\106\111\107\131\105\114\105\115\041\040\105\172\145\156\040\164 -\141\156\165\163\151\164\166\141\156\171\040\141\040\116\145\164 -\114\157\143\153\040\113\146\164\056\040\101\154\164\141\154\141 -\156\157\163\040\123\172\157\154\147\141\154\164\141\164\141\163 -\151\040\106\145\154\164\145\164\145\154\145\151\142\145\156\040 -\154\145\151\162\164\040\145\154\152\141\162\141\163\157\153\040 -\141\154\141\160\152\141\156\040\153\145\163\172\165\154\164\056 -\040\101\040\150\151\164\145\154\145\163\151\164\145\163\040\146 -\157\154\171\141\155\141\164\141\164\040\141\040\116\145\164\114 -\157\143\153\040\113\146\164\056\040\164\145\162\155\145\153\146 -\145\154\145\154\157\163\163\145\147\055\142\151\172\164\157\163 -\151\164\141\163\141\040\166\145\144\151\056\040\101\040\144\151 -\147\151\164\141\154\151\163\040\141\154\141\151\162\141\163\040 -\145\154\146\157\147\141\144\141\163\141\156\141\153\040\146\145 -\154\164\145\164\145\154\145\040\141\172\040\145\154\157\151\162 -\164\040\145\154\154\145\156\157\162\172\145\163\151\040\145\154 -\152\141\162\141\163\040\155\145\147\164\145\164\145\154\145\056 -\040\101\172\040\145\154\152\141\162\141\163\040\154\145\151\162 -\141\163\141\040\155\145\147\164\141\154\141\154\150\141\164\157 -\040\141\040\116\145\164\114\157\143\153\040\113\146\164\056\040 -\111\156\164\145\162\156\145\164\040\150\157\156\154\141\160\152 -\141\156\040\141\040\150\164\164\160\163\072\057\057\167\167\167 -\056\156\145\164\154\157\143\153\056\156\145\164\057\144\157\143 -\163\040\143\151\155\145\156\040\166\141\147\171\040\153\145\162 -\150\145\164\157\040\141\172\040\145\154\154\145\156\157\162\172 -\145\163\100\156\145\164\154\157\143\153\056\156\145\164\040\145 -\055\155\141\151\154\040\143\151\155\145\156\056\040\111\115\120 -\117\122\124\101\116\124\041\040\124\150\145\040\151\163\163\165 -\141\156\143\145\040\141\156\144\040\164\150\145\040\165\163\145 -\040\157\146\040\164\150\151\163\040\143\145\162\164\151\146\151 -\143\141\164\145\040\151\163\040\163\165\142\152\145\143\164\040 -\164\157\040\164\150\145\040\116\145\164\114\157\143\153\040\103 -\120\123\040\141\166\141\151\154\141\142\154\145\040\141\164\040 -\150\164\164\160\163\072\057\057\167\167\167\056\156\145\164\154 -\157\143\153\056\156\145\164\057\144\157\143\163\040\157\162\040 -\142\171\040\145\055\155\141\151\154\040\141\164\040\143\160\163 -\100\156\145\164\154\157\143\153\056\156\145\164\056\060\015\006 -\011\052\206\110\206\367\015\001\001\004\005\000\003\202\001\001 -\000\110\044\106\367\272\126\157\372\310\050\003\100\116\345\061 -\071\153\046\153\123\177\333\337\337\363\161\075\046\300\024\016 -\306\147\173\043\250\014\163\335\001\273\306\312\156\067\071\125 -\325\307\214\126\040\016\050\012\016\322\052\244\260\111\122\306 -\070\007\376\276\012\011\214\321\230\317\312\332\024\061\241\117 -\322\071\374\017\021\054\103\303\335\253\223\307\125\076\107\174 -\030\032\000\334\363\173\330\362\177\122\154\040\364\013\137\151 -\122\364\356\370\262\051\140\353\343\111\061\041\015\326\265\020 -\101\342\101\011\154\342\032\232\126\113\167\002\366\240\233\232 -\047\207\350\125\051\161\302\220\237\105\170\032\341\025\144\075 -\320\016\330\240\166\237\256\305\320\056\352\326\017\126\354\144 -\177\132\233\024\130\001\047\176\023\120\307\153\052\346\150\074 -\277\134\240\012\033\341\016\172\351\342\200\303\351\351\366\375 -\154\021\236\320\345\050\047\053\124\062\102\024\202\165\346\112 -\360\053\146\165\143\214\242\373\004\076\203\016\233\066\360\030 -\344\046\040\303\214\360\050\007\255\074\027\146\210\265\375\266 -\210 -END - -# Trust for Certificate "NetLock Notary (Class A) Root" -# Issuer: CN=NetLock Kozjegyzoi (Class A) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,ST=Hungary,C=HU -# Serial Number: 259 (0x103) -# Subject: CN=NetLock Kozjegyzoi (Class A) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,ST=Hungary,C=HU -# Not Valid Before: Wed Feb 24 23:14:47 1999 -# Not Valid After : Tue Feb 19 23:14:47 2019 -# Fingerprint (MD5): 86:38:6D:5E:49:63:6C:85:5C:DB:6D:DC:94:B7:D0:F7 -# Fingerprint (SHA1): AC:ED:5F:65:53:FD:25:CE:01:5F:1F:7A:48:3B:6A:74:9F:61:78:C6 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Notary (Class A) Root" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\254\355\137\145\123\375\045\316\001\137\037\172\110\073\152\164 -\237\141\170\306 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\206\070\155\136\111\143\154\205\134\333\155\334\224\267\320\367 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\257\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\020\060\016\006\003\125\004\010\023\007\110\165\156\147\141 -\162\171\061\021\060\017\006\003\125\004\007\023\010\102\165\144 -\141\160\145\163\164\061\047\060\045\006\003\125\004\012\023\036 -\116\145\164\114\157\143\153\040\110\141\154\157\172\141\164\142 -\151\172\164\157\156\163\141\147\151\040\113\146\164\056\061\032 -\060\030\006\003\125\004\013\023\021\124\141\156\165\163\151\164 -\166\141\156\171\153\151\141\144\157\153\061\066\060\064\006\003 -\125\004\003\023\055\116\145\164\114\157\143\153\040\113\157\172 -\152\145\147\171\172\157\151\040\050\103\154\141\163\163\040\101 -\051\040\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\002\001\003 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "NetLock Business (Class B) Root" -# -# Issuer: CN=NetLock Uzleti (Class B) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 105 (0x69) -# Subject: CN=NetLock Uzleti (Class B) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Thu Feb 25 14:10:22 1999 -# Not Valid After : Wed Feb 20 14:10:22 2019 -# Fingerprint (MD5): 39:16:AA:B9:6A:41:E1:14:69:DF:9E:6C:3B:72:DC:B6 -# Fingerprint (SHA1): 87:9F:4B:EE:05:DF:98:58:3B:E3:60:D6:33:E7:0D:3F:FE:98:71:AF -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Business (Class B) Root" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\231\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\062\060\060\006\003\125\004 -\003\023\051\116\145\164\114\157\143\153\040\125\172\154\145\164 -\151\040\050\103\154\141\163\163\040\102\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\231\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\062\060\060\006\003\125\004 -\003\023\051\116\145\164\114\157\143\153\040\125\172\154\145\164 -\151\040\050\103\154\141\163\163\040\102\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\151 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\005\113\060\202\004\264\240\003\002\001\002\002\001\151 -\060\015\006\011\052\206\110\206\367\015\001\001\004\005\000\060 -\201\231\061\013\060\011\006\003\125\004\006\023\002\110\125\061 -\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160\145 -\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145\164 -\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172\164 -\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030\006 -\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141\156 -\171\153\151\141\144\157\153\061\062\060\060\006\003\125\004\003 -\023\051\116\145\164\114\157\143\153\040\125\172\154\145\164\151 -\040\050\103\154\141\163\163\040\102\051\040\124\141\156\165\163 -\151\164\166\141\156\171\153\151\141\144\157\060\036\027\015\071 -\071\060\062\062\065\061\064\061\060\062\062\132\027\015\061\071 -\060\062\062\060\061\064\061\060\062\062\132\060\201\231\061\013 -\060\011\006\003\125\004\006\023\002\110\125\061\021\060\017\006 -\003\125\004\007\023\010\102\165\144\141\160\145\163\164\061\047 -\060\045\006\003\125\004\012\023\036\116\145\164\114\157\143\153 -\040\110\141\154\157\172\141\164\142\151\172\164\157\156\163\141 -\147\151\040\113\146\164\056\061\032\060\030\006\003\125\004\013 -\023\021\124\141\156\165\163\151\164\166\141\156\171\153\151\141 -\144\157\153\061\062\060\060\006\003\125\004\003\023\051\116\145 -\164\114\157\143\153\040\125\172\154\145\164\151\040\050\103\154 -\141\163\163\040\102\051\040\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\060\201\237\060\015\006\011\052\206 -\110\206\367\015\001\001\001\005\000\003\201\215\000\060\201\211 -\002\201\201\000\261\352\004\354\040\240\043\302\217\070\140\317 -\307\106\263\325\033\376\373\271\231\236\004\334\034\177\214\112 -\201\230\356\244\324\312\212\027\271\042\177\203\012\165\114\233 -\300\151\330\144\071\243\355\222\243\375\133\134\164\032\300\107 -\312\072\151\166\232\272\342\104\027\374\114\243\325\376\270\227 -\210\257\210\003\211\037\244\362\004\076\310\007\013\346\371\263 -\057\172\142\024\011\106\024\312\144\365\213\200\265\142\250\330 -\153\326\161\223\055\263\277\011\124\130\355\006\353\250\173\334 -\103\261\241\151\002\003\001\000\001\243\202\002\237\060\202\002 -\233\060\022\006\003\125\035\023\001\001\377\004\010\060\006\001 -\001\377\002\001\004\060\016\006\003\125\035\017\001\001\377\004 -\004\003\002\000\006\060\021\006\011\140\206\110\001\206\370\102 -\001\001\004\004\003\002\000\007\060\202\002\140\006\011\140\206 -\110\001\206\370\102\001\015\004\202\002\121\026\202\002\115\106 -\111\107\131\105\114\105\115\041\040\105\172\145\156\040\164\141 -\156\165\163\151\164\166\141\156\171\040\141\040\116\145\164\114 -\157\143\153\040\113\146\164\056\040\101\154\164\141\154\141\156 -\157\163\040\123\172\157\154\147\141\154\164\141\164\141\163\151 -\040\106\145\154\164\145\164\145\154\145\151\142\145\156\040\154 -\145\151\162\164\040\145\154\152\141\162\141\163\157\153\040\141 -\154\141\160\152\141\156\040\153\145\163\172\165\154\164\056\040 -\101\040\150\151\164\145\154\145\163\151\164\145\163\040\146\157 -\154\171\141\155\141\164\141\164\040\141\040\116\145\164\114\157 -\143\153\040\113\146\164\056\040\164\145\162\155\145\153\146\145 -\154\145\154\157\163\163\145\147\055\142\151\172\164\157\163\151 -\164\141\163\141\040\166\145\144\151\056\040\101\040\144\151\147 -\151\164\141\154\151\163\040\141\154\141\151\162\141\163\040\145 -\154\146\157\147\141\144\141\163\141\156\141\153\040\146\145\154 -\164\145\164\145\154\145\040\141\172\040\145\154\157\151\162\164 -\040\145\154\154\145\156\157\162\172\145\163\151\040\145\154\152 -\141\162\141\163\040\155\145\147\164\145\164\145\154\145\056\040 -\101\172\040\145\154\152\141\162\141\163\040\154\145\151\162\141 -\163\141\040\155\145\147\164\141\154\141\154\150\141\164\157\040 -\141\040\116\145\164\114\157\143\153\040\113\146\164\056\040\111 -\156\164\145\162\156\145\164\040\150\157\156\154\141\160\152\141 -\156\040\141\040\150\164\164\160\163\072\057\057\167\167\167\056 -\156\145\164\154\157\143\153\056\156\145\164\057\144\157\143\163 -\040\143\151\155\145\156\040\166\141\147\171\040\153\145\162\150 -\145\164\157\040\141\172\040\145\154\154\145\156\157\162\172\145 -\163\100\156\145\164\154\157\143\153\056\156\145\164\040\145\055 -\155\141\151\154\040\143\151\155\145\156\056\040\111\115\120\117 -\122\124\101\116\124\041\040\124\150\145\040\151\163\163\165\141 -\156\143\145\040\141\156\144\040\164\150\145\040\165\163\145\040 -\157\146\040\164\150\151\163\040\143\145\162\164\151\146\151\143 -\141\164\145\040\151\163\040\163\165\142\152\145\143\164\040\164 -\157\040\164\150\145\040\116\145\164\114\157\143\153\040\103\120 -\123\040\141\166\141\151\154\141\142\154\145\040\141\164\040\150 -\164\164\160\163\072\057\057\167\167\167\056\156\145\164\154\157 -\143\153\056\156\145\164\057\144\157\143\163\040\157\162\040\142 -\171\040\145\055\155\141\151\154\040\141\164\040\143\160\163\100 -\156\145\164\154\157\143\153\056\156\145\164\056\060\015\006\011 -\052\206\110\206\367\015\001\001\004\005\000\003\201\201\000\004 -\333\256\214\027\257\370\016\220\061\116\315\076\011\300\155\072 -\260\370\063\114\107\114\343\165\210\020\227\254\260\070\025\221 -\306\051\226\314\041\300\155\074\245\164\317\330\202\245\071\303 -\145\343\102\160\273\042\220\343\175\333\065\166\341\240\265\332 -\237\160\156\223\032\060\071\035\060\333\056\343\174\262\221\262 -\321\067\051\372\271\326\027\134\107\117\343\035\070\353\237\325 -\173\225\250\050\236\025\112\321\321\320\053\000\227\240\342\222 -\066\053\143\254\130\001\153\063\051\120\206\203\361\001\110 -END - -# Trust for Certificate "NetLock Business (Class B) Root" -# Issuer: CN=NetLock Uzleti (Class B) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 105 (0x69) -# Subject: CN=NetLock Uzleti (Class B) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Thu Feb 25 14:10:22 1999 -# Not Valid After : Wed Feb 20 14:10:22 2019 -# Fingerprint (MD5): 39:16:AA:B9:6A:41:E1:14:69:DF:9E:6C:3B:72:DC:B6 -# Fingerprint (SHA1): 87:9F:4B:EE:05:DF:98:58:3B:E3:60:D6:33:E7:0D:3F:FE:98:71:AF -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Business (Class B) Root" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\207\237\113\356\005\337\230\130\073\343\140\326\063\347\015\077 -\376\230\161\257 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\071\026\252\271\152\101\341\024\151\337\236\154\073\162\334\266 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\231\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\062\060\060\006\003\125\004 -\003\023\051\116\145\164\114\157\143\153\040\125\172\154\145\164 -\151\040\050\103\154\141\163\163\040\102\051\040\124\141\156\165 -\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\151 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "NetLock Express (Class C) Root" -# -# Issuer: CN=NetLock Expressz (Class C) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 104 (0x68) -# Subject: CN=NetLock Expressz (Class C) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Thu Feb 25 14:08:11 1999 -# Not Valid After : Wed Feb 20 14:08:11 2019 -# Fingerprint (MD5): 4F:EB:F1:F0:70:C2:80:63:5D:58:9F:DA:12:3C:A9:C4 -# Fingerprint (SHA1): E3:92:51:2F:0A:CF:F5:05:DF:F6:DE:06:7F:75:37:E1:65:EA:57:4B -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Express (Class C) Root" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\233\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\064\060\062\006\003\125\004 -\003\023\053\116\145\164\114\157\143\153\040\105\170\160\162\145 -\163\163\172\040\050\103\154\141\163\163\040\103\051\040\124\141 -\156\165\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\233\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\064\060\062\006\003\125\004 -\003\023\053\116\145\164\114\157\143\153\040\105\170\160\162\145 -\163\163\172\040\050\103\154\141\163\163\040\103\051\040\124\141 -\156\165\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\150 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\005\117\060\202\004\270\240\003\002\001\002\002\001\150 -\060\015\006\011\052\206\110\206\367\015\001\001\004\005\000\060 -\201\233\061\013\060\011\006\003\125\004\006\023\002\110\125\061 -\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160\145 -\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145\164 -\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172\164 -\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030\006 -\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141\156 -\171\153\151\141\144\157\153\061\064\060\062\006\003\125\004\003 -\023\053\116\145\164\114\157\143\153\040\105\170\160\162\145\163 -\163\172\040\050\103\154\141\163\163\040\103\051\040\124\141\156 -\165\163\151\164\166\141\156\171\153\151\141\144\157\060\036\027 -\015\071\071\060\062\062\065\061\064\060\070\061\061\132\027\015 -\061\071\060\062\062\060\061\064\060\070\061\061\132\060\201\233 -\061\013\060\011\006\003\125\004\006\023\002\110\125\061\021\060 -\017\006\003\125\004\007\023\010\102\165\144\141\160\145\163\164 -\061\047\060\045\006\003\125\004\012\023\036\116\145\164\114\157 -\143\153\040\110\141\154\157\172\141\164\142\151\172\164\157\156 -\163\141\147\151\040\113\146\164\056\061\032\060\030\006\003\125 -\004\013\023\021\124\141\156\165\163\151\164\166\141\156\171\153 -\151\141\144\157\153\061\064\060\062\006\003\125\004\003\023\053 -\116\145\164\114\157\143\153\040\105\170\160\162\145\163\163\172 -\040\050\103\154\141\163\163\040\103\051\040\124\141\156\165\163 -\151\164\166\141\156\171\153\151\141\144\157\060\201\237\060\015 -\006\011\052\206\110\206\367\015\001\001\001\005\000\003\201\215 -\000\060\201\211\002\201\201\000\353\354\260\154\141\212\043\045 -\257\140\040\343\331\237\374\223\013\333\135\215\260\241\263\100 -\072\202\316\375\165\340\170\062\003\206\132\206\225\221\355\123 -\372\235\100\374\346\350\335\331\133\172\003\275\135\363\073\014 -\303\121\171\233\255\125\240\351\320\003\020\257\012\272\024\102 -\331\122\046\021\042\307\322\040\314\202\244\232\251\376\270\201 -\166\235\152\267\322\066\165\076\261\206\011\366\156\155\176\116 -\267\172\354\256\161\204\366\004\063\010\045\062\353\164\254\026 -\104\306\344\100\223\035\177\255\002\003\001\000\001\243\202\002 -\237\060\202\002\233\060\022\006\003\125\035\023\001\001\377\004 -\010\060\006\001\001\377\002\001\004\060\016\006\003\125\035\017 -\001\001\377\004\004\003\002\000\006\060\021\006\011\140\206\110 -\001\206\370\102\001\001\004\004\003\002\000\007\060\202\002\140 -\006\011\140\206\110\001\206\370\102\001\015\004\202\002\121\026 -\202\002\115\106\111\107\131\105\114\105\115\041\040\105\172\145 -\156\040\164\141\156\165\163\151\164\166\141\156\171\040\141\040 -\116\145\164\114\157\143\153\040\113\146\164\056\040\101\154\164 -\141\154\141\156\157\163\040\123\172\157\154\147\141\154\164\141 -\164\141\163\151\040\106\145\154\164\145\164\145\154\145\151\142 -\145\156\040\154\145\151\162\164\040\145\154\152\141\162\141\163 -\157\153\040\141\154\141\160\152\141\156\040\153\145\163\172\165 -\154\164\056\040\101\040\150\151\164\145\154\145\163\151\164\145 -\163\040\146\157\154\171\141\155\141\164\141\164\040\141\040\116 -\145\164\114\157\143\153\040\113\146\164\056\040\164\145\162\155 -\145\153\146\145\154\145\154\157\163\163\145\147\055\142\151\172 -\164\157\163\151\164\141\163\141\040\166\145\144\151\056\040\101 -\040\144\151\147\151\164\141\154\151\163\040\141\154\141\151\162 -\141\163\040\145\154\146\157\147\141\144\141\163\141\156\141\153 -\040\146\145\154\164\145\164\145\154\145\040\141\172\040\145\154 -\157\151\162\164\040\145\154\154\145\156\157\162\172\145\163\151 -\040\145\154\152\141\162\141\163\040\155\145\147\164\145\164\145 -\154\145\056\040\101\172\040\145\154\152\141\162\141\163\040\154 -\145\151\162\141\163\141\040\155\145\147\164\141\154\141\154\150 -\141\164\157\040\141\040\116\145\164\114\157\143\153\040\113\146 -\164\056\040\111\156\164\145\162\156\145\164\040\150\157\156\154 -\141\160\152\141\156\040\141\040\150\164\164\160\163\072\057\057 -\167\167\167\056\156\145\164\154\157\143\153\056\156\145\164\057 -\144\157\143\163\040\143\151\155\145\156\040\166\141\147\171\040 -\153\145\162\150\145\164\157\040\141\172\040\145\154\154\145\156 -\157\162\172\145\163\100\156\145\164\154\157\143\153\056\156\145 -\164\040\145\055\155\141\151\154\040\143\151\155\145\156\056\040 -\111\115\120\117\122\124\101\116\124\041\040\124\150\145\040\151 -\163\163\165\141\156\143\145\040\141\156\144\040\164\150\145\040 -\165\163\145\040\157\146\040\164\150\151\163\040\143\145\162\164 -\151\146\151\143\141\164\145\040\151\163\040\163\165\142\152\145 -\143\164\040\164\157\040\164\150\145\040\116\145\164\114\157\143 -\153\040\103\120\123\040\141\166\141\151\154\141\142\154\145\040 -\141\164\040\150\164\164\160\163\072\057\057\167\167\167\056\156 -\145\164\154\157\143\153\056\156\145\164\057\144\157\143\163\040 -\157\162\040\142\171\040\145\055\155\141\151\154\040\141\164\040 -\143\160\163\100\156\145\164\154\157\143\153\056\156\145\164\056 -\060\015\006\011\052\206\110\206\367\015\001\001\004\005\000\003 -\201\201\000\020\255\177\327\014\062\200\012\330\206\361\171\230 -\265\255\324\315\263\066\304\226\110\301\134\315\232\331\005\056 -\237\276\120\353\364\046\024\020\055\324\146\027\370\236\301\047 -\375\361\355\344\173\113\240\154\265\253\232\127\160\246\355\240 -\244\355\056\365\375\374\275\376\115\067\010\014\274\343\226\203 -\042\365\111\033\177\113\053\264\124\301\200\174\231\116\035\320 -\214\356\320\254\345\222\372\165\126\376\144\240\023\217\270\270 -\026\235\141\005\147\200\310\320\330\245\007\002\064\230\004\215 -\063\004\324 -END - -# Trust for Certificate "NetLock Express (Class C) Root" -# Issuer: CN=NetLock Expressz (Class C) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Serial Number: 104 (0x68) -# Subject: CN=NetLock Expressz (Class C) Tanusitvanykiado,OU=Tanusitvanykiadok,O=NetLock Halozatbiztonsagi Kft.,L=Budapest,C=HU -# Not Valid Before: Thu Feb 25 14:08:11 1999 -# Not Valid After : Wed Feb 20 14:08:11 2019 -# Fingerprint (MD5): 4F:EB:F1:F0:70:C2:80:63:5D:58:9F:DA:12:3C:A9:C4 -# Fingerprint (SHA1): E3:92:51:2F:0A:CF:F5:05:DF:F6:DE:06:7F:75:37:E1:65:EA:57:4B -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "NetLock Express (Class C) Root" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\343\222\121\057\012\317\365\005\337\366\336\006\177\165\067\341 -\145\352\127\113 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\117\353\361\360\160\302\200\143\135\130\237\332\022\074\251\304 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\233\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\023\010\102\165\144\141\160 -\145\163\164\061\047\060\045\006\003\125\004\012\023\036\116\145 -\164\114\157\143\153\040\110\141\154\157\172\141\164\142\151\172 -\164\157\156\163\141\147\151\040\113\146\164\056\061\032\060\030 -\006\003\125\004\013\023\021\124\141\156\165\163\151\164\166\141 -\156\171\153\151\141\144\157\153\061\064\060\062\006\003\125\004 -\003\023\053\116\145\164\114\157\143\153\040\105\170\160\162\145 -\163\163\172\040\050\103\154\141\163\163\040\103\051\040\124\141 -\156\165\163\151\164\166\141\156\171\153\151\141\144\157 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\150 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "XRamp Global CA Root" # @@ -9443,359 +7532,38 @@ CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # -# Certificate "TURKTRUST Certificate Services Provider Root 1" +# Certificate "SwissSign Platinum CA - G2" # -# Issuer: O=(c) 2005 T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hiz...,L=ANKARA,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Serial Number: 1 (0x1) -# Subject: O=(c) 2005 T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hiz...,L=ANKARA,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Not Valid Before: Fri May 13 10:27:17 2005 -# Not Valid After : Sun Mar 22 10:27:17 2015 -# Fingerprint (MD5): F1:6A:22:18:C9:CD:DF:CE:82:1D:1D:B7:78:5C:A9:A5 -# Fingerprint (SHA1): 79:98:A3:08:E1:4D:65:85:E6:C2:1E:15:3A:71:9F:BA:5A:D3:4A:D9 +# Issuer: CN=SwissSign Platinum CA - G2,O=SwissSign AG,C=CH +# Serial Number:4e:b2:00:67:0c:03:5d:4f +# Subject: CN=SwissSign Platinum CA - G2,O=SwissSign AG,C=CH +# Not Valid Before: Wed Oct 25 08:36:00 2006 +# Not Valid After : Sat Oct 25 08:36:00 2036 +# Fingerprint (MD5): C9:98:27:77:28:1E:3D:0E:15:3C:84:00:B8:85:03:E6 +# Fingerprint (SHA1): 56:E0:FA:C0:3B:8F:18:23:55:18:E5:D3:11:CA:E8:C2:43:31:AB:66 CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE CKA_TOKEN CK_BBOOL CK_TRUE CKA_PRIVATE CK_BBOOL CK_FALSE CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TURKTRUST Certificate Services Provider Root 1" +CKA_LABEL UTF8 "SwissSign Platinum CA - G2" CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 CKA_SUBJECT MULTILINE_OCTAL -\060\201\267\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\014\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\116\113\101 -\122\101\061\126\060\124\006\003\125\004\012\014\115\050\143\051 -\040\062\060\060\065\040\124\303\234\122\113\124\122\125\123\124 -\040\102\151\154\147\151\040\304\260\154\145\164\151\305\237\151 -\155\040\166\145\040\102\151\154\151\305\237\151\155\040\107\303 -\274\166\145\156\154\151\304\237\151\040\110\151\172\155\145\164 -\154\145\162\151\040\101\056\305\236\056 +\060\111\061\013\060\011\006\003\125\004\006\023\002\103\110\061 +\025\060\023\006\003\125\004\012\023\014\123\167\151\163\163\123 +\151\147\156\040\101\107\061\043\060\041\006\003\125\004\003\023 +\032\123\167\151\163\163\123\151\147\156\040\120\154\141\164\151 +\156\165\155\040\103\101\040\055\040\107\062 END CKA_ID UTF8 "0" CKA_ISSUER MULTILINE_OCTAL -\060\201\267\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\014\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\116\113\101 -\122\101\061\126\060\124\006\003\125\004\012\014\115\050\143\051 -\040\062\060\060\065\040\124\303\234\122\113\124\122\125\123\124 -\040\102\151\154\147\151\040\304\260\154\145\164\151\305\237\151 -\155\040\166\145\040\102\151\154\151\305\237\151\155\040\107\303 -\274\166\145\156\154\151\304\237\151\040\110\151\172\155\145\164 -\154\145\162\151\040\101\056\305\236\056 +\060\111\061\013\060\011\006\003\125\004\006\023\002\103\110\061 +\025\060\023\006\003\125\004\012\023\014\123\167\151\163\163\123 +\151\147\156\040\101\107\061\043\060\041\006\003\125\004\003\023 +\032\123\167\151\163\163\123\151\147\156\040\120\154\141\164\151 +\156\165\155\040\103\101\040\055\040\107\062 END CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\373\060\202\002\343\240\003\002\001\002\002\001\001 -\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060 -\201\267\061\077\060\075\006\003\125\004\003\014\066\124\303\234 -\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157\156 -\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151\172 -\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304\261 -\163\304\261\061\013\060\011\006\003\125\004\006\014\002\124\122 -\061\017\060\015\006\003\125\004\007\014\006\101\116\113\101\122 -\101\061\126\060\124\006\003\125\004\012\014\115\050\143\051\040 -\062\060\060\065\040\124\303\234\122\113\124\122\125\123\124\040 -\102\151\154\147\151\040\304\260\154\145\164\151\305\237\151\155 -\040\166\145\040\102\151\154\151\305\237\151\155\040\107\303\274 -\166\145\156\154\151\304\237\151\040\110\151\172\155\145\164\154 -\145\162\151\040\101\056\305\236\056\060\036\027\015\060\065\060 -\065\061\063\061\060\062\067\061\067\132\027\015\061\065\060\063 -\062\062\061\060\062\067\061\067\132\060\201\267\061\077\060\075 -\006\003\125\004\003\014\066\124\303\234\122\113\124\122\125\123 -\124\040\105\154\145\153\164\162\157\156\151\153\040\123\145\162 -\164\151\146\151\153\141\040\110\151\172\155\145\164\040\123\141 -\304\237\154\141\171\304\261\143\304\261\163\304\261\061\013\060 -\011\006\003\125\004\006\014\002\124\122\061\017\060\015\006\003 -\125\004\007\014\006\101\116\113\101\122\101\061\126\060\124\006 -\003\125\004\012\014\115\050\143\051\040\062\060\060\065\040\124 -\303\234\122\113\124\122\125\123\124\040\102\151\154\147\151\040 -\304\260\154\145\164\151\305\237\151\155\040\166\145\040\102\151 -\154\151\305\237\151\155\040\107\303\274\166\145\156\154\151\304 -\237\151\040\110\151\172\155\145\164\154\145\162\151\040\101\056 -\305\236\056\060\202\001\042\060\015\006\011\052\206\110\206\367 -\015\001\001\001\005\000\003\202\001\017\000\060\202\001\012\002 -\202\001\001\000\312\122\005\326\143\003\330\034\137\335\322\173 -\135\362\014\140\141\133\153\073\164\053\170\015\175\105\275\042 -\164\350\214\003\301\306\021\052\075\225\274\251\224\260\273\221 -\227\310\151\174\204\305\264\221\154\154\023\152\244\125\255\244 -\205\350\225\176\263\000\257\000\302\005\030\365\160\235\066\213 -\256\313\344\033\201\177\223\210\373\152\125\273\175\205\222\316 -\272\130\237\333\062\305\275\135\357\042\112\057\101\007\176\111 -\141\263\206\354\116\246\101\156\204\274\003\354\365\073\034\310 -\037\302\356\250\356\352\022\112\215\024\317\363\012\340\120\071 -\371\010\065\370\021\131\255\347\042\352\113\312\024\006\336\102 -\272\262\231\363\055\124\210\020\006\352\341\032\076\075\147\037 -\373\316\373\174\202\350\021\135\112\301\271\024\352\124\331\146 -\233\174\211\175\004\232\142\311\351\122\074\236\234\357\322\365 -\046\344\346\345\030\174\213\156\337\154\314\170\133\117\162\262 -\313\134\077\214\005\215\321\114\214\255\222\307\341\170\177\145 -\154\111\006\120\054\236\062\302\327\112\306\165\212\131\116\165 -\157\107\136\301\002\003\001\000\001\243\020\060\016\060\014\006 -\003\125\035\023\004\005\060\003\001\001\377\060\015\006\011\052 -\206\110\206\367\015\001\001\005\005\000\003\202\001\001\000\025 -\365\125\377\067\226\200\131\041\244\374\241\025\114\040\366\324 -\137\332\003\044\374\317\220\032\364\041\012\232\356\072\261\152 -\357\357\370\140\321\114\066\146\105\035\363\146\002\164\004\173 -\222\060\250\336\012\166\017\357\225\156\275\311\067\346\032\015 -\254\211\110\133\314\203\066\302\365\106\134\131\202\126\264\325 -\376\043\264\330\124\034\104\253\304\247\345\024\316\074\101\141 -\174\103\346\315\304\201\011\213\044\373\124\045\326\026\250\226 -\014\147\007\157\263\120\107\343\034\044\050\335\052\230\244\141 -\376\333\352\022\067\274\001\032\064\205\275\156\117\347\221\162 -\007\104\205\036\130\312\124\104\335\367\254\271\313\211\041\162 -\333\217\300\151\051\227\052\243\256\030\043\227\034\101\052\213 -\174\052\301\174\220\350\251\050\300\323\221\306\255\050\207\100 -\150\265\377\354\247\322\323\070\030\234\323\175\151\135\360\306 -\245\036\044\033\243\107\374\151\007\150\347\344\232\264\355\017 -\241\207\207\002\316\207\322\110\116\341\274\377\313\361\162\222 -\104\144\003\045\352\336\133\156\237\311\362\116\254\335\307 -END - -# Trust for Certificate "TURKTRUST Certificate Services Provider Root 1" -# Issuer: O=(c) 2005 T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hiz...,L=ANKARA,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Serial Number: 1 (0x1) -# Subject: O=(c) 2005 T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hiz...,L=ANKARA,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Not Valid Before: Fri May 13 10:27:17 2005 -# Not Valid After : Sun Mar 22 10:27:17 2015 -# Fingerprint (MD5): F1:6A:22:18:C9:CD:DF:CE:82:1D:1D:B7:78:5C:A9:A5 -# Fingerprint (SHA1): 79:98:A3:08:E1:4D:65:85:E6:C2:1E:15:3A:71:9F:BA:5A:D3:4A:D9 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TURKTRUST Certificate Services Provider Root 1" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\171\230\243\010\341\115\145\205\346\302\036\025\072\161\237\272 -\132\323\112\331 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\361\152\042\030\311\315\337\316\202\035\035\267\170\134\251\245 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\267\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\014\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\116\113\101 -\122\101\061\126\060\124\006\003\125\004\012\014\115\050\143\051 -\040\062\060\060\065\040\124\303\234\122\113\124\122\125\123\124 -\040\102\151\154\147\151\040\304\260\154\145\164\151\305\237\151 -\155\040\166\145\040\102\151\154\151\305\237\151\155\040\107\303 -\274\166\145\156\154\151\304\237\151\040\110\151\172\155\145\164 -\154\145\162\151\040\101\056\305\236\056 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "TURKTRUST Certificate Services Provider Root 2" -# -# Issuer: O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A...,L=Ankara,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Serial Number: 1 (0x1) -# Subject: O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A...,L=Ankara,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Not Valid Before: Mon Nov 07 10:07:57 2005 -# Not Valid After : Wed Sep 16 10:07:57 2015 -# Fingerprint (MD5): 37:A5:6E:D4:B1:25:84:97:B7:FD:56:15:7A:F9:A2:00 -# Fingerprint (SHA1): B4:35:D4:E1:11:9D:1C:66:90:A7:49:EB:B3:94:BD:63:7B:A7:82:B7 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TURKTRUST Certificate Services Provider Root 2" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\276\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\023\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141 -\162\141\061\135\060\133\006\003\125\004\012\014\124\124\303\234 -\122\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260 -\154\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151 -\305\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151 -\040\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236 -\056\040\050\143\051\040\113\141\163\304\261\155\040\062\060\060 -\065 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\276\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\023\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141 -\162\141\061\135\060\133\006\003\125\004\012\014\124\124\303\234 -\122\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260 -\154\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151 -\305\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151 -\040\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236 -\056\040\050\143\051\040\113\141\163\304\261\155\040\062\060\060 -\065 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\074\060\202\003\044\240\003\002\001\002\002\001\001 -\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060 -\201\276\061\077\060\075\006\003\125\004\003\014\066\124\303\234 -\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157\156 -\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151\172 -\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304\261 -\163\304\261\061\013\060\011\006\003\125\004\006\023\002\124\122 -\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 -\141\061\135\060\133\006\003\125\004\012\014\124\124\303\234\122 -\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 -\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 -\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 -\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 -\040\050\143\051\040\113\141\163\304\261\155\040\062\060\060\065 -\060\036\027\015\060\065\061\061\060\067\061\060\060\067\065\067 -\132\027\015\061\065\060\071\061\066\061\060\060\067\065\067\132 -\060\201\276\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\023\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141 -\162\141\061\135\060\133\006\003\125\004\012\014\124\124\303\234 -\122\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260 -\154\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151 -\305\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151 -\040\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236 -\056\040\050\143\051\040\113\141\163\304\261\155\040\062\060\060 -\065\060\202\001\042\060\015\006\011\052\206\110\206\367\015\001 -\001\001\005\000\003\202\001\017\000\060\202\001\012\002\202\001 -\001\000\251\066\176\303\221\103\114\303\031\230\010\310\307\130 -\173\117\026\214\245\316\111\001\037\163\016\254\165\023\246\372 -\236\054\040\336\330\220\016\012\321\151\322\047\373\252\167\237 -\047\122\045\342\313\135\330\330\203\120\027\175\212\265\202\077 -\004\216\264\325\360\111\247\144\267\036\056\137\040\234\120\165 -\117\257\341\265\101\024\364\230\222\210\307\345\345\144\107\141 -\107\171\375\300\121\361\301\231\347\334\316\152\373\257\265\001 -\060\334\106\034\357\212\354\225\357\334\377\257\020\034\353\235 -\330\260\252\152\205\030\015\027\311\076\277\361\233\320\011\211 -\102\375\240\102\264\235\211\121\125\051\317\033\160\274\204\124 -\255\301\023\037\230\364\056\166\140\213\135\077\232\255\312\014 -\277\247\126\133\217\167\270\325\236\171\111\222\077\340\361\227 -\044\172\154\233\027\017\155\357\123\230\221\053\344\017\276\131 -\171\007\170\273\227\225\364\237\151\324\130\207\012\251\343\314 -\266\130\031\237\046\041\261\304\131\215\262\101\165\300\255\151 -\316\234\000\010\362\066\377\076\360\241\017\032\254\024\375\246 -\140\017\002\003\001\000\001\243\103\060\101\060\035\006\003\125 -\035\016\004\026\004\024\331\067\263\116\005\375\331\317\237\022 -\026\256\266\211\057\353\045\072\210\034\060\017\006\003\125\035 -\017\001\001\377\004\005\003\003\007\006\000\060\017\006\003\125 -\035\023\001\001\377\004\005\060\003\001\001\377\060\015\006\011 -\052\206\110\206\367\015\001\001\005\005\000\003\202\001\001\000 -\162\140\226\267\311\334\330\051\136\043\205\137\262\263\055\166 -\373\210\327\027\376\173\155\105\270\366\205\154\237\042\374\052 -\020\042\354\252\271\060\366\253\130\326\071\020\061\231\051\000 -\275\211\146\101\373\164\336\221\301\030\013\237\265\141\313\235 -\072\276\365\250\224\243\042\125\156\027\111\377\322\051\361\070 -\046\135\357\245\252\072\371\161\173\346\332\130\035\323\164\302 -\001\372\076\151\130\137\255\313\150\276\024\056\233\154\300\266 -\334\240\046\372\167\032\342\044\332\032\067\340\147\255\321\163 -\203\015\245\032\035\156\022\222\176\204\142\000\027\275\274\045 -\030\127\362\327\251\157\131\210\274\064\267\056\205\170\235\226 -\334\024\303\054\212\122\233\226\214\122\146\075\206\026\213\107 -\270\121\011\214\352\175\315\210\162\263\140\063\261\360\012\104 -\357\017\365\011\067\210\044\016\054\153\040\072\242\372\021\362 -\100\065\234\104\150\143\073\254\063\157\143\274\054\273\362\322 -\313\166\175\175\210\330\035\310\005\035\156\274\224\251\146\214 -\167\161\307\372\221\372\057\121\236\351\071\122\266\347\004\102 -END - -# Trust for Certificate "TURKTRUST Certificate Services Provider Root 2" -# Issuer: O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A...,L=Ankara,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Serial Number: 1 (0x1) -# Subject: O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A...,L=Ankara,C=TR,CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. -# Not Valid Before: Mon Nov 07 10:07:57 2005 -# Not Valid After : Wed Sep 16 10:07:57 2015 -# Fingerprint (MD5): 37:A5:6E:D4:B1:25:84:97:B7:FD:56:15:7A:F9:A2:00 -# Fingerprint (SHA1): B4:35:D4:E1:11:9D:1C:66:90:A7:49:EB:B3:94:BD:63:7B:A7:82:B7 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TURKTRUST Certificate Services Provider Root 2" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\264\065\324\341\021\235\034\146\220\247\111\353\263\224\275\143 -\173\247\202\267 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\067\245\156\324\261\045\204\227\267\375\126\025\172\371\242\000 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\276\061\077\060\075\006\003\125\004\003\014\066\124\303 -\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162\157 -\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110\151 -\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143\304 -\261\163\304\261\061\013\060\011\006\003\125\004\006\023\002\124 -\122\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141 -\162\141\061\135\060\133\006\003\125\004\012\014\124\124\303\234 -\122\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260 -\154\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151 -\305\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151 -\040\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236 -\056\040\050\143\051\040\113\141\163\304\261\155\040\062\060\060 -\065 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "SwissSign Platinum CA - G2" -# -# Issuer: CN=SwissSign Platinum CA - G2,O=SwissSign AG,C=CH -# Serial Number:4e:b2:00:67:0c:03:5d:4f -# Subject: CN=SwissSign Platinum CA - G2,O=SwissSign AG,C=CH -# Not Valid Before: Wed Oct 25 08:36:00 2006 -# Not Valid After : Sat Oct 25 08:36:00 2036 -# Fingerprint (MD5): C9:98:27:77:28:1E:3D:0E:15:3C:84:00:B8:85:03:E6 -# Fingerprint (SHA1): 56:E0:FA:C0:3B:8F:18:23:55:18:E5:D3:11:CA:E8:C2:43:31:AB:66 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "SwissSign Platinum CA - G2" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\111\061\013\060\011\006\003\125\004\006\023\002\103\110\061 -\025\060\023\006\003\125\004\012\023\014\123\167\151\163\163\123 -\151\147\156\040\101\107\061\043\060\041\006\003\125\004\003\023 -\032\123\167\151\163\163\123\151\147\156\040\120\154\141\164\151 -\156\165\155\040\103\101\040\055\040\107\062 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\111\061\013\060\011\006\003\125\004\006\023\002\103\110\061 -\025\060\023\006\003\125\004\012\023\014\123\167\151\163\163\123 -\151\147\156\040\101\107\061\043\060\041\006\003\125\004\003\023 -\032\123\167\151\163\163\123\151\147\156\040\120\154\141\164\151 -\156\165\155\040\103\101\040\055\040\107\062 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\010\116\262\000\147\014\003\135\117 +\002\010\116\262\000\147\014\003\135\117 END CKA_VALUE MULTILINE_OCTAL \060\202\005\301\060\202\003\251\240\003\002\001\002\002\010\116 @@ -12867,162 +10635,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "TC TrustCenter Class 2 CA II" -# -# Issuer: CN=TC TrustCenter Class 2 CA II,OU=TC TrustCenter Class 2 CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:2e:6a:00:01:00:02:1f:d7:52:21:2c:11:5c:3b -# Subject: CN=TC TrustCenter Class 2 CA II,OU=TC TrustCenter Class 2 CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Thu Jan 12 14:38:43 2006 -# Not Valid After : Wed Dec 31 22:59:59 2025 -# Fingerprint (MD5): CE:78:33:5C:59:78:01:6E:18:EA:B9:36:A0:B9:2E:23 -# Fingerprint (SHA1): AE:50:83:ED:7C:F4:5C:BC:8F:61:C6:21:FE:68:5D:79:42:21:15:6E -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Class 2 CA II" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\166\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\042\060 -\040\006\003\125\004\013\023\031\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\103\154\141\163\163\040\062\040\103 -\101\061\045\060\043\006\003\125\004\003\023\034\124\103\040\124 -\162\165\163\164\103\145\156\164\145\162\040\103\154\141\163\163 -\040\062\040\103\101\040\111\111 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\166\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\042\060 -\040\006\003\125\004\013\023\031\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\103\154\141\163\163\040\062\040\103 -\101\061\045\060\043\006\003\125\004\003\023\034\124\103\040\124 -\162\165\163\164\103\145\156\164\145\162\040\103\154\141\163\163 -\040\062\040\103\101\040\111\111 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\056\152\000\001\000\002\037\327\122\041\054\021\134\073 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\252\060\202\003\222\240\003\002\001\002\002\016\056 -\152\000\001\000\002\037\327\122\041\054\021\134\073\060\015\006 -\011\052\206\110\206\367\015\001\001\005\005\000\060\166\061\013 -\060\011\006\003\125\004\006\023\002\104\105\061\034\060\032\006 -\003\125\004\012\023\023\124\103\040\124\162\165\163\164\103\145 -\156\164\145\162\040\107\155\142\110\061\042\060\040\006\003\125 -\004\013\023\031\124\103\040\124\162\165\163\164\103\145\156\164 -\145\162\040\103\154\141\163\163\040\062\040\103\101\061\045\060 -\043\006\003\125\004\003\023\034\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\103\154\141\163\163\040\062\040\103 -\101\040\111\111\060\036\027\015\060\066\060\061\061\062\061\064 -\063\070\064\063\132\027\015\062\065\061\062\063\061\062\062\065 -\071\065\071\132\060\166\061\013\060\011\006\003\125\004\006\023 -\002\104\105\061\034\060\032\006\003\125\004\012\023\023\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\107\155\142 -\110\061\042\060\040\006\003\125\004\013\023\031\124\103\040\124 -\162\165\163\164\103\145\156\164\145\162\040\103\154\141\163\163 -\040\062\040\103\101\061\045\060\043\006\003\125\004\003\023\034 -\124\103\040\124\162\165\163\164\103\145\156\164\145\162\040\103 -\154\141\163\163\040\062\040\103\101\040\111\111\060\202\001\042 -\060\015\006\011\052\206\110\206\367\015\001\001\001\005\000\003 -\202\001\017\000\060\202\001\012\002\202\001\001\000\253\200\207 -\233\216\360\303\174\207\327\350\044\202\021\263\074\335\103\142 -\356\370\303\105\332\350\341\240\137\321\052\262\352\223\150\337 -\264\310\326\103\351\304\165\131\177\374\341\035\370\061\160\043 -\033\210\236\047\271\173\375\072\322\311\251\351\024\057\220\276 -\003\122\301\111\315\366\375\344\010\146\013\127\212\242\102\240 -\270\325\177\151\134\220\062\262\227\015\312\112\334\106\076\002 -\125\211\123\343\032\132\313\066\306\007\126\367\214\317\021\364 -\114\273\060\160\004\225\245\366\071\214\375\163\201\010\175\211 -\136\062\036\042\251\042\105\113\260\146\056\060\314\237\145\375 -\374\313\201\251\361\340\073\257\243\206\321\211\352\304\105\171 -\120\135\256\351\041\164\222\115\213\131\202\217\224\343\351\112 -\361\347\111\260\024\343\365\142\313\325\162\275\037\271\322\237 -\240\315\250\372\001\310\331\015\337\332\374\107\235\263\310\124 -\337\111\112\361\041\251\376\030\116\356\110\324\031\273\357\175 -\344\342\235\313\133\266\156\377\343\315\132\347\164\202\005\272 -\200\045\070\313\344\151\236\257\101\252\032\204\365\002\003\001 -\000\001\243\202\001\064\060\202\001\060\060\017\006\003\125\035 -\023\001\001\377\004\005\060\003\001\001\377\060\016\006\003\125 -\035\017\001\001\377\004\004\003\002\001\006\060\035\006\003\125 -\035\016\004\026\004\024\343\253\124\114\200\241\333\126\103\267 -\221\112\313\363\202\172\023\134\010\253\060\201\355\006\003\125 -\035\037\004\201\345\060\201\342\060\201\337\240\201\334\240\201 -\331\206\065\150\164\164\160\072\057\057\167\167\167\056\164\162 -\165\163\164\143\145\156\164\145\162\056\144\145\057\143\162\154 -\057\166\062\057\164\143\137\143\154\141\163\163\137\062\137\143 -\141\137\111\111\056\143\162\154\206\201\237\154\144\141\160\072 -\057\057\167\167\167\056\164\162\165\163\164\143\145\156\164\145 -\162\056\144\145\057\103\116\075\124\103\045\062\060\124\162\165 -\163\164\103\145\156\164\145\162\045\062\060\103\154\141\163\163 -\045\062\060\062\045\062\060\103\101\045\062\060\111\111\054\117 -\075\124\103\045\062\060\124\162\165\163\164\103\145\156\164\145 -\162\045\062\060\107\155\142\110\054\117\125\075\162\157\157\164 -\143\145\162\164\163\054\104\103\075\164\162\165\163\164\143\145 -\156\164\145\162\054\104\103\075\144\145\077\143\145\162\164\151 -\146\151\143\141\164\145\122\145\166\157\143\141\164\151\157\156 -\114\151\163\164\077\142\141\163\145\077\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\003\202\001\001\000\214\327 -\337\176\356\033\200\020\263\203\365\333\021\352\153\113\250\222 -\030\331\367\007\071\365\054\276\006\165\172\150\123\025\034\352 -\112\355\136\374\043\262\023\240\323\011\377\366\366\056\153\101 -\161\171\315\342\155\375\256\131\153\205\035\270\116\042\232\355 -\146\071\156\113\224\346\125\374\013\033\213\167\301\123\023\146 -\211\331\050\326\213\363\105\112\143\267\375\173\013\141\135\270 -\155\276\303\334\133\171\322\355\206\345\242\115\276\136\164\174 -\152\355\026\070\037\177\130\201\132\032\353\062\210\055\262\363 -\071\167\200\257\136\266\141\165\051\333\043\115\210\312\120\050 -\313\205\322\323\020\242\131\156\323\223\124\000\172\242\106\225 -\206\005\234\251\031\230\345\061\162\014\000\342\147\331\100\340 -\044\063\173\157\054\271\134\253\145\235\054\254\166\352\065\231 -\365\227\271\017\044\354\307\166\041\050\145\256\127\350\007\210 -\165\112\126\240\322\005\072\244\346\215\222\210\054\363\362\341 -\301\306\141\333\101\305\307\233\367\016\032\121\105\302\141\153 -\334\144\047\027\214\132\267\332\164\050\315\227\344\275 -END - -# Trust for Certificate "TC TrustCenter Class 2 CA II" -# Issuer: CN=TC TrustCenter Class 2 CA II,OU=TC TrustCenter Class 2 CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:2e:6a:00:01:00:02:1f:d7:52:21:2c:11:5c:3b -# Subject: CN=TC TrustCenter Class 2 CA II,OU=TC TrustCenter Class 2 CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Thu Jan 12 14:38:43 2006 -# Not Valid After : Wed Dec 31 22:59:59 2025 -# Fingerprint (MD5): CE:78:33:5C:59:78:01:6E:18:EA:B9:36:A0:B9:2E:23 -# Fingerprint (SHA1): AE:50:83:ED:7C:F4:5C:BC:8F:61:C6:21:FE:68:5D:79:42:21:15:6E -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Class 2 CA II" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\256\120\203\355\174\364\134\274\217\141\306\041\376\150\135\171 -\102\041\025\156 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\316\170\063\134\131\170\001\156\030\352\271\066\240\271\056\043 -END -CKA_ISSUER MULTILINE_OCTAL -\060\166\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\042\060 -\040\006\003\125\004\013\023\031\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\103\154\141\163\163\040\062\040\103 -\101\061\045\060\043\006\003\125\004\003\023\034\124\103\040\124 -\162\165\163\164\103\145\156\164\145\162\040\103\154\141\163\163 -\040\062\040\103\101\040\111\111 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\056\152\000\001\000\002\037\327\122\041\054\021\134\073 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "TC TrustCenter Class 3 CA II" # @@ -13180,188 +10792,44 @@ CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # -# Certificate "TC TrustCenter Universal CA I" +# Certificate "Deutsche Telekom Root CA 2" # -# Issuer: CN=TC TrustCenter Universal CA I,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:1d:a2:00:01:00:02:ec:b7:60:80:78:8d:b6:06 -# Subject: CN=TC TrustCenter Universal CA I,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Wed Mar 22 15:54:28 2006 -# Not Valid After : Wed Dec 31 22:59:59 2025 -# Fingerprint (MD5): 45:E1:A5:72:C5:A9:36:64:40:9E:F5:E4:58:84:67:8C -# Fingerprint (SHA1): 6B:2F:34:AD:89:58:BE:62:FD:B0:6B:5C:CE:BB:9D:D9:4F:4E:39:F3 +# Issuer: CN=Deutsche Telekom Root CA 2,OU=T-TeleSec Trust Center,O=Deutsche Telekom AG,C=DE +# Serial Number: 38 (0x26) +# Subject: CN=Deutsche Telekom Root CA 2,OU=T-TeleSec Trust Center,O=Deutsche Telekom AG,C=DE +# Not Valid Before: Fri Jul 09 12:11:00 1999 +# Not Valid After : Tue Jul 09 23:59:00 2019 +# Fingerprint (MD5): 74:01:4A:91:B1:08:C4:58:CE:47:CD:F0:DD:11:53:08 +# Fingerprint (SHA1): 85:A4:08:C0:9C:19:3E:5D:51:58:7D:CD:D6:13:30:FD:8C:DE:37:BF CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE CKA_TOKEN CK_BBOOL CK_TRUE CKA_PRIVATE CK_BBOOL CK_FALSE CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Universal CA I" +CKA_LABEL UTF8 "Deutsche Telekom Root CA 2" CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 CKA_SUBJECT MULTILINE_OCTAL -\060\171\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\046\060\044\006\003\125\004\003\023\035\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111 +\060\161\061\013\060\011\006\003\125\004\006\023\002\104\105\061 +\034\060\032\006\003\125\004\012\023\023\104\145\165\164\163\143 +\150\145\040\124\145\154\145\153\157\155\040\101\107\061\037\060 +\035\006\003\125\004\013\023\026\124\055\124\145\154\145\123\145 +\143\040\124\162\165\163\164\040\103\145\156\164\145\162\061\043 +\060\041\006\003\125\004\003\023\032\104\145\165\164\163\143\150 +\145\040\124\145\154\145\153\157\155\040\122\157\157\164\040\103 +\101\040\062 END CKA_ID UTF8 "0" CKA_ISSUER MULTILINE_OCTAL -\060\171\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\046\060\044\006\003\125\004\003\023\035\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111 +\060\161\061\013\060\011\006\003\125\004\006\023\002\104\105\061 +\034\060\032\006\003\125\004\012\023\023\104\145\165\164\163\143 +\150\145\040\124\145\154\145\153\157\155\040\101\107\061\037\060 +\035\006\003\125\004\013\023\026\124\055\124\145\154\145\123\145 +\143\040\124\162\165\163\164\040\103\145\156\164\145\162\061\043 +\060\041\006\003\125\004\003\023\032\104\145\165\164\163\143\150 +\145\040\124\145\154\145\153\157\155\040\122\157\157\164\040\103 +\101\040\062 END CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\035\242\000\001\000\002\354\267\140\200\170\215\266\006 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\335\060\202\002\305\240\003\002\001\002\002\016\035 -\242\000\001\000\002\354\267\140\200\170\215\266\006\060\015\006 -\011\052\206\110\206\367\015\001\001\005\005\000\060\171\061\013 -\060\011\006\003\125\004\006\023\002\104\105\061\034\060\032\006 -\003\125\004\012\023\023\124\103\040\124\162\165\163\164\103\145 -\156\164\145\162\040\107\155\142\110\061\044\060\042\006\003\125 -\004\013\023\033\124\103\040\124\162\165\163\164\103\145\156\164 -\145\162\040\125\156\151\166\145\162\163\141\154\040\103\101\061 -\046\060\044\006\003\125\004\003\023\035\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\125\156\151\166\145\162\163 -\141\154\040\103\101\040\111\060\036\027\015\060\066\060\063\062 -\062\061\065\065\064\062\070\132\027\015\062\065\061\062\063\061 -\062\062\065\071\065\071\132\060\171\061\013\060\011\006\003\125 -\004\006\023\002\104\105\061\034\060\032\006\003\125\004\012\023 -\023\124\103\040\124\162\165\163\164\103\145\156\164\145\162\040 -\107\155\142\110\061\044\060\042\006\003\125\004\013\023\033\124 -\103\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156 -\151\166\145\162\163\141\154\040\103\101\061\046\060\044\006\003 -\125\004\003\023\035\124\103\040\124\162\165\163\164\103\145\156 -\164\145\162\040\125\156\151\166\145\162\163\141\154\040\103\101 -\040\111\060\202\001\042\060\015\006\011\052\206\110\206\367\015 -\001\001\001\005\000\003\202\001\017\000\060\202\001\012\002\202 -\001\001\000\244\167\043\226\104\257\220\364\061\247\020\364\046 -\207\234\363\070\331\017\136\336\317\101\350\061\255\306\164\221 -\044\226\170\036\011\240\233\232\225\112\112\365\142\174\002\250 -\312\254\373\132\004\166\071\336\137\361\371\263\277\363\003\130 -\125\322\252\267\343\004\042\321\370\224\332\042\010\000\215\323 -\174\046\135\314\167\171\347\054\170\071\250\046\163\016\242\135 -\045\151\205\117\125\016\232\357\306\271\104\341\127\075\337\037 -\124\042\345\157\145\252\063\204\072\363\316\172\276\125\227\256 -\215\022\017\024\063\342\120\160\303\111\207\023\274\121\336\327 -\230\022\132\357\072\203\063\222\006\165\213\222\174\022\150\173 -\160\152\017\265\233\266\167\133\110\131\235\344\357\132\255\363 -\301\236\324\327\105\116\312\126\064\041\274\076\027\133\157\167 -\014\110\001\103\051\260\335\077\226\156\346\225\252\014\300\040 -\266\375\076\066\047\234\343\134\317\116\201\334\031\273\221\220 -\175\354\346\227\004\036\223\314\042\111\327\227\206\266\023\012 -\074\103\043\167\176\360\334\346\315\044\037\073\203\233\064\072 -\203\064\343\002\003\001\000\001\243\143\060\141\060\037\006\003 -\125\035\043\004\030\060\026\200\024\222\244\165\054\244\236\276 -\201\104\353\171\374\212\305\225\245\353\020\165\163\060\017\006 -\003\125\035\023\001\001\377\004\005\060\003\001\001\377\060\016 -\006\003\125\035\017\001\001\377\004\004\003\002\001\206\060\035 -\006\003\125\035\016\004\026\004\024\222\244\165\054\244\236\276 -\201\104\353\171\374\212\305\225\245\353\020\165\163\060\015\006 -\011\052\206\110\206\367\015\001\001\005\005\000\003\202\001\001 -\000\050\322\340\206\325\346\370\173\360\227\334\042\153\073\225 -\024\126\017\021\060\245\232\117\072\260\072\340\006\313\145\365 -\355\306\227\047\376\045\362\127\346\136\225\214\076\144\140\025 -\132\177\057\015\001\305\261\140\375\105\065\317\360\262\277\006 -\331\357\132\276\263\142\041\264\327\253\065\174\123\076\246\047 -\361\241\055\332\032\043\235\314\335\354\074\055\236\047\064\135 -\017\302\066\171\274\311\112\142\055\355\153\331\175\101\103\174 -\266\252\312\355\141\261\067\202\025\011\032\212\026\060\330\354 -\311\326\107\162\170\113\020\106\024\216\137\016\257\354\307\057 -\253\020\327\266\361\156\354\206\262\302\350\015\222\163\334\242 -\364\017\072\277\141\043\020\211\234\110\100\156\160\000\263\323 -\272\067\104\130\021\172\002\152\210\360\067\064\360\031\351\254 -\324\145\163\366\151\214\144\224\072\171\205\051\260\026\053\014 -\202\077\006\234\307\375\020\053\236\017\054\266\236\343\025\277 -\331\066\034\272\045\032\122\075\032\354\042\014\034\340\244\242 -\075\360\350\071\317\201\300\173\355\135\037\157\305\320\013\327 -\230 -END - -# Trust for Certificate "TC TrustCenter Universal CA I" -# Issuer: CN=TC TrustCenter Universal CA I,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:1d:a2:00:01:00:02:ec:b7:60:80:78:8d:b6:06 -# Subject: CN=TC TrustCenter Universal CA I,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Wed Mar 22 15:54:28 2006 -# Not Valid After : Wed Dec 31 22:59:59 2025 -# Fingerprint (MD5): 45:E1:A5:72:C5:A9:36:64:40:9E:F5:E4:58:84:67:8C -# Fingerprint (SHA1): 6B:2F:34:AD:89:58:BE:62:FD:B0:6B:5C:CE:BB:9D:D9:4F:4E:39:F3 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Universal CA I" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\153\057\064\255\211\130\276\142\375\260\153\134\316\273\235\331 -\117\116\071\363 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\105\341\245\162\305\251\066\144\100\236\365\344\130\204\147\214 -END -CKA_ISSUER MULTILINE_OCTAL -\060\171\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\046\060\044\006\003\125\004\003\023\035\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\035\242\000\001\000\002\354\267\140\200\170\215\266\006 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "Deutsche Telekom Root CA 2" -# -# Issuer: CN=Deutsche Telekom Root CA 2,OU=T-TeleSec Trust Center,O=Deutsche Telekom AG,C=DE -# Serial Number: 38 (0x26) -# Subject: CN=Deutsche Telekom Root CA 2,OU=T-TeleSec Trust Center,O=Deutsche Telekom AG,C=DE -# Not Valid Before: Fri Jul 09 12:11:00 1999 -# Not Valid After : Tue Jul 09 23:59:00 2019 -# Fingerprint (MD5): 74:01:4A:91:B1:08:C4:58:CE:47:CD:F0:DD:11:53:08 -# Fingerprint (SHA1): 85:A4:08:C0:9C:19:3E:5D:51:58:7D:CD:D6:13:30:FD:8C:DE:37:BF -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Deutsche Telekom Root CA 2" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\161\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\104\145\165\164\163\143 -\150\145\040\124\145\154\145\153\157\155\040\101\107\061\037\060 -\035\006\003\125\004\013\023\026\124\055\124\145\154\145\123\145 -\143\040\124\162\165\163\164\040\103\145\156\164\145\162\061\043 -\060\041\006\003\125\004\003\023\032\104\145\165\164\163\143\150 -\145\040\124\145\154\145\153\157\155\040\122\157\157\164\040\103 -\101\040\062 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\161\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\104\145\165\164\163\143 -\150\145\040\124\145\154\145\153\157\155\040\101\107\061\037\060 -\035\006\003\125\004\013\023\026\124\055\124\145\154\145\123\145 -\143\040\124\162\165\163\164\040\103\145\156\164\145\162\061\043 -\060\041\006\003\125\004\003\023\032\104\145\165\164\163\143\150 -\145\040\124\145\154\145\153\157\155\040\122\157\157\164\040\103 -\101\040\062 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\046 +\002\001\046 END CKA_VALUE MULTILINE_OCTAL \060\202\003\237\060\202\002\207\240\003\002\001\002\002\001\046 @@ -13717,7 +11185,7 @@ CKA_SERIAL_NUMBER MULTILINE_OCTAL \002\021\000\307\050\107\011\263\270\154\105\214\035\372\044\365 \066\116\351 END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE @@ -14341,132 +11809,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "Buypass Class 3 CA 1" -# -# Issuer: CN=Buypass Class 3 CA 1,O=Buypass AS-983163327,C=NO -# Serial Number: 2 (0x2) -# Subject: CN=Buypass Class 3 CA 1,O=Buypass AS-983163327,C=NO -# Not Valid Before: Mon May 09 14:13:03 2005 -# Not Valid After : Sat May 09 14:13:03 2015 -# Fingerprint (MD5): DF:3C:73:59:81:E7:39:50:81:04:4C:34:A2:CB:B3:7B -# Fingerprint (SHA1): 61:57:3A:11:DF:0E:D8:7E:D5:92:65:22:EA:D0:56:D7:44:B3:23:71 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Buypass Class 3 CA 1" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\113\061\013\060\011\006\003\125\004\006\023\002\116\117\061 -\035\060\033\006\003\125\004\012\014\024\102\165\171\160\141\163 -\163\040\101\123\055\071\070\063\061\066\063\063\062\067\061\035 -\060\033\006\003\125\004\003\014\024\102\165\171\160\141\163\163 -\040\103\154\141\163\163\040\063\040\103\101\040\061 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\113\061\013\060\011\006\003\125\004\006\023\002\116\117\061 -\035\060\033\006\003\125\004\012\014\024\102\165\171\160\141\163 -\163\040\101\123\055\071\070\063\061\066\063\063\062\067\061\035 -\060\033\006\003\125\004\003\014\024\102\165\171\160\141\163\163 -\040\103\154\141\163\163\040\063\040\103\101\040\061 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\002 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\123\060\202\002\073\240\003\002\001\002\002\001\002 -\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060 -\113\061\013\060\011\006\003\125\004\006\023\002\116\117\061\035 -\060\033\006\003\125\004\012\014\024\102\165\171\160\141\163\163 -\040\101\123\055\071\070\063\061\066\063\063\062\067\061\035\060 -\033\006\003\125\004\003\014\024\102\165\171\160\141\163\163\040 -\103\154\141\163\163\040\063\040\103\101\040\061\060\036\027\015 -\060\065\060\065\060\071\061\064\061\063\060\063\132\027\015\061 -\065\060\065\060\071\061\064\061\063\060\063\132\060\113\061\013 -\060\011\006\003\125\004\006\023\002\116\117\061\035\060\033\006 -\003\125\004\012\014\024\102\165\171\160\141\163\163\040\101\123 -\055\071\070\063\061\066\063\063\062\067\061\035\060\033\006\003 -\125\004\003\014\024\102\165\171\160\141\163\163\040\103\154\141 -\163\163\040\063\040\103\101\040\061\060\202\001\042\060\015\006 -\011\052\206\110\206\367\015\001\001\001\005\000\003\202\001\017 -\000\060\202\001\012\002\202\001\001\000\244\216\327\164\331\051 -\144\336\137\037\207\200\221\352\116\071\346\031\306\104\013\200 -\325\013\257\123\007\213\022\275\346\147\360\002\261\211\366\140 -\212\304\133\260\102\321\300\041\250\313\341\233\357\144\121\266 -\247\317\025\365\164\200\150\004\220\240\130\242\346\164\246\123 -\123\125\110\143\077\222\126\335\044\116\216\370\272\053\377\363 -\064\212\236\050\327\064\237\254\057\326\017\361\244\057\275\122 -\262\111\205\155\071\065\360\104\060\223\106\044\363\266\347\123 -\373\274\141\257\251\243\024\373\302\027\027\204\154\340\174\210 -\370\311\034\127\054\360\075\176\224\274\045\223\204\350\232\000 -\232\105\005\102\127\200\364\116\316\331\256\071\366\310\123\020 -\014\145\072\107\173\140\302\326\372\221\311\306\161\154\275\221 -\207\074\221\206\111\253\363\017\240\154\046\166\136\034\254\233 -\161\345\215\274\233\041\036\234\326\070\176\044\200\025\061\202 -\226\261\111\323\142\067\133\210\014\012\142\064\376\247\110\176 -\231\261\060\213\220\067\225\034\250\037\245\054\215\364\125\310 -\333\335\131\012\302\255\170\240\364\213\002\003\001\000\001\243 -\102\060\100\060\017\006\003\125\035\023\001\001\377\004\005\060 -\003\001\001\377\060\035\006\003\125\035\016\004\026\004\024\070 -\024\346\310\360\251\244\003\364\116\076\042\243\133\362\326\340 -\255\100\164\060\016\006\003\125\035\017\001\001\377\004\004\003 -\002\001\006\060\015\006\011\052\206\110\206\367\015\001\001\005 -\005\000\003\202\001\001\000\001\147\243\214\311\045\075\023\143 -\135\026\157\354\241\076\011\134\221\025\052\052\331\200\041\117 -\005\334\273\245\211\253\023\063\052\236\070\267\214\157\002\162 -\143\307\163\167\036\011\006\272\073\050\173\244\107\311\141\153 -\010\010\040\374\212\005\212\037\274\272\306\302\376\317\156\354 -\023\063\161\147\056\151\372\251\054\077\146\300\022\131\115\013 -\124\002\222\204\273\333\022\357\203\160\160\170\310\123\372\337 -\306\306\377\334\210\057\007\300\111\235\062\127\140\323\362\366 -\231\051\137\347\252\001\314\254\063\250\034\012\273\221\304\003 -\240\157\266\064\371\206\323\263\166\124\230\364\112\201\263\123 -\235\115\100\354\345\167\023\105\257\133\252\037\330\057\114\202 -\173\376\052\304\130\273\117\374\236\375\003\145\032\052\016\303 -\245\040\026\224\153\171\246\242\022\264\273\032\244\043\172\137 -\360\256\204\044\344\363\053\373\212\044\243\047\230\145\332\060 -\165\166\374\031\221\350\333\353\233\077\062\277\100\227\007\046 -\272\314\363\224\205\112\172\047\223\317\220\102\324\270\133\026 -\246\347\313\100\003\335\171 -END - -# Trust for Certificate "Buypass Class 3 CA 1" -# Issuer: CN=Buypass Class 3 CA 1,O=Buypass AS-983163327,C=NO -# Serial Number: 2 (0x2) -# Subject: CN=Buypass Class 3 CA 1,O=Buypass AS-983163327,C=NO -# Not Valid Before: Mon May 09 14:13:03 2005 -# Not Valid After : Sat May 09 14:13:03 2015 -# Fingerprint (MD5): DF:3C:73:59:81:E7:39:50:81:04:4C:34:A2:CB:B3:7B -# Fingerprint (SHA1): 61:57:3A:11:DF:0E:D8:7E:D5:92:65:22:EA:D0:56:D7:44:B3:23:71 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Buypass Class 3 CA 1" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\141\127\072\021\337\016\330\176\325\222\145\042\352\320\126\327 -\104\263\043\161 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\337\074\163\131\201\347\071\120\201\004\114\064\242\313\263\173 -END -CKA_ISSUER MULTILINE_OCTAL -\060\113\061\013\060\011\006\003\125\004\006\023\002\116\117\061 -\035\060\033\006\003\125\004\012\014\024\102\165\171\160\141\163 -\163\040\101\123\055\071\070\063\061\066\063\063\062\067\061\035 -\060\033\006\003\125\004\003\014\024\102\165\171\160\141\163\163 -\040\103\154\141\163\163\040\063\040\103\101\040\061 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\002 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "EBG Elektronik Sertifika Hizmet Saglayicisi" # @@ -16247,144 +13589,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "CA Disig" -# -# Issuer: CN=CA Disig,O=Disig a.s.,L=Bratislava,C=SK -# Serial Number: 1 (0x1) -# Subject: CN=CA Disig,O=Disig a.s.,L=Bratislava,C=SK -# Not Valid Before: Wed Mar 22 01:39:34 2006 -# Not Valid After : Tue Mar 22 01:39:34 2016 -# Fingerprint (MD5): 3F:45:96:39:E2:50:87:F7:BB:FE:98:0C:3C:20:98:E6 -# Fingerprint (SHA1): 2A:C8:D5:8B:57:CE:BF:2F:49:AF:F2:FC:76:8F:51:14:62:90:7A:41 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "CA Disig" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\112\061\013\060\011\006\003\125\004\006\023\002\123\113\061 -\023\060\021\006\003\125\004\007\023\012\102\162\141\164\151\163 -\154\141\166\141\061\023\060\021\006\003\125\004\012\023\012\104 -\151\163\151\147\040\141\056\163\056\061\021\060\017\006\003\125 -\004\003\023\010\103\101\040\104\151\163\151\147 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\112\061\013\060\011\006\003\125\004\006\023\002\123\113\061 -\023\060\021\006\003\125\004\007\023\012\102\162\141\164\151\163 -\154\141\166\141\061\023\060\021\006\003\125\004\012\023\012\104 -\151\163\151\147\040\141\056\163\056\061\021\060\017\006\003\125 -\004\003\023\010\103\101\040\104\151\163\151\147 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\017\060\202\002\367\240\003\002\001\002\002\001\001 -\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060 -\112\061\013\060\011\006\003\125\004\006\023\002\123\113\061\023 -\060\021\006\003\125\004\007\023\012\102\162\141\164\151\163\154 -\141\166\141\061\023\060\021\006\003\125\004\012\023\012\104\151 -\163\151\147\040\141\056\163\056\061\021\060\017\006\003\125\004 -\003\023\010\103\101\040\104\151\163\151\147\060\036\027\015\060 -\066\060\063\062\062\060\061\063\071\063\064\132\027\015\061\066 -\060\063\062\062\060\061\063\071\063\064\132\060\112\061\013\060 -\011\006\003\125\004\006\023\002\123\113\061\023\060\021\006\003 -\125\004\007\023\012\102\162\141\164\151\163\154\141\166\141\061 -\023\060\021\006\003\125\004\012\023\012\104\151\163\151\147\040 -\141\056\163\056\061\021\060\017\006\003\125\004\003\023\010\103 -\101\040\104\151\163\151\147\060\202\001\042\060\015\006\011\052 -\206\110\206\367\015\001\001\001\005\000\003\202\001\017\000\060 -\202\001\012\002\202\001\001\000\222\366\061\301\175\210\375\231 -\001\251\330\173\362\161\165\361\061\306\363\165\146\372\121\050 -\106\204\227\170\064\274\154\374\274\105\131\210\046\030\112\304 -\067\037\241\112\104\275\343\161\004\365\104\027\342\077\374\110 -\130\157\134\236\172\011\272\121\067\042\043\146\103\041\260\074 -\144\242\370\152\025\016\077\353\121\341\124\251\335\006\231\327 -\232\074\124\213\071\003\077\017\305\316\306\353\203\162\002\250 -\037\161\363\055\370\165\010\333\142\114\350\372\316\371\347\152 -\037\266\153\065\202\272\342\217\026\222\175\005\014\154\106\003 -\135\300\355\151\277\072\301\212\240\350\216\331\271\105\050\207 -\010\354\264\312\025\276\202\335\265\104\213\055\255\206\014\150 -\142\155\205\126\362\254\024\143\072\306\321\231\254\064\170\126 -\113\317\266\255\077\214\212\327\004\345\343\170\114\365\206\252 -\365\217\372\075\154\161\243\055\312\147\353\150\173\156\063\251 -\014\202\050\250\114\152\041\100\025\040\014\046\133\203\302\251 -\026\025\300\044\202\135\053\026\255\312\143\366\164\000\260\337 -\103\304\020\140\126\147\143\105\002\003\001\000\001\243\201\377 -\060\201\374\060\017\006\003\125\035\023\001\001\377\004\005\060 -\003\001\001\377\060\035\006\003\125\035\016\004\026\004\024\215 -\262\111\150\235\162\010\045\271\300\047\365\120\223\126\110\106 -\161\371\217\060\016\006\003\125\035\017\001\001\377\004\004\003 -\002\001\006\060\066\006\003\125\035\021\004\057\060\055\201\023 -\143\141\157\160\145\162\141\164\157\162\100\144\151\163\151\147 -\056\163\153\206\026\150\164\164\160\072\057\057\167\167\167\056 -\144\151\163\151\147\056\163\153\057\143\141\060\146\006\003\125 -\035\037\004\137\060\135\060\055\240\053\240\051\206\047\150\164 -\164\160\072\057\057\167\167\167\056\144\151\163\151\147\056\163 -\153\057\143\141\057\143\162\154\057\143\141\137\144\151\163\151 -\147\056\143\162\154\060\054\240\052\240\050\206\046\150\164\164 -\160\072\057\057\143\141\056\144\151\163\151\147\056\163\153\057 -\143\141\057\143\162\154\057\143\141\137\144\151\163\151\147\056 -\143\162\154\060\032\006\003\125\035\040\004\023\060\021\060\017 -\006\015\053\201\036\221\223\346\012\000\000\000\001\001\001\060 -\015\006\011\052\206\110\206\367\015\001\001\005\005\000\003\202 -\001\001\000\135\064\164\141\114\257\073\330\377\237\155\130\066 -\034\075\013\201\015\022\053\106\020\200\375\347\074\047\320\172 -\310\251\266\176\164\060\063\243\072\212\173\164\300\171\171\102 -\223\155\377\261\051\024\202\253\041\214\057\027\371\077\046\057 -\365\131\306\357\200\006\267\232\111\051\354\316\176\161\074\152 -\020\101\300\366\323\232\262\174\132\221\234\300\254\133\310\115 -\136\367\341\123\377\103\167\374\236\113\147\154\327\363\203\321 -\240\340\177\045\337\270\230\013\232\062\070\154\060\240\363\377 -\010\025\063\367\120\112\173\076\243\076\040\251\334\057\126\200 -\012\355\101\120\260\311\364\354\262\343\046\104\000\016\157\236 -\006\274\042\226\123\160\145\304\120\012\106\153\244\057\047\201 -\022\047\023\137\020\241\166\316\212\173\067\352\303\071\141\003 -\225\230\072\347\154\210\045\010\374\171\150\015\207\175\142\370 -\264\137\373\305\330\114\275\130\274\077\103\133\324\036\001\115 -\074\143\276\043\357\214\315\132\120\270\150\124\371\012\231\063 -\021\000\341\236\302\106\167\202\365\131\006\214\041\114\207\011 -\315\345\250 -END - -# Trust for Certificate "CA Disig" -# Issuer: CN=CA Disig,O=Disig a.s.,L=Bratislava,C=SK -# Serial Number: 1 (0x1) -# Subject: CN=CA Disig,O=Disig a.s.,L=Bratislava,C=SK -# Not Valid Before: Wed Mar 22 01:39:34 2006 -# Not Valid After : Tue Mar 22 01:39:34 2016 -# Fingerprint (MD5): 3F:45:96:39:E2:50:87:F7:BB:FE:98:0C:3C:20:98:E6 -# Fingerprint (SHA1): 2A:C8:D5:8B:57:CE:BF:2F:49:AF:F2:FC:76:8F:51:14:62:90:7A:41 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "CA Disig" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\052\310\325\213\127\316\277\057\111\257\362\374\166\217\121\024 -\142\220\172\101 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\077\105\226\071\342\120\207\367\273\376\230\014\074\040\230\346 -END -CKA_ISSUER MULTILINE_OCTAL -\060\112\061\013\060\011\006\003\125\004\006\023\002\123\113\061 -\023\060\021\006\003\125\004\007\023\012\102\162\141\164\151\163 -\154\141\166\141\061\023\060\021\006\003\125\004\012\023\012\104 -\151\163\151\147\040\141\056\163\056\061\021\060\017\006\003\125 -\004\003\023\010\103\101\040\104\151\163\151\147 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\001\001 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "Juur-SK" # @@ -17076,162 +14280,46 @@ CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE # -# Certificate "Verisign Class 3 Public Primary Certification Authority" +# Certificate "Microsec e-Szigno Root CA 2009" # -# Issuer: OU=Class 3 Public Primary Certification Authority,O="VeriSign, Inc.",C=US -# Serial Number:3c:91:31:cb:1f:f6:d0:1b:0e:9a:b8:d0:44:bf:12:be -# Subject: OU=Class 3 Public Primary Certification Authority,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon Jan 29 00:00:00 1996 -# Not Valid After : Wed Aug 02 23:59:59 2028 -# Fingerprint (MD5): EF:5A:F1:33:EF:F1:CD:BB:51:02:EE:12:14:4B:96:C4 -# Fingerprint (SHA1): A1:DB:63:93:91:6F:17:E4:18:55:09:40:04:15:C7:02:40:B0:AE:6B +# Issuer: E=info@e-szigno.hu,CN=Microsec e-Szigno Root CA 2009,O=Microsec Ltd.,L=Budapest,C=HU +# Serial Number:00:c2:7e:43:04:4e:47:3f:19 +# Subject: E=info@e-szigno.hu,CN=Microsec e-Szigno Root CA 2009,O=Microsec Ltd.,L=Budapest,C=HU +# Not Valid Before: Tue Jun 16 11:30:18 2009 +# Not Valid After : Sun Dec 30 11:30:18 2029 +# Fingerprint (MD5): F8:49:F4:03:BC:44:2D:83:BE:48:69:7D:29:64:FC:B1 +# Fingerprint (SHA1): 89:DF:74:FE:5C:F4:0F:4A:80:F9:E3:37:7D:54:DA:91:E1:01:31:8E CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE CKA_TOKEN CK_BBOOL CK_TRUE CKA_PRIVATE CK_BBOOL CK_FALSE CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 3 Public Primary Certification Authority" +CKA_LABEL UTF8 "Microsec e-Szigno Root CA 2009" CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 CKA_SUBJECT MULTILINE_OCTAL -\060\137\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123\151 -\147\156\054\040\111\156\143\056\061\067\060\065\006\003\125\004 -\013\023\056\103\154\141\163\163\040\063\040\120\165\142\154\151 -\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151\146 -\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151\164 -\171 +\060\201\202\061\013\060\011\006\003\125\004\006\023\002\110\125 +\061\021\060\017\006\003\125\004\007\014\010\102\165\144\141\160 +\145\163\164\061\026\060\024\006\003\125\004\012\014\015\115\151 +\143\162\157\163\145\143\040\114\164\144\056\061\047\060\045\006 +\003\125\004\003\014\036\115\151\143\162\157\163\145\143\040\145 +\055\123\172\151\147\156\157\040\122\157\157\164\040\103\101\040 +\062\060\060\071\061\037\060\035\006\011\052\206\110\206\367\015 +\001\011\001\026\020\151\156\146\157\100\145\055\163\172\151\147 +\156\157\056\150\165 END CKA_ID UTF8 "0" CKA_ISSUER MULTILINE_OCTAL -\060\137\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123\151 -\147\156\054\040\111\156\143\056\061\067\060\065\006\003\125\004 -\013\023\056\103\154\141\163\163\040\063\040\120\165\142\154\151 -\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151\146 -\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151\164 -\171 +\060\201\202\061\013\060\011\006\003\125\004\006\023\002\110\125 +\061\021\060\017\006\003\125\004\007\014\010\102\165\144\141\160 +\145\163\164\061\026\060\024\006\003\125\004\012\014\015\115\151 +\143\162\157\163\145\143\040\114\164\144\056\061\047\060\045\006 +\003\125\004\003\014\036\115\151\143\162\157\163\145\143\040\145 +\055\123\172\151\147\156\157\040\122\157\157\164\040\103\101\040 +\062\060\060\071\061\037\060\035\006\011\052\206\110\206\367\015 +\001\011\001\026\020\151\156\146\157\100\145\055\163\172\151\147 +\156\157\056\150\165 END CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\074\221\061\313\037\366\320\033\016\232\270\320\104\277 -\022\276 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\002\074\060\202\001\245\002\020\074\221\061\313\037\366 -\320\033\016\232\270\320\104\277\022\276\060\015\006\011\052\206 -\110\206\367\015\001\001\005\005\000\060\137\061\013\060\011\006 -\003\125\004\006\023\002\125\123\061\027\060\025\006\003\125\004 -\012\023\016\126\145\162\151\123\151\147\156\054\040\111\156\143 -\056\061\067\060\065\006\003\125\004\013\023\056\103\154\141\163 -\163\040\063\040\120\165\142\154\151\143\040\120\162\151\155\141 -\162\171\040\103\145\162\164\151\146\151\143\141\164\151\157\156 -\040\101\165\164\150\157\162\151\164\171\060\036\027\015\071\066 -\060\061\062\071\060\060\060\060\060\060\132\027\015\062\070\060 -\070\060\062\062\063\065\071\065\071\132\060\137\061\013\060\011 -\006\003\125\004\006\023\002\125\123\061\027\060\025\006\003\125 -\004\012\023\016\126\145\162\151\123\151\147\156\054\040\111\156 -\143\056\061\067\060\065\006\003\125\004\013\023\056\103\154\141 -\163\163\040\063\040\120\165\142\154\151\143\040\120\162\151\155 -\141\162\171\040\103\145\162\164\151\146\151\143\141\164\151\157 -\156\040\101\165\164\150\157\162\151\164\171\060\201\237\060\015 -\006\011\052\206\110\206\367\015\001\001\001\005\000\003\201\215 -\000\060\201\211\002\201\201\000\311\134\131\236\362\033\212\001 -\024\264\020\337\004\100\333\343\127\257\152\105\100\217\204\014 -\013\321\063\331\331\021\317\356\002\130\037\045\367\052\250\104 -\005\252\354\003\037\170\177\236\223\271\232\000\252\043\175\326 -\254\205\242\143\105\307\162\047\314\364\114\306\165\161\322\071 -\357\117\102\360\165\337\012\220\306\216\040\157\230\017\370\254 -\043\137\160\051\066\244\311\206\347\261\232\040\313\123\245\205 -\347\075\276\175\232\376\044\105\063\334\166\025\355\017\242\161 -\144\114\145\056\201\150\105\247\002\003\001\000\001\060\015\006 -\011\052\206\110\206\367\015\001\001\005\005\000\003\201\201\000 -\020\162\122\251\005\024\031\062\010\101\360\305\153\012\314\176 -\017\041\031\315\344\147\334\137\251\033\346\312\350\163\235\042 -\330\230\156\163\003\141\221\305\174\260\105\100\156\104\235\215 -\260\261\226\164\141\055\015\251\105\322\244\222\052\326\232\165 -\227\156\077\123\375\105\231\140\035\250\053\114\371\136\247\011 -\330\165\060\327\322\145\140\075\147\326\110\125\165\151\077\221 -\365\110\013\107\151\042\151\202\226\276\311\310\070\206\112\172 -\054\163\031\110\151\116\153\174\145\277\017\374\160\316\210\220 -END - -# Trust for Certificate "Verisign Class 3 Public Primary Certification Authority" -# Issuer: OU=Class 3 Public Primary Certification Authority,O="VeriSign, Inc.",C=US -# Serial Number:3c:91:31:cb:1f:f6:d0:1b:0e:9a:b8:d0:44:bf:12:be -# Subject: OU=Class 3 Public Primary Certification Authority,O="VeriSign, Inc.",C=US -# Not Valid Before: Mon Jan 29 00:00:00 1996 -# Not Valid After : Wed Aug 02 23:59:59 2028 -# Fingerprint (MD5): EF:5A:F1:33:EF:F1:CD:BB:51:02:EE:12:14:4B:96:C4 -# Fingerprint (SHA1): A1:DB:63:93:91:6F:17:E4:18:55:09:40:04:15:C7:02:40:B0:AE:6B -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Verisign Class 3 Public Primary Certification Authority" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\241\333\143\223\221\157\027\344\030\125\011\100\004\025\307\002 -\100\260\256\153 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\357\132\361\063\357\361\315\273\121\002\356\022\024\113\226\304 -END -CKA_ISSUER MULTILINE_OCTAL -\060\137\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\027\060\025\006\003\125\004\012\023\016\126\145\162\151\123\151 -\147\156\054\040\111\156\143\056\061\067\060\065\006\003\125\004 -\013\023\056\103\154\141\163\163\040\063\040\120\165\142\154\151 -\143\040\120\162\151\155\141\162\171\040\103\145\162\164\151\146 -\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151\164 -\171 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\074\221\061\313\037\366\320\033\016\232\270\320\104\277 -\022\276 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - -# -# Certificate "Microsec e-Szigno Root CA 2009" -# -# Issuer: E=info@e-szigno.hu,CN=Microsec e-Szigno Root CA 2009,O=Microsec Ltd.,L=Budapest,C=HU -# Serial Number:00:c2:7e:43:04:4e:47:3f:19 -# Subject: E=info@e-szigno.hu,CN=Microsec e-Szigno Root CA 2009,O=Microsec Ltd.,L=Budapest,C=HU -# Not Valid Before: Tue Jun 16 11:30:18 2009 -# Not Valid After : Sun Dec 30 11:30:18 2029 -# Fingerprint (MD5): F8:49:F4:03:BC:44:2D:83:BE:48:69:7D:29:64:FC:B1 -# Fingerprint (SHA1): 89:DF:74:FE:5C:F4:0F:4A:80:F9:E3:37:7D:54:DA:91:E1:01:31:8E -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "Microsec e-Szigno Root CA 2009" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\202\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\014\010\102\165\144\141\160 -\145\163\164\061\026\060\024\006\003\125\004\012\014\015\115\151 -\143\162\157\163\145\143\040\114\164\144\056\061\047\060\045\006 -\003\125\004\003\014\036\115\151\143\162\157\163\145\143\040\145 -\055\123\172\151\147\156\157\040\122\157\157\164\040\103\101\040 -\062\060\060\071\061\037\060\035\006\011\052\206\110\206\367\015 -\001\011\001\026\020\151\156\146\157\100\145\055\163\172\151\147 -\156\157\056\150\165 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\202\061\013\060\011\006\003\125\004\006\023\002\110\125 -\061\021\060\017\006\003\125\004\007\014\010\102\165\144\141\160 -\145\163\164\061\026\060\024\006\003\125\004\012\014\015\115\151 -\143\162\157\163\145\143\040\114\164\144\056\061\047\060\045\006 -\003\125\004\003\014\036\115\151\143\162\157\163\145\143\040\145 -\055\123\172\151\147\156\157\040\122\157\157\164\040\103\101\040 -\062\060\060\071\061\037\060\035\006\011\052\206\110\206\367\015 -\001\011\001\026\020\151\156\146\157\100\145\055\163\172\151\147 -\156\157\056\150\165 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\011\000\302\176\103\004\116\107\077\031 +\002\011\000\302\176\103\004\116\107\077\031 END CKA_VALUE MULTILINE_OCTAL \060\202\004\012\060\202\002\362\240\003\002\001\002\002\011\000 @@ -17467,150 +14555,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "TC TrustCenter Universal CA III" -# -# Issuer: CN=TC TrustCenter Universal CA III,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:63:25:00:01:00:02:14:8d:33:15:02:e4:6c:f4 -# Subject: CN=TC TrustCenter Universal CA III,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Wed Sep 09 08:15:27 2009 -# Not Valid After : Mon Dec 31 23:59:59 2029 -# Fingerprint (MD5): 9F:DD:DB:AB:FF:8E:FF:45:21:5F:F0:6C:9D:8F:FE:2B -# Fingerprint (SHA1): 96:56:CD:7B:57:96:98:95:D0:E1:41:46:68:06:FB:B8:C6:11:06:87 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Universal CA III" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\173\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\050\060\046\006\003\125\004\003\023\037\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111\111\111 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\173\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\050\060\046\006\003\125\004\003\023\037\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111\111\111 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\143\045\000\001\000\002\024\215\063\025\002\344\154\364 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\341\060\202\002\311\240\003\002\001\002\002\016\143 -\045\000\001\000\002\024\215\063\025\002\344\154\364\060\015\006 -\011\052\206\110\206\367\015\001\001\005\005\000\060\173\061\013 -\060\011\006\003\125\004\006\023\002\104\105\061\034\060\032\006 -\003\125\004\012\023\023\124\103\040\124\162\165\163\164\103\145 -\156\164\145\162\040\107\155\142\110\061\044\060\042\006\003\125 -\004\013\023\033\124\103\040\124\162\165\163\164\103\145\156\164 -\145\162\040\125\156\151\166\145\162\163\141\154\040\103\101\061 -\050\060\046\006\003\125\004\003\023\037\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\125\156\151\166\145\162\163 -\141\154\040\103\101\040\111\111\111\060\036\027\015\060\071\060 -\071\060\071\060\070\061\065\062\067\132\027\015\062\071\061\062 -\063\061\062\063\065\071\065\071\132\060\173\061\013\060\011\006 -\003\125\004\006\023\002\104\105\061\034\060\032\006\003\125\004 -\012\023\023\124\103\040\124\162\165\163\164\103\145\156\164\145 -\162\040\107\155\142\110\061\044\060\042\006\003\125\004\013\023 -\033\124\103\040\124\162\165\163\164\103\145\156\164\145\162\040 -\125\156\151\166\145\162\163\141\154\040\103\101\061\050\060\046 -\006\003\125\004\003\023\037\124\103\040\124\162\165\163\164\103 -\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154\040 -\103\101\040\111\111\111\060\202\001\042\060\015\006\011\052\206 -\110\206\367\015\001\001\001\005\000\003\202\001\017\000\060\202 -\001\012\002\202\001\001\000\302\332\234\142\260\271\161\022\260 -\013\310\032\127\262\256\203\024\231\263\064\113\233\220\242\305 -\347\347\057\002\240\115\055\244\372\205\332\233\045\205\055\100 -\050\040\155\352\340\275\261\110\203\042\051\104\237\116\203\356 -\065\121\023\163\164\325\274\362\060\146\224\123\300\100\066\057 -\014\204\145\316\017\156\302\130\223\350\054\013\072\351\301\216 -\373\362\153\312\074\342\234\116\216\344\371\175\323\047\237\033 -\325\147\170\207\055\177\013\107\263\307\350\311\110\174\257\057 -\314\012\331\101\357\237\376\232\341\262\256\371\123\265\345\351 -\106\237\140\343\337\215\323\177\373\226\176\263\265\162\370\113 -\255\010\171\315\151\211\100\047\365\052\301\255\103\354\244\123 -\310\141\266\367\322\171\052\147\030\166\110\155\133\045\001\321 -\046\305\267\127\151\043\025\133\141\212\255\360\033\055\331\257 -\134\361\046\220\151\251\325\014\100\365\063\200\103\217\234\243 -\166\052\105\264\257\277\177\076\207\077\166\305\315\052\336\040 -\305\026\130\313\371\033\365\017\313\015\021\122\144\270\322\166 -\142\167\203\361\130\237\377\002\003\001\000\001\243\143\060\141 -\060\037\006\003\125\035\043\004\030\060\026\200\024\126\347\341 -\133\045\103\200\340\366\214\341\161\274\216\345\200\057\304\110 -\342\060\017\006\003\125\035\023\001\001\377\004\005\060\003\001 -\001\377\060\016\006\003\125\035\017\001\001\377\004\004\003\002 -\001\006\060\035\006\003\125\035\016\004\026\004\024\126\347\341 -\133\045\103\200\340\366\214\341\161\274\216\345\200\057\304\110 -\342\060\015\006\011\052\206\110\206\367\015\001\001\005\005\000 -\003\202\001\001\000\203\307\257\352\177\115\012\074\071\261\150 -\276\173\155\211\056\351\263\011\347\030\127\215\205\232\027\363 -\166\102\120\023\017\307\220\157\063\255\305\111\140\053\154\111 -\130\031\324\342\276\267\277\253\111\274\224\310\253\276\050\154 -\026\150\340\310\227\106\040\240\150\147\140\210\071\040\121\330 -\150\001\021\316\247\366\021\007\366\354\354\254\032\037\262\146 -\156\126\147\140\172\164\136\300\155\227\066\256\265\015\135\146 -\163\300\045\062\105\330\112\006\007\217\304\267\007\261\115\006 -\015\341\245\353\364\165\312\272\234\320\275\263\323\062\044\114 -\356\176\342\166\004\113\111\123\330\362\351\124\063\374\345\161 -\037\075\024\134\226\113\361\072\362\000\273\154\264\372\226\125 -\010\210\011\301\314\221\031\051\260\040\055\377\313\070\244\100 -\341\027\276\171\141\200\377\007\003\206\114\116\173\006\237\021 -\206\215\211\356\047\304\333\342\274\031\216\013\303\303\023\307 -\055\003\143\073\323\350\344\242\052\302\202\010\224\026\124\360 -\357\037\047\220\045\270\015\016\050\033\107\167\107\275\034\250 -\045\361\224\264\146 -END - -# Trust for Certificate "TC TrustCenter Universal CA III" -# Issuer: CN=TC TrustCenter Universal CA III,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Serial Number:63:25:00:01:00:02:14:8d:33:15:02:e4:6c:f4 -# Subject: CN=TC TrustCenter Universal CA III,OU=TC TrustCenter Universal CA,O=TC TrustCenter GmbH,C=DE -# Not Valid Before: Wed Sep 09 08:15:27 2009 -# Not Valid After : Mon Dec 31 23:59:59 2029 -# Fingerprint (MD5): 9F:DD:DB:AB:FF:8E:FF:45:21:5F:F0:6C:9D:8F:FE:2B -# Fingerprint (SHA1): 96:56:CD:7B:57:96:98:95:D0:E1:41:46:68:06:FB:B8:C6:11:06:87 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "TC TrustCenter Universal CA III" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\226\126\315\173\127\226\230\225\320\341\101\106\150\006\373\270 -\306\021\006\207 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\237\335\333\253\377\216\377\105\041\137\360\154\235\217\376\053 -END -CKA_ISSUER MULTILINE_OCTAL -\060\173\061\013\060\011\006\003\125\004\006\023\002\104\105\061 -\034\060\032\006\003\125\004\012\023\023\124\103\040\124\162\165 -\163\164\103\145\156\164\145\162\040\107\155\142\110\061\044\060 -\042\006\003\125\004\013\023\033\124\103\040\124\162\165\163\164 -\103\145\156\164\145\162\040\125\156\151\166\145\162\163\141\154 -\040\103\101\061\050\060\046\006\003\125\004\003\023\037\124\103 -\040\124\162\165\163\164\103\145\156\164\145\162\040\125\156\151 -\166\145\162\163\141\154\040\103\101\040\111\111\111 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\016\143\045\000\001\000\002\024\215\063\025\002\344\154\364 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "Autoridad de Certificacion Firmaprofesional CIF A62634068" # @@ -21538,152 +18482,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "A-Trust-nQual-03" -# -# Issuer: CN=A-Trust-nQual-03,OU=A-Trust-nQual-03,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT -# Serial Number: 93214 (0x16c1e) -# Subject: CN=A-Trust-nQual-03,OU=A-Trust-nQual-03,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT -# Not Valid Before: Wed Aug 17 22:00:00 2005 -# Not Valid After : Mon Aug 17 22:00:00 2015 -# Fingerprint (MD5): 49:63:AE:27:F4:D5:95:3D:D8:DB:24:86:B8:9C:07:53 -# Fingerprint (SHA1): D3:C0:63:F2:19:ED:07:3E:34:AD:5D:75:0B:32:76:29:FF:D5:9A:F2 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "A-Trust-nQual-03" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\201\215\061\013\060\011\006\003\125\004\006\023\002\101\124 -\061\110\060\106\006\003\125\004\012\014\077\101\055\124\162\165 -\163\164\040\107\145\163\056\040\146\056\040\123\151\143\150\145 -\162\150\145\151\164\163\163\171\163\164\145\155\145\040\151\155 -\040\145\154\145\153\164\162\056\040\104\141\164\145\156\166\145 -\162\153\145\150\162\040\107\155\142\110\061\031\060\027\006\003 -\125\004\013\014\020\101\055\124\162\165\163\164\055\156\121\165 -\141\154\055\060\063\061\031\060\027\006\003\125\004\003\014\020 -\101\055\124\162\165\163\164\055\156\121\165\141\154\055\060\063 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\201\215\061\013\060\011\006\003\125\004\006\023\002\101\124 -\061\110\060\106\006\003\125\004\012\014\077\101\055\124\162\165 -\163\164\040\107\145\163\056\040\146\056\040\123\151\143\150\145 -\162\150\145\151\164\163\163\171\163\164\145\155\145\040\151\155 -\040\145\154\145\153\164\162\056\040\104\141\164\145\156\166\145 -\162\153\145\150\162\040\107\155\142\110\061\031\060\027\006\003 -\125\004\013\014\020\101\055\124\162\165\163\164\055\156\121\165 -\141\154\055\060\063\061\031\060\027\006\003\125\004\003\014\020 -\101\055\124\162\165\163\164\055\156\121\165\141\154\055\060\063 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\003\001\154\036 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\003\317\060\202\002\267\240\003\002\001\002\002\003\001 -\154\036\060\015\006\011\052\206\110\206\367\015\001\001\005\005 -\000\060\201\215\061\013\060\011\006\003\125\004\006\023\002\101 -\124\061\110\060\106\006\003\125\004\012\014\077\101\055\124\162 -\165\163\164\040\107\145\163\056\040\146\056\040\123\151\143\150 -\145\162\150\145\151\164\163\163\171\163\164\145\155\145\040\151 -\155\040\145\154\145\153\164\162\056\040\104\141\164\145\156\166 -\145\162\153\145\150\162\040\107\155\142\110\061\031\060\027\006 -\003\125\004\013\014\020\101\055\124\162\165\163\164\055\156\121 -\165\141\154\055\060\063\061\031\060\027\006\003\125\004\003\014 -\020\101\055\124\162\165\163\164\055\156\121\165\141\154\055\060 -\063\060\036\027\015\060\065\060\070\061\067\062\062\060\060\060 -\060\132\027\015\061\065\060\070\061\067\062\062\060\060\060\060 -\132\060\201\215\061\013\060\011\006\003\125\004\006\023\002\101 -\124\061\110\060\106\006\003\125\004\012\014\077\101\055\124\162 -\165\163\164\040\107\145\163\056\040\146\056\040\123\151\143\150 -\145\162\150\145\151\164\163\163\171\163\164\145\155\145\040\151 -\155\040\145\154\145\153\164\162\056\040\104\141\164\145\156\166 -\145\162\153\145\150\162\040\107\155\142\110\061\031\060\027\006 -\003\125\004\013\014\020\101\055\124\162\165\163\164\055\156\121 -\165\141\154\055\060\063\061\031\060\027\006\003\125\004\003\014 -\020\101\055\124\162\165\163\164\055\156\121\165\141\154\055\060 -\063\060\202\001\042\060\015\006\011\052\206\110\206\367\015\001 -\001\001\005\000\003\202\001\017\000\060\202\001\012\002\202\001 -\001\000\255\075\141\156\003\363\220\073\300\101\013\204\200\315 -\354\052\243\235\153\273\156\302\102\204\367\121\024\341\240\250 -\055\121\243\121\362\336\043\360\064\104\377\224\353\314\005\043 -\225\100\271\007\170\245\045\366\012\275\105\206\350\331\275\300 -\004\216\205\104\141\357\177\247\311\372\301\045\314\205\054\143 -\077\005\140\163\111\005\340\140\170\225\020\113\334\371\021\131 -\316\161\177\100\233\212\252\044\337\013\102\342\333\126\274\112 -\322\245\014\233\267\103\076\335\203\323\046\020\002\317\352\043 -\304\111\116\345\323\351\264\210\253\014\256\142\222\324\145\207 -\331\152\327\364\205\237\344\063\042\045\245\345\310\063\272\303 -\307\101\334\137\306\152\314\000\016\155\062\250\266\207\066\000 -\142\167\233\036\037\064\313\220\074\170\210\164\005\353\171\365 -\223\161\145\312\235\307\153\030\055\075\134\116\347\325\370\077 -\061\175\217\207\354\012\042\057\043\351\376\273\175\311\340\364 -\354\353\174\304\260\303\055\142\265\232\161\326\261\152\350\354 -\331\355\325\162\354\276\127\001\316\005\125\237\336\321\140\210 -\020\263\002\003\001\000\001\243\066\060\064\060\017\006\003\125 -\035\023\001\001\377\004\005\060\003\001\001\377\060\021\006\003 -\125\035\016\004\012\004\010\104\152\225\147\125\171\021\117\060 -\016\006\003\125\035\017\001\001\377\004\004\003\002\001\006\060 -\015\006\011\052\206\110\206\367\015\001\001\005\005\000\003\202 -\001\001\000\125\324\124\321\131\110\134\263\223\205\252\277\143 -\057\344\200\316\064\243\064\142\076\366\330\356\147\210\061\004 -\003\157\013\324\007\373\116\165\017\323\056\323\300\027\307\306 -\050\354\006\015\021\044\016\016\245\135\277\214\262\023\226\161 -\334\324\316\016\015\012\150\062\154\271\101\061\031\253\261\007 -\173\115\230\323\134\260\321\360\247\102\240\265\304\216\257\376 -\361\077\364\357\117\106\000\166\353\002\373\371\235\322\100\226 -\307\210\072\270\237\021\171\363\200\145\250\275\037\323\170\201 -\240\121\114\067\264\246\135\045\160\321\146\311\150\371\056\021 -\024\150\361\124\230\010\254\046\222\017\336\211\236\324\372\263 -\171\053\322\243\171\324\354\213\254\207\123\150\102\114\121\121 -\164\036\033\047\056\343\365\037\051\164\115\355\257\367\341\222 -\231\201\350\276\072\307\027\120\366\267\306\374\233\260\212\153 -\326\210\003\221\217\006\167\072\205\002\335\230\325\103\170\077 -\306\060\025\254\233\153\313\127\267\211\121\213\072\350\311\204 -\014\333\261\120\040\012\032\112\272\152\032\275\354\033\310\305 -\204\232\315 -END - -# Trust for Certificate "A-Trust-nQual-03" -# Issuer: CN=A-Trust-nQual-03,OU=A-Trust-nQual-03,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT -# Serial Number: 93214 (0x16c1e) -# Subject: CN=A-Trust-nQual-03,OU=A-Trust-nQual-03,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT -# Not Valid Before: Wed Aug 17 22:00:00 2005 -# Not Valid After : Mon Aug 17 22:00:00 2015 -# Fingerprint (MD5): 49:63:AE:27:F4:D5:95:3D:D8:DB:24:86:B8:9C:07:53 -# Fingerprint (SHA1): D3:C0:63:F2:19:ED:07:3E:34:AD:5D:75:0B:32:76:29:FF:D5:9A:F2 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "A-Trust-nQual-03" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\323\300\143\362\031\355\007\076\064\255\135\165\013\062\166\051 -\377\325\232\362 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\111\143\256\047\364\325\225\075\330\333\044\206\270\234\007\123 -END -CKA_ISSUER MULTILINE_OCTAL -\060\201\215\061\013\060\011\006\003\125\004\006\023\002\101\124 -\061\110\060\106\006\003\125\004\012\014\077\101\055\124\162\165 -\163\164\040\107\145\163\056\040\146\056\040\123\151\143\150\145 -\162\150\145\151\164\163\163\171\163\164\145\155\145\040\151\155 -\040\145\154\145\153\164\162\056\040\104\141\164\145\156\166\145 -\162\153\145\150\162\040\107\155\142\110\061\031\060\027\006\003 -\125\004\013\014\020\101\055\124\162\165\163\164\055\156\121\165 -\141\154\055\060\063\061\031\060\027\006\003\125\004\003\014\020 -\101\055\124\162\165\163\164\055\156\121\165\141\154\055\060\063 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\003\001\154\036 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "TWCA Root Certification Authority" # @@ -23783,7 +20581,7 @@ CKA_SERIAL_NUMBER MULTILINE_OCTAL \002\010\127\012\021\227\102\304\343\314 END CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE @@ -26489,182 +23287,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "SG TRUST SERVICES RACINE" -# -# Issuer: C=FR,O=SG TRUST SERVICES,OU=0002 43525289500022,CN=SG TRUST SERVICES RACINE -# Serial Number:3e:d5:51:19:e6:4d:ce:7e -# Subject: C=FR,O=SG TRUST SERVICES,OU=0002 43525289500022,CN=SG TRUST SERVICES RACINE -# Not Valid Before: Mon Sep 06 12:53:42 2010 -# Not Valid After : Thu Sep 05 12:53:42 2030 -# Fingerprint (MD5): 25:EF:CF:48:4A:84:B7:30:9F:60:D3:1D:56:91:2F:E1 -# Fingerprint (SHA1): 0C:62:8F:5C:55:70:B1:C9:57:FA:FD:38:3F:B0:3D:7B:7D:D7:B9:C6 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "SG TRUST SERVICES RACINE" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\152\061\041\060\037\006\003\125\004\003\023\030\123\107\040 -\124\122\125\123\124\040\123\105\122\126\111\103\105\123\040\122 -\101\103\111\116\105\061\034\060\032\006\003\125\004\013\023\023 -\060\060\060\062\040\064\063\065\062\065\062\070\071\065\060\060 -\060\062\062\061\032\060\030\006\003\125\004\012\023\021\123\107 -\040\124\122\125\123\124\040\123\105\122\126\111\103\105\123\061 -\013\060\011\006\003\125\004\006\023\002\106\122 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\152\061\041\060\037\006\003\125\004\003\023\030\123\107\040 -\124\122\125\123\124\040\123\105\122\126\111\103\105\123\040\122 -\101\103\111\116\105\061\034\060\032\006\003\125\004\013\023\023 -\060\060\060\062\040\064\063\065\062\065\062\070\071\065\060\060 -\060\062\062\061\032\060\030\006\003\125\004\012\023\021\123\107 -\040\124\122\125\123\124\040\123\105\122\126\111\103\105\123\061 -\013\060\011\006\003\125\004\006\023\002\106\122 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\010\076\325\121\031\346\115\316\176 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\006\031\060\202\004\001\240\003\002\001\002\002\010\076 -\325\121\031\346\115\316\176\060\015\006\011\052\206\110\206\367 -\015\001\001\013\005\000\060\152\061\041\060\037\006\003\125\004 -\003\023\030\123\107\040\124\122\125\123\124\040\123\105\122\126 -\111\103\105\123\040\122\101\103\111\116\105\061\034\060\032\006 -\003\125\004\013\023\023\060\060\060\062\040\064\063\065\062\065 -\062\070\071\065\060\060\060\062\062\061\032\060\030\006\003\125 -\004\012\023\021\123\107\040\124\122\125\123\124\040\123\105\122 -\126\111\103\105\123\061\013\060\011\006\003\125\004\006\023\002 -\106\122\060\036\027\015\061\060\060\071\060\066\061\062\065\063 -\064\062\132\027\015\063\060\060\071\060\065\061\062\065\063\064 -\062\132\060\152\061\041\060\037\006\003\125\004\003\023\030\123 -\107\040\124\122\125\123\124\040\123\105\122\126\111\103\105\123 -\040\122\101\103\111\116\105\061\034\060\032\006\003\125\004\013 -\023\023\060\060\060\062\040\064\063\065\062\065\062\070\071\065 -\060\060\060\062\062\061\032\060\030\006\003\125\004\012\023\021 -\123\107\040\124\122\125\123\124\040\123\105\122\126\111\103\105 -\123\061\013\060\011\006\003\125\004\006\023\002\106\122\060\202 -\002\042\060\015\006\011\052\206\110\206\367\015\001\001\001\005 -\000\003\202\002\017\000\060\202\002\012\002\202\002\001\000\332 -\250\126\002\354\174\225\360\116\351\012\322\267\007\243\042\213 -\120\263\271\056\031\075\127\333\031\252\322\053\344\316\102\342 -\154\241\344\135\045\036\063\035\266\105\321\264\372\131\212\126 -\160\311\155\010\166\151\160\232\346\307\234\010\060\023\376\346 -\321\222\150\141\076\114\021\362\156\362\261\173\127\126\113\011 -\275\334\017\331\161\014\350\232\067\336\042\020\034\231\136\326 -\261\027\007\323\244\071\055\302\032\163\375\312\113\051\007\302 -\171\051\310\310\046\256\054\304\374\043\310\113\342\206\126\017 -\050\375\266\207\033\150\137\071\144\105\375\150\203\154\165\044 -\036\074\165\231\141\372\322\024\370\251\113\261\330\175\247\170 -\322\023\142\145\265\326\276\176\152\003\274\265\262\374\144\060 -\303\320\302\231\075\231\244\323\315\321\261\304\123\207\173\114 -\023\023\146\177\277\325\145\123\150\371\134\036\345\264\377\066 -\231\105\243\237\142\300\177\021\202\001\124\336\017\145\245\071 -\256\235\110\114\211\243\020\073\340\346\203\365\260\332\054\036 -\172\034\134\037\000\254\314\253\247\140\144\263\306\305\173\307 -\125\106\164\074\220\201\016\112\216\131\235\124\260\110\261\122 -\114\073\230\356\253\332\064\267\123\315\111\332\057\353\225\276 -\014\127\021\366\226\114\004\171\134\231\325\345\344\276\157\352 -\107\356\121\113\357\042\046\256\265\330\021\252\103\273\170\277 -\013\176\264\335\317\164\035\045\251\211\143\261\342\064\201\304 -\210\065\070\342\002\015\017\023\311\325\052\202\025\360\212\304 -\103\062\126\344\123\035\035\254\266\317\175\233\226\135\036\144 -\351\164\163\304\126\344\026\112\122\155\222\071\323\341\115\016 -\077\142\271\336\255\265\035\145\271\135\122\376\135\011\251\234 -\264\244\014\331\057\105\166\245\317\216\152\232\236\252\260\021 -\241\353\141\306\353\077\036\374\146\264\022\235\106\177\062\026 -\211\276\161\105\257\221\041\331\375\223\277\264\002\221\102\377 -\111\037\355\213\025\150\335\037\216\254\233\335\202\005\234\104 -\151\026\144\027\126\137\101\017\112\117\004\017\145\120\206\223 -\227\354\105\277\135\302\034\334\317\304\330\072\346\170\005\320 -\305\125\125\251\136\376\253\072\041\273\345\162\024\367\013\002 -\003\001\000\001\243\201\302\060\201\277\060\035\006\003\125\035 -\016\004\026\004\024\051\040\313\361\303\017\332\006\216\023\223 -\207\376\137\140\032\051\273\363\266\060\017\006\003\125\035\023 -\001\001\377\004\005\060\003\001\001\377\060\037\006\003\125\035 -\043\004\030\060\026\200\024\051\040\313\361\303\017\332\006\216 -\023\223\207\376\137\140\032\051\273\363\266\060\021\006\003\125 -\035\040\004\012\060\010\060\006\006\004\125\035\040\000\060\111 -\006\003\125\035\037\004\102\060\100\060\076\240\074\240\072\206 -\070\150\164\164\160\072\057\057\143\162\154\056\163\147\164\162 -\165\163\164\163\145\162\166\151\143\145\163\056\143\157\155\057 -\162\141\143\151\156\145\055\107\162\157\165\160\145\123\107\057 -\114\141\164\145\163\164\103\122\114\060\016\006\003\125\035\017 -\001\001\377\004\004\003\002\001\006\060\015\006\011\052\206\110 -\206\367\015\001\001\013\005\000\003\202\002\001\000\114\106\147 -\340\104\120\365\305\266\272\262\121\012\045\023\035\267\307\210 -\056\037\271\053\144\240\313\223\210\122\131\252\140\365\314\051 -\122\027\377\004\347\067\264\061\021\106\176\053\036\154\247\213 -\074\107\232\136\364\252\135\220\073\105\075\237\112\311\212\173 -\216\300\356\076\171\213\222\243\310\224\112\270\050\021\153\246 -\045\137\135\275\307\310\373\203\117\125\061\346\134\360\023\174 -\343\275\177\052\054\067\067\224\111\257\204\037\024\047\242\130 -\020\217\012\071\067\032\022\040\101\217\031\366\251\037\031\355 -\262\064\262\255\175\063\104\213\137\012\007\103\362\166\105\105 -\055\255\344\215\016\000\375\004\010\252\347\153\373\027\275\260 -\010\126\016\065\052\162\360\263\347\115\072\117\015\334\363\140 -\022\263\070\144\214\333\371\341\046\215\057\357\116\350\044\107 -\076\066\064\212\151\017\050\153\213\207\306\275\205\046\371\323 -\353\151\041\126\140\221\326\367\340\142\302\250\161\256\056\336 -\146\043\265\122\106\246\244\110\067\054\177\001\026\127\021\367 -\047\015\016\345\017\326\220\105\341\036\077\041\334\322\374\026 -\030\023\076\115\152\262\046\152\100\136\045\170\375\070\364\254 -\130\172\067\033\230\100\004\307\216\311\324\304\147\141\261\230 -\256\360\315\016\334\271\257\145\203\173\012\004\212\077\141\252 -\367\135\101\206\346\306\114\302\117\072\134\126\352\050\073\247 -\104\317\310\112\144\365\162\140\055\343\103\270\112\340\165\074 -\062\344\252\026\327\021\271\301\105\331\233\146\143\146\345\042 -\267\064\356\272\325\164\057\045\144\363\201\124\313\167\336\127 -\324\223\343\254\007\061\072\076\134\003\203\127\123\307\360\376 -\150\330\045\120\115\022\310\346\341\225\215\147\253\074\223\077 -\027\002\272\070\327\236\367\060\245\075\075\104\001\063\032\232 -\237\216\320\237\361\356\060\210\163\357\256\044\031\272\227\163 -\025\301\354\161\014\204\144\265\173\354\274\151\076\244\155\011 -\026\066\312\112\071\212\313\247\173\306\035\176\347\063\210\311 -\276\060\155\234\205\225\041\351\107\073\006\176\201\342\352\106 -\346\160\130\200\346\250\362\235\013\151\321\063\211\131\060\363 -\144\323\013\366\316\053\011\373\175\020\166\056\020 -END - -# Trust for "SG TRUST SERVICES RACINE" -# Issuer: C=FR,O=SG TRUST SERVICES,OU=0002 43525289500022,CN=SG TRUST SERVICES RACINE -# Serial Number:3e:d5:51:19:e6:4d:ce:7e -# Subject: C=FR,O=SG TRUST SERVICES,OU=0002 43525289500022,CN=SG TRUST SERVICES RACINE -# Not Valid Before: Mon Sep 06 12:53:42 2010 -# Not Valid After : Thu Sep 05 12:53:42 2030 -# Fingerprint (MD5): 25:EF:CF:48:4A:84:B7:30:9F:60:D3:1D:56:91:2F:E1 -# Fingerprint (SHA1): 0C:62:8F:5C:55:70:B1:C9:57:FA:FD:38:3F:B0:3D:7B:7D:D7:B9:C6 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "SG TRUST SERVICES RACINE" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\014\142\217\134\125\160\261\311\127\372\375\070\077\260\075\173 -\175\327\271\306 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\045\357\317\110\112\204\267\060\237\140\323\035\126\221\057\341 -END -CKA_ISSUER MULTILINE_OCTAL -\060\152\061\041\060\037\006\003\125\004\003\023\030\123\107\040 -\124\122\125\123\124\040\123\105\122\126\111\103\105\123\040\122 -\101\103\111\116\105\061\034\060\032\006\003\125\004\013\023\023 -\060\060\060\062\040\064\063\065\062\065\062\070\071\065\060\060 -\060\062\062\061\032\060\030\006\003\125\004\012\023\021\123\107 -\040\124\122\125\123\124\040\123\105\122\126\111\103\105\123\061 -\013\060\011\006\003\125\004\006\023\002\106\122 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\010\076\325\121\031\346\115\316\176 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "ACCVRAIZ1" # @@ -29839,164 +26461,6 @@ CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE -# -# Certificate "USERTrust-temporary-intermediate-after-1024bit-removal" -# -# Issuer: CN=AddTrust External CA Root,OU=AddTrust External TTP Network,O=AddTrust AB,C=SE -# Serial Number:5d:20:61:8e:8c:0e:b9:34:40:93:b9:b1:d8:63:95:b6 -# Subject: CN=USERTrust Legacy Secure Server CA,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Tue Aug 05 00:00:00 2014 -# Not Valid After : Sun Nov 01 23:59:59 2015 -# Fingerprint (SHA-256): 92:96:6E:83:44:D2:FB:3A:28:0E:B8:60:4D:81:40:77:4C:E1:A0:57:C5:82:BE:BC:83:4D:03:02:E8:59:BC:43 -# Fingerprint (SHA1): 7C:2F:91:E2:BB:96:68:A9:C6:F6:BD:10:19:2C:6B:52:5A:1B:BA:48 -CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "USERTrust-temporary-intermediate-after-1024bit-removal" -CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 -CKA_SUBJECT MULTILINE_OCTAL -\060\177\061\013\060\011\006\003\125\004\006\023\002\125\123\061 -\013\060\011\006\003\125\004\010\023\002\125\124\061\027\060\025 -\006\003\125\004\007\023\016\123\141\154\164\040\114\141\153\145 -\040\103\151\164\171\061\036\060\034\006\003\125\004\012\023\025 -\124\150\145\040\125\123\105\122\124\122\125\123\124\040\116\145 -\164\167\157\162\153\061\052\060\050\006\003\125\004\003\023\041 -\125\123\105\122\124\162\165\163\164\040\114\145\147\141\143\171 -\040\123\145\143\165\162\145\040\123\145\162\166\145\162\040\103 -\101 -END -CKA_ID UTF8 "0" -CKA_ISSUER MULTILINE_OCTAL -\060\157\061\013\060\011\006\003\125\004\006\023\002\123\105\061 -\024\060\022\006\003\125\004\012\023\013\101\144\144\124\162\165 -\163\164\040\101\102\061\046\060\044\006\003\125\004\013\023\035 -\101\144\144\124\162\165\163\164\040\105\170\164\145\162\156\141 -\154\040\124\124\120\040\116\145\164\167\157\162\153\061\042\060 -\040\006\003\125\004\003\023\031\101\144\144\124\162\165\163\164 -\040\105\170\164\145\162\156\141\154\040\103\101\040\122\157\157 -\164 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\135\040\141\216\214\016\271\064\100\223\271\261\330\143 -\225\266 -END -CKA_VALUE MULTILINE_OCTAL -\060\202\004\231\060\202\003\201\240\003\002\001\002\002\020\135 -\040\141\216\214\016\271\064\100\223\271\261\330\143\225\266\060 -\015\006\011\052\206\110\206\367\015\001\001\005\005\000\060\157 -\061\013\060\011\006\003\125\004\006\023\002\123\105\061\024\060 -\022\006\003\125\004\012\023\013\101\144\144\124\162\165\163\164 -\040\101\102\061\046\060\044\006\003\125\004\013\023\035\101\144 -\144\124\162\165\163\164\040\105\170\164\145\162\156\141\154\040 -\124\124\120\040\116\145\164\167\157\162\153\061\042\060\040\006 -\003\125\004\003\023\031\101\144\144\124\162\165\163\164\040\105 -\170\164\145\162\156\141\154\040\103\101\040\122\157\157\164\060 -\036\027\015\061\064\060\070\060\065\060\060\060\060\060\060\132 -\027\015\061\065\061\061\060\061\062\063\065\071\065\071\132\060 -\177\061\013\060\011\006\003\125\004\006\023\002\125\123\061\013 -\060\011\006\003\125\004\010\023\002\125\124\061\027\060\025\006 -\003\125\004\007\023\016\123\141\154\164\040\114\141\153\145\040 -\103\151\164\171\061\036\060\034\006\003\125\004\012\023\025\124 -\150\145\040\125\123\105\122\124\122\125\123\124\040\116\145\164 -\167\157\162\153\061\052\060\050\006\003\125\004\003\023\041\125 -\123\105\122\124\162\165\163\164\040\114\145\147\141\143\171\040 -\123\145\143\165\162\145\040\123\145\162\166\145\162\040\103\101 -\060\202\001\042\060\015\006\011\052\206\110\206\367\015\001\001 -\001\005\000\003\202\001\017\000\060\202\001\012\002\202\001\001 -\000\331\115\040\072\346\051\060\206\362\351\206\211\166\064\116 -\150\037\226\104\367\321\371\326\202\116\246\070\236\356\313\133 -\341\216\056\275\362\127\200\375\311\077\374\220\163\104\274\217 -\273\127\133\345\055\037\024\060\165\066\365\177\274\317\126\364 -\177\201\377\256\221\315\330\322\152\313\227\371\367\315\220\152 -\105\055\304\273\244\205\023\150\127\137\357\051\272\052\312\352 -\365\314\244\004\233\143\315\000\353\375\355\215\335\043\306\173 -\036\127\035\066\177\037\010\232\015\141\333\132\154\161\002\123 -\050\302\372\215\375\253\273\263\361\215\164\113\337\275\275\314 -\006\223\143\011\225\302\020\172\235\045\220\062\235\001\302\071 -\123\260\340\025\153\307\327\164\345\244\042\233\344\224\377\204 -\221\373\055\263\031\103\055\223\017\234\022\011\344\147\271\047 -\172\062\255\172\052\314\101\130\300\156\131\137\356\070\053\027 -\042\234\211\372\156\347\345\127\065\364\132\355\222\225\223\055 -\371\314\044\077\245\034\075\047\275\042\003\163\314\365\312\363 -\251\364\334\376\317\351\320\134\320\017\253\207\374\203\375\310 -\251\002\003\001\000\001\243\202\001\037\060\202\001\033\060\037 -\006\003\125\035\043\004\030\060\026\200\024\255\275\230\172\064 -\264\046\367\372\304\046\124\357\003\275\340\044\313\124\032\060 -\035\006\003\125\035\016\004\026\004\024\257\244\100\257\237\026 -\376\253\061\375\373\325\227\213\365\221\243\044\206\026\060\016 -\006\003\125\035\017\001\001\377\004\004\003\002\001\206\060\022 -\006\003\125\035\023\001\001\377\004\010\060\006\001\001\377\002 -\001\000\060\035\006\003\125\035\045\004\026\060\024\006\010\053 -\006\001\005\005\007\003\001\006\010\053\006\001\005\005\007\003 -\002\060\031\006\003\125\035\040\004\022\060\020\060\016\006\014 -\053\006\001\004\001\262\061\001\002\001\003\004\060\104\006\003 -\125\035\037\004\075\060\073\060\071\240\067\240\065\206\063\150 -\164\164\160\072\057\057\143\162\154\056\165\163\145\162\164\162 -\165\163\164\056\143\157\155\057\101\144\144\124\162\165\163\164 -\105\170\164\145\162\156\141\154\103\101\122\157\157\164\056\143 -\162\154\060\065\006\010\053\006\001\005\005\007\001\001\004\051 -\060\047\060\045\006\010\053\006\001\005\005\007\060\001\206\031 -\150\164\164\160\072\057\057\157\143\163\160\056\165\163\145\162 -\164\162\165\163\164\056\143\157\155\060\015\006\011\052\206\110 -\206\367\015\001\001\005\005\000\003\202\001\001\000\204\256\055 -\150\070\021\154\203\121\142\300\221\302\230\274\306\073\372\245 -\305\275\073\011\346\156\140\157\060\003\206\042\032\262\213\363 -\306\316\036\273\033\171\340\026\024\115\322\232\005\113\377\217 -\354\360\050\051\352\052\004\035\075\257\021\022\325\111\230\120 -\102\237\141\146\072\266\100\231\004\014\153\020\062\351\367\317 -\206\130\117\055\315\323\254\176\350\133\152\203\174\015\240\234 -\134\120\066\165\015\155\176\102\267\337\246\334\220\134\157\043 -\116\227\035\363\042\165\277\003\065\346\135\177\307\371\233\054 -\207\366\216\326\045\226\131\235\317\352\020\036\357\156\352\132 -\233\167\030\064\314\201\167\257\232\207\302\012\345\345\236\023 -\225\123\275\275\111\032\245\166\022\366\334\362\221\267\351\032 -\341\274\115\075\225\161\175\370\215\174\076\003\117\123\355\376 -\122\375\312\137\223\341\032\001\033\002\267\163\116\272\146\351 -\170\213\120\376\021\313\321\147\320\042\117\167\352\315\024\025 -\100\256\146\135\350\056\177\036\210\157\125\171\326\271\176\343 -\265\375\221\240\300\362\046\207\113\057\235\365\240 -END - -# Trust for "USERTrust-temporary-intermediate-after-1024bit-removal" -# Issuer: CN=AddTrust External CA Root,OU=AddTrust External TTP Network,O=AddTrust AB,C=SE -# Serial Number:5d:20:61:8e:8c:0e:b9:34:40:93:b9:b1:d8:63:95:b6 -# Subject: CN=USERTrust Legacy Secure Server CA,O=The USERTRUST Network,L=Salt Lake City,ST=UT,C=US -# Not Valid Before: Tue Aug 05 00:00:00 2014 -# Not Valid After : Sun Nov 01 23:59:59 2015 -# Fingerprint (SHA-256): 92:96:6E:83:44:D2:FB:3A:28:0E:B8:60:4D:81:40:77:4C:E1:A0:57:C5:82:BE:BC:83:4D:03:02:E8:59:BC:43 -# Fingerprint (SHA1): 7C:2F:91:E2:BB:96:68:A9:C6:F6:BD:10:19:2C:6B:52:5A:1B:BA:48 -CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST -CKA_TOKEN CK_BBOOL CK_TRUE -CKA_PRIVATE CK_BBOOL CK_FALSE -CKA_MODIFIABLE CK_BBOOL CK_FALSE -CKA_LABEL UTF8 "USERTrust-temporary-intermediate-after-1024bit-removal" -CKA_CERT_SHA1_HASH MULTILINE_OCTAL -\174\057\221\342\273\226\150\251\306\366\275\020\031\054\153\122 -\132\033\272\110 -END -CKA_CERT_MD5_HASH MULTILINE_OCTAL -\131\153\146\214\004\251\341\013\017\356\105\245\220\044\037\016 -END -CKA_ISSUER MULTILINE_OCTAL -\060\157\061\013\060\011\006\003\125\004\006\023\002\123\105\061 -\024\060\022\006\003\125\004\012\023\013\101\144\144\124\162\165 -\163\164\040\101\102\061\046\060\044\006\003\125\004\013\023\035 -\101\144\144\124\162\165\163\164\040\105\170\164\145\162\156\141 -\154\040\124\124\120\040\116\145\164\167\157\162\153\061\042\060 -\040\006\003\125\004\003\023\031\101\144\144\124\162\165\163\164 -\040\105\170\164\145\162\156\141\154\040\103\101\040\122\157\157 -\164 -END -CKA_SERIAL_NUMBER MULTILINE_OCTAL -\002\020\135\040\141\216\214\016\271\064\100\223\271\261\330\143 -\225\266 -END -CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST -CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE - # # Certificate "VeriSign-C3SSA-G2-temporary-intermediate-after-1024bit-removal" # @@ -31590,3 +28054,1181 @@ CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_NOT_TRUSTED CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5" +# +# Issuer: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H5,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Serial Number:00:8e:17:fe:24:20:81 +# Subject: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H5,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Not Valid Before: Tue Apr 30 08:07:01 2013 +# Not Valid After : Fri Apr 28 08:07:01 2023 +# Fingerprint (SHA-256): 49:35:1B:90:34:44:C1:85:CC:DC:5C:69:3D:24:D8:55:5C:B2:08:D6:A8:14:13:07:69:9F:4A:F0:63:19:9D:78 +# Fingerprint (SHA1): C4:18:F6:4D:46:D1:DF:00:3D:27:30:13:72:43:A9:12:11:C6:75:FB +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\065 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\065 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\007\000\216\027\376\044\040\201 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\004\047\060\202\003\017\240\003\002\001\002\002\007\000 +\216\027\376\044\040\201\060\015\006\011\052\206\110\206\367\015 +\001\001\013\005\000\060\201\261\061\013\060\011\006\003\125\004 +\006\023\002\124\122\061\017\060\015\006\003\125\004\007\014\006 +\101\156\153\141\162\141\061\115\060\113\006\003\125\004\012\014 +\104\124\303\234\122\113\124\122\125\123\124\040\102\151\154\147 +\151\040\304\260\154\145\164\151\305\237\151\155\040\166\145\040 +\102\151\154\151\305\237\151\155\040\107\303\274\166\145\156\154 +\151\304\237\151\040\110\151\172\155\145\164\154\145\162\151\040 +\101\056\305\236\056\061\102\060\100\006\003\125\004\003\014\071 +\124\303\234\122\113\124\122\125\123\124\040\105\154\145\153\164 +\162\157\156\151\153\040\123\145\162\164\151\146\151\153\141\040 +\110\151\172\155\145\164\040\123\141\304\237\154\141\171\304\261 +\143\304\261\163\304\261\040\110\065\060\036\027\015\061\063\060 +\064\063\060\060\070\060\067\060\061\132\027\015\062\063\060\064 +\062\070\060\070\060\067\060\061\132\060\201\261\061\013\060\011 +\006\003\125\004\006\023\002\124\122\061\017\060\015\006\003\125 +\004\007\014\006\101\156\153\141\162\141\061\115\060\113\006\003 +\125\004\012\014\104\124\303\234\122\113\124\122\125\123\124\040 +\102\151\154\147\151\040\304\260\154\145\164\151\305\237\151\155 +\040\166\145\040\102\151\154\151\305\237\151\155\040\107\303\274 +\166\145\156\154\151\304\237\151\040\110\151\172\155\145\164\154 +\145\162\151\040\101\056\305\236\056\061\102\060\100\006\003\125 +\004\003\014\071\124\303\234\122\113\124\122\125\123\124\040\105 +\154\145\153\164\162\157\156\151\153\040\123\145\162\164\151\146 +\151\153\141\040\110\151\172\155\145\164\040\123\141\304\237\154 +\141\171\304\261\143\304\261\163\304\261\040\110\065\060\202\001 +\042\060\015\006\011\052\206\110\206\367\015\001\001\001\005\000 +\003\202\001\017\000\060\202\001\012\002\202\001\001\000\244\045 +\031\341\145\236\353\110\041\120\112\010\345\021\360\132\272\046 +\377\203\131\316\104\052\057\376\341\316\140\003\374\215\003\245 +\355\377\153\250\272\314\064\006\237\131\065\366\354\054\273\235 +\373\215\122\151\343\234\047\020\123\363\244\002\305\247\371\021 +\032\151\165\156\303\035\213\321\230\215\223\207\247\161\227\015 +\041\307\231\371\122\323\054\143\135\125\274\350\037\001\110\271 +\140\376\102\112\366\310\200\256\315\146\172\236\105\212\150\167 +\342\110\150\237\242\332\361\341\301\020\237\353\074\051\201\247 +\341\062\010\324\240\005\261\214\373\215\226\000\016\076\045\337 +\123\206\042\073\374\364\275\363\011\176\167\354\206\353\017\063 +\345\103\117\364\124\165\155\051\231\056\146\132\103\337\313\134 +\312\310\345\070\361\176\073\065\235\017\364\305\132\241\314\363 +\040\200\044\323\127\354\025\272\165\045\233\350\144\113\263\064 +\204\357\004\270\366\311\154\252\002\076\266\125\342\062\067\137 +\374\146\227\137\315\326\236\307\040\277\115\306\254\077\165\137 +\034\355\062\234\174\151\000\151\221\343\043\030\123\351\002\003 +\001\000\001\243\102\060\100\060\035\006\003\125\035\016\004\026 +\004\024\126\231\007\036\323\254\014\151\144\264\014\120\107\336 +\103\054\276\040\300\373\060\016\006\003\125\035\017\001\001\377 +\004\004\003\002\001\006\060\017\006\003\125\035\023\001\001\377 +\004\005\060\003\001\001\377\060\015\006\011\052\206\110\206\367 +\015\001\001\013\005\000\003\202\001\001\000\236\105\166\173\027 +\110\062\362\070\213\051\275\356\226\112\116\201\030\261\121\107 +\040\315\320\144\261\016\311\331\001\331\011\316\310\231\334\150 +\045\023\324\134\362\243\350\004\376\162\011\307\013\252\035\045 +\125\176\226\232\127\267\272\305\021\172\031\346\247\176\075\205 +\016\365\371\056\051\057\347\371\154\130\026\127\120\045\366\076 +\056\076\252\355\167\161\252\252\231\226\106\012\256\216\354\052 +\121\026\260\136\315\352\147\004\034\130\060\365\140\212\275\246 +\275\115\345\226\264\374\102\211\001\153\366\160\310\120\071\014 +\055\325\146\331\310\322\263\062\267\033\031\155\313\063\371\337 +\245\346\025\204\067\360\302\362\145\226\222\220\167\360\255\364 +\220\351\021\170\327\223\211\300\075\013\272\051\364\350\231\235 +\162\216\355\235\057\356\222\175\241\361\377\135\272\063\140\205 +\142\376\007\002\241\204\126\106\276\226\012\232\023\327\041\114 +\267\174\007\237\116\116\077\221\164\373\047\235\021\314\335\346 +\261\312\161\115\023\027\071\046\305\051\041\053\223\051\152\226 +\372\253\101\341\113\266\065\013\300\233\025 +END + +# Trust for "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5" +# Issuer: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H5,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Serial Number:00:8e:17:fe:24:20:81 +# Subject: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H5,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Not Valid Before: Tue Apr 30 08:07:01 2013 +# Not Valid After : Fri Apr 28 08:07:01 2023 +# Fingerprint (SHA-256): 49:35:1B:90:34:44:C1:85:CC:DC:5C:69:3D:24:D8:55:5C:B2:08:D6:A8:14:13:07:69:9F:4A:F0:63:19:9D:78 +# Fingerprint (SHA1): C4:18:F6:4D:46:D1:DF:00:3D:27:30:13:72:43:A9:12:11:C6:75:FB +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\304\030\366\115\106\321\337\000\075\047\060\023\162\103\251\022 +\021\306\165\373 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\332\160\216\360\042\337\223\046\366\137\237\323\025\006\122\116 +END +CKA_ISSUER MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\065 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\007\000\216\027\376\044\040\201 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6" +# +# Issuer: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H6,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Serial Number:7d:a1:f2:65:ec:8a +# Subject: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H6,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Not Valid Before: Wed Dec 18 09:04:10 2013 +# Not Valid After : Sat Dec 16 09:04:10 2023 +# Fingerprint (SHA-256): 8D:E7:86:55:E1:BE:7F:78:47:80:0B:93:F6:94:D2:1D:36:8C:C0:6E:03:3E:7F:AB:04:BB:5E:B9:9D:A6:B7:00 +# Fingerprint (SHA1): 8A:5C:8C:EE:A5:03:E6:05:56:BA:D8:1B:D4:F6:C9:B0:ED:E5:2F:E0 +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\066 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\066 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\006\175\241\362\145\354\212 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\004\046\060\202\003\016\240\003\002\001\002\002\006\175 +\241\362\145\354\212\060\015\006\011\052\206\110\206\367\015\001 +\001\013\005\000\060\201\261\061\013\060\011\006\003\125\004\006 +\023\002\124\122\061\017\060\015\006\003\125\004\007\014\006\101 +\156\153\141\162\141\061\115\060\113\006\003\125\004\012\014\104 +\124\303\234\122\113\124\122\125\123\124\040\102\151\154\147\151 +\040\304\260\154\145\164\151\305\237\151\155\040\166\145\040\102 +\151\154\151\305\237\151\155\040\107\303\274\166\145\156\154\151 +\304\237\151\040\110\151\172\155\145\164\154\145\162\151\040\101 +\056\305\236\056\061\102\060\100\006\003\125\004\003\014\071\124 +\303\234\122\113\124\122\125\123\124\040\105\154\145\153\164\162 +\157\156\151\153\040\123\145\162\164\151\146\151\153\141\040\110 +\151\172\155\145\164\040\123\141\304\237\154\141\171\304\261\143 +\304\261\163\304\261\040\110\066\060\036\027\015\061\063\061\062 +\061\070\060\071\060\064\061\060\132\027\015\062\063\061\062\061 +\066\060\071\060\064\061\060\132\060\201\261\061\013\060\011\006 +\003\125\004\006\023\002\124\122\061\017\060\015\006\003\125\004 +\007\014\006\101\156\153\141\162\141\061\115\060\113\006\003\125 +\004\012\014\104\124\303\234\122\113\124\122\125\123\124\040\102 +\151\154\147\151\040\304\260\154\145\164\151\305\237\151\155\040 +\166\145\040\102\151\154\151\305\237\151\155\040\107\303\274\166 +\145\156\154\151\304\237\151\040\110\151\172\155\145\164\154\145 +\162\151\040\101\056\305\236\056\061\102\060\100\006\003\125\004 +\003\014\071\124\303\234\122\113\124\122\125\123\124\040\105\154 +\145\153\164\162\157\156\151\153\040\123\145\162\164\151\146\151 +\153\141\040\110\151\172\155\145\164\040\123\141\304\237\154\141 +\171\304\261\143\304\261\163\304\261\040\110\066\060\202\001\042 +\060\015\006\011\052\206\110\206\367\015\001\001\001\005\000\003 +\202\001\017\000\060\202\001\012\002\202\001\001\000\235\260\150 +\326\350\275\024\226\243\000\012\232\361\364\307\314\221\115\161 +\170\167\271\367\041\046\025\163\121\026\224\011\107\005\342\063 +\365\150\232\065\377\334\113\057\062\307\260\355\342\202\345\157 +\332\332\352\254\306\006\317\045\015\101\201\366\301\070\042\275 +\371\261\245\246\263\001\274\077\120\027\053\366\351\146\125\324 +\063\263\134\370\103\040\170\223\125\026\160\031\062\346\211\327 +\144\353\275\110\120\375\366\320\101\003\302\164\267\375\366\200 +\317\133\305\253\244\326\225\022\233\347\227\023\062\003\351\324 +\253\103\133\026\355\063\042\144\051\266\322\223\255\057\154\330 +\075\266\366\035\016\064\356\322\175\251\125\017\040\364\375\051 +\273\221\133\034\175\306\102\070\155\102\050\155\324\001\373\315 +\210\227\111\176\270\363\203\370\265\230\057\263\047\013\110\136 +\126\347\116\243\063\263\104\326\245\362\030\224\355\034\036\251 +\225\134\142\112\370\015\147\121\251\257\041\325\370\062\235\171 +\272\032\137\345\004\125\115\023\106\377\362\317\164\307\032\143 +\155\303\037\027\022\303\036\020\076\140\010\263\061\002\003\001 +\000\001\243\102\060\100\060\035\006\003\125\035\016\004\026\004 +\024\335\125\027\023\366\254\350\110\041\312\357\265\257\321\000 +\062\355\236\214\265\060\016\006\003\125\035\017\001\001\377\004 +\004\003\002\001\006\060\017\006\003\125\035\023\001\001\377\004 +\005\060\003\001\001\377\060\015\006\011\052\206\110\206\367\015 +\001\001\013\005\000\003\202\001\001\000\157\130\015\227\103\252 +\026\124\076\277\251\337\222\105\077\205\013\273\126\323\014\122 +\314\310\277\166\147\136\346\252\263\247\357\271\254\264\020\024 +\015\164\176\075\155\255\321\175\320\232\251\245\312\030\073\002 +\100\056\052\234\120\024\213\376\127\176\127\134\021\011\113\066 +\105\122\367\075\254\024\375\104\337\213\227\043\324\303\301\356 +\324\123\225\376\054\112\376\015\160\252\273\213\057\055\313\062 +\243\202\362\124\337\330\362\335\327\110\162\356\112\243\051\226 +\303\104\316\156\265\222\207\166\244\273\364\222\154\316\054\024 +\011\146\216\215\255\026\265\307\033\011\141\073\343\040\242\003 +\200\216\255\176\121\000\116\307\226\206\373\103\230\167\175\050 +\307\217\330\052\156\347\204\157\227\101\051\000\026\136\115\342 +\023\352\131\300\143\147\072\104\373\230\374\004\323\060\162\246 +\366\207\011\127\255\166\246\035\143\232\375\327\145\310\170\203 +\053\165\073\245\133\270\015\135\177\276\043\256\126\125\224\130 +\357\037\201\214\052\262\315\346\233\143\236\030\274\345\153\006 +\264\013\230\113\050\136\257\210\130\313 +END + +# Trust for "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6" +# Issuer: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H6,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Serial Number:7d:a1:f2:65:ec:8a +# Subject: CN=T..RKTRUST Elektronik Sertifika Hizmet Sa..lay..c..s.. H6,O=T..RKTRUST Bilgi ..leti..im ve Bili..im G..venli..i Hizmetleri A....,L=Ankara,C=TR +# Not Valid Before: Wed Dec 18 09:04:10 2013 +# Not Valid After : Sat Dec 16 09:04:10 2023 +# Fingerprint (SHA-256): 8D:E7:86:55:E1:BE:7F:78:47:80:0B:93:F6:94:D2:1D:36:8C:C0:6E:03:3E:7F:AB:04:BB:5E:B9:9D:A6:B7:00 +# Fingerprint (SHA1): 8A:5C:8C:EE:A5:03:E6:05:56:BA:D8:1B:D4:F6:C9:B0:ED:E5:2F:E0 +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\212\134\214\356\245\003\346\005\126\272\330\033\324\366\311\260 +\355\345\057\340 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\370\305\356\052\153\276\225\215\010\367\045\112\352\161\076\106 +END +CKA_ISSUER MULTILINE_OCTAL +\060\201\261\061\013\060\011\006\003\125\004\006\023\002\124\122 +\061\017\060\015\006\003\125\004\007\014\006\101\156\153\141\162 +\141\061\115\060\113\006\003\125\004\012\014\104\124\303\234\122 +\113\124\122\125\123\124\040\102\151\154\147\151\040\304\260\154 +\145\164\151\305\237\151\155\040\166\145\040\102\151\154\151\305 +\237\151\155\040\107\303\274\166\145\156\154\151\304\237\151\040 +\110\151\172\155\145\164\154\145\162\151\040\101\056\305\236\056 +\061\102\060\100\006\003\125\004\003\014\071\124\303\234\122\113 +\124\122\125\123\124\040\105\154\145\153\164\162\157\156\151\153 +\040\123\145\162\164\151\146\151\153\141\040\110\151\172\155\145 +\164\040\123\141\304\237\154\141\171\304\261\143\304\261\163\304 +\261\040\110\066 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\006\175\241\362\145\354\212 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "Certinomis - Root CA" +# +# Issuer: CN=Certinomis - Root CA,OU=0002 433998903,O=Certinomis,C=FR +# Serial Number: 1 (0x1) +# Subject: CN=Certinomis - Root CA,OU=0002 433998903,O=Certinomis,C=FR +# Not Valid Before: Mon Oct 21 09:17:18 2013 +# Not Valid After : Fri Oct 21 09:17:18 2033 +# Fingerprint (SHA-256): 2A:99:F5:BC:11:74:B7:3C:BB:1D:62:08:84:E0:1C:34:E5:1C:CB:39:78:DA:12:5F:0E:33:26:88:83:BF:41:58 +# Fingerprint (SHA1): 9D:70:BB:01:A5:A4:A0:18:11:2E:F7:1C:01:B9:32:C5:34:E7:88:A8 +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certinomis - Root CA" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\132\061\013\060\011\006\003\125\004\006\023\002\106\122\061 +\023\060\021\006\003\125\004\012\023\012\103\145\162\164\151\156 +\157\155\151\163\061\027\060\025\006\003\125\004\013\023\016\060 +\060\060\062\040\064\063\063\071\071\070\071\060\063\061\035\060 +\033\006\003\125\004\003\023\024\103\145\162\164\151\156\157\155 +\151\163\040\055\040\122\157\157\164\040\103\101 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\132\061\013\060\011\006\003\125\004\006\023\002\106\122\061 +\023\060\021\006\003\125\004\012\023\012\103\145\162\164\151\156 +\157\155\151\163\061\027\060\025\006\003\125\004\013\023\016\060 +\060\060\062\040\064\063\063\071\071\070\071\060\063\061\035\060 +\033\006\003\125\004\003\023\024\103\145\162\164\151\156\157\155 +\151\163\040\055\040\122\157\157\164\040\103\101 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\001\001 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\005\222\060\202\003\172\240\003\002\001\002\002\001\001 +\060\015\006\011\052\206\110\206\367\015\001\001\013\005\000\060 +\132\061\013\060\011\006\003\125\004\006\023\002\106\122\061\023 +\060\021\006\003\125\004\012\023\012\103\145\162\164\151\156\157 +\155\151\163\061\027\060\025\006\003\125\004\013\023\016\060\060 +\060\062\040\064\063\063\071\071\070\071\060\063\061\035\060\033 +\006\003\125\004\003\023\024\103\145\162\164\151\156\157\155\151 +\163\040\055\040\122\157\157\164\040\103\101\060\036\027\015\061 +\063\061\060\062\061\060\071\061\067\061\070\132\027\015\063\063 +\061\060\062\061\060\071\061\067\061\070\132\060\132\061\013\060 +\011\006\003\125\004\006\023\002\106\122\061\023\060\021\006\003 +\125\004\012\023\012\103\145\162\164\151\156\157\155\151\163\061 +\027\060\025\006\003\125\004\013\023\016\060\060\060\062\040\064 +\063\063\071\071\070\071\060\063\061\035\060\033\006\003\125\004 +\003\023\024\103\145\162\164\151\156\157\155\151\163\040\055\040 +\122\157\157\164\040\103\101\060\202\002\042\060\015\006\011\052 +\206\110\206\367\015\001\001\001\005\000\003\202\002\017\000\060 +\202\002\012\002\202\002\001\000\324\314\011\012\054\077\222\366 +\177\024\236\013\234\232\152\035\100\060\144\375\252\337\016\036 +\006\133\237\120\205\352\315\215\253\103\147\336\260\372\176\200 +\226\236\204\170\222\110\326\343\071\356\316\344\131\130\227\345 +\056\047\230\352\223\250\167\233\112\360\357\164\200\055\353\060 +\037\265\331\307\200\234\142\047\221\210\360\112\211\335\334\210 +\346\024\371\325\003\057\377\225\333\275\237\354\054\372\024\025 +\131\225\012\306\107\174\151\030\271\247\003\371\312\166\251\317 +\307\157\264\136\005\376\356\301\122\262\165\062\207\354\355\051 +\146\073\363\112\026\202\366\326\232\333\162\230\351\336\360\305 +\114\245\253\265\352\001\342\214\056\144\177\144\157\375\243\045 +\223\213\310\242\016\111\215\064\360\037\354\130\105\056\064\252 +\204\120\275\347\262\112\023\270\260\017\256\070\135\260\251\033 +\346\163\311\132\241\331\146\100\252\251\115\246\064\002\255\204 +\176\262\043\301\373\052\306\147\364\064\266\260\225\152\063\117 +\161\104\265\255\300\171\063\210\340\277\355\243\240\024\264\234 +\011\260\012\343\140\276\370\370\146\210\315\133\361\167\005\340 +\265\163\156\301\175\106\056\216\113\047\246\315\065\012\375\345 +\115\175\252\052\243\051\307\132\150\004\350\345\326\223\244\142 +\302\305\346\364\117\306\371\237\032\215\202\111\031\212\312\131 +\103\072\350\015\062\301\364\114\023\003\157\156\246\077\221\163 +\313\312\163\157\022\040\213\356\300\202\170\336\113\056\302\111 +\303\035\355\026\366\044\364\047\033\134\127\061\334\125\356\250 +\036\157\154\254\342\105\314\127\127\212\165\127\031\340\265\130 +\231\111\066\061\074\063\001\155\026\112\315\270\052\203\204\206 +\233\371\140\322\037\155\221\003\323\140\246\325\075\232\335\167 +\220\075\065\244\237\017\136\365\122\104\151\271\300\272\334\317 +\175\337\174\331\304\254\206\042\062\274\173\153\221\357\172\370 +\027\150\260\342\123\125\140\055\257\076\302\203\330\331\011\053 +\360\300\144\333\207\213\221\314\221\353\004\375\166\264\225\232 +\346\024\006\033\325\064\035\276\330\377\164\034\123\205\231\340 +\131\122\112\141\355\210\236\153\111\211\106\176\040\132\331\347 +\112\345\152\356\322\145\021\103\002\003\001\000\001\243\143\060 +\141\060\016\006\003\125\035\017\001\001\377\004\004\003\002\001 +\006\060\017\006\003\125\035\023\001\001\377\004\005\060\003\001 +\001\377\060\035\006\003\125\035\016\004\026\004\024\357\221\114 +\365\245\303\060\350\057\010\352\323\161\042\244\222\150\170\164 +\331\060\037\006\003\125\035\043\004\030\060\026\200\024\357\221 +\114\365\245\303\060\350\057\010\352\323\161\042\244\222\150\170 +\164\331\060\015\006\011\052\206\110\206\367\015\001\001\013\005 +\000\003\202\002\001\000\176\075\124\332\042\135\032\130\076\073 +\124\047\272\272\314\310\343\032\152\352\076\371\022\353\126\137 +\075\120\316\340\352\110\046\046\317\171\126\176\221\034\231\077 +\320\241\221\034\054\017\117\230\225\131\123\275\320\042\330\210 +\135\234\067\374\373\144\301\170\214\213\232\140\011\352\325\372 +\041\137\320\164\145\347\120\305\277\056\271\013\013\255\265\260 +\027\246\022\214\324\142\170\352\126\152\354\012\322\100\303\074 +\005\060\076\115\224\267\237\112\003\323\175\047\113\266\376\104 +\316\372\031\063\032\155\244\102\321\335\314\310\310\327\026\122 +\203\117\065\224\263\022\125\175\345\342\102\353\344\234\223\011 +\300\114\133\007\253\307\155\021\240\120\027\224\043\250\265\012 +\222\017\262\172\301\140\054\070\314\032\246\133\377\362\014\343 +\252\037\034\334\270\240\223\047\336\143\343\177\041\237\072\345 +\236\372\340\023\152\165\353\226\134\142\221\224\216\147\123\266 +\211\370\022\011\313\157\122\133\003\162\206\120\225\010\324\215 +\207\206\025\037\225\044\330\244\157\232\316\244\235\233\155\322 +\262\166\006\206\306\126\010\305\353\011\332\066\302\033\133\101 +\276\141\052\343\160\346\270\246\370\266\132\304\275\041\367\377 +\252\137\241\154\166\071\146\326\352\114\125\341\000\063\233\023 +\230\143\311\157\320\001\040\011\067\122\347\014\117\076\315\274 +\365\137\226\047\247\040\002\225\340\056\350\007\101\005\037\025 +\156\326\260\344\031\340\017\002\223\000\047\162\305\213\321\124 +\037\135\112\303\100\227\176\125\246\174\301\063\004\024\001\035 +\111\040\151\013\031\223\235\156\130\042\367\100\014\106\014\043 +\143\363\071\322\177\166\121\247\364\310\241\361\014\166\042\043 +\106\122\051\055\342\243\101\007\126\151\230\322\005\011\274\151 +\307\132\141\315\217\201\140\025\115\200\335\220\342\175\304\120 +\362\214\073\156\112\307\306\346\200\053\074\201\274\021\200\026 +\020\047\327\360\315\077\171\314\163\052\303\176\123\221\326\156 +\370\365\363\307\320\121\115\216\113\245\133\346\031\027\073\326 +\201\011\334\042\334\356\216\271\304\217\123\341\147\273\063\270 +\210\025\106\317\355\151\065\377\165\015\106\363\316\161\341\305 +\153\206\102\006\271\101 +END + +# Trust for "Certinomis - Root CA" +# Issuer: CN=Certinomis - Root CA,OU=0002 433998903,O=Certinomis,C=FR +# Serial Number: 1 (0x1) +# Subject: CN=Certinomis - Root CA,OU=0002 433998903,O=Certinomis,C=FR +# Not Valid Before: Mon Oct 21 09:17:18 2013 +# Not Valid After : Fri Oct 21 09:17:18 2033 +# Fingerprint (SHA-256): 2A:99:F5:BC:11:74:B7:3C:BB:1D:62:08:84:E0:1C:34:E5:1C:CB:39:78:DA:12:5F:0E:33:26:88:83:BF:41:58 +# Fingerprint (SHA1): 9D:70:BB:01:A5:A4:A0:18:11:2E:F7:1C:01:B9:32:C5:34:E7:88:A8 +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certinomis - Root CA" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\235\160\273\001\245\244\240\030\021\056\367\034\001\271\062\305 +\064\347\210\250 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\024\012\375\215\250\050\265\070\151\333\126\176\141\042\003\077 +END +CKA_ISSUER MULTILINE_OCTAL +\060\132\061\013\060\011\006\003\125\004\006\023\002\106\122\061 +\023\060\021\006\003\125\004\012\023\012\103\145\162\164\151\156 +\157\155\151\163\061\027\060\025\006\003\125\004\013\023\016\060 +\060\060\062\040\064\063\063\071\071\070\071\060\063\061\035\060 +\033\006\003\125\004\003\023\024\103\145\162\164\151\156\157\155 +\151\163\040\055\040\122\157\157\164\040\103\101 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\001\001 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "OISTE WISeKey Global Root GB CA" +# +# Issuer: CN=OISTE WISeKey Global Root GB CA,OU=OISTE Foundation Endorsed,O=WISeKey,C=CH +# Serial Number:76:b1:20:52:74:f0:85:87:46:b3:f8:23:1a:f6:c2:c0 +# Subject: CN=OISTE WISeKey Global Root GB CA,OU=OISTE Foundation Endorsed,O=WISeKey,C=CH +# Not Valid Before: Mon Dec 01 15:00:32 2014 +# Not Valid After : Thu Dec 01 15:10:31 2039 +# Fingerprint (SHA-256): 6B:9C:08:E8:6E:B0:F7:67:CF:AD:65:CD:98:B6:21:49:E5:49:4A:67:F5:84:5E:7B:D1:ED:01:9F:27:B8:6B:D6 +# Fingerprint (SHA1): 0F:F9:40:76:18:D3:D7:6A:4B:98:F0:A8:35:9E:0C:FD:27:AC:CC:ED +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "OISTE WISeKey Global Root GB CA" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\155\061\013\060\011\006\003\125\004\006\023\002\103\110\061 +\020\060\016\006\003\125\004\012\023\007\127\111\123\145\113\145 +\171\061\042\060\040\006\003\125\004\013\023\031\117\111\123\124 +\105\040\106\157\165\156\144\141\164\151\157\156\040\105\156\144 +\157\162\163\145\144\061\050\060\046\006\003\125\004\003\023\037 +\117\111\123\124\105\040\127\111\123\145\113\145\171\040\107\154 +\157\142\141\154\040\122\157\157\164\040\107\102\040\103\101 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\155\061\013\060\011\006\003\125\004\006\023\002\103\110\061 +\020\060\016\006\003\125\004\012\023\007\127\111\123\145\113\145 +\171\061\042\060\040\006\003\125\004\013\023\031\117\111\123\124 +\105\040\106\157\165\156\144\141\164\151\157\156\040\105\156\144 +\157\162\163\145\144\061\050\060\046\006\003\125\004\003\023\037 +\117\111\123\124\105\040\127\111\123\145\113\145\171\040\107\154 +\157\142\141\154\040\122\157\157\164\040\107\102\040\103\101 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\166\261\040\122\164\360\205\207\106\263\370\043\032\366 +\302\300 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\003\265\060\202\002\235\240\003\002\001\002\002\020\166 +\261\040\122\164\360\205\207\106\263\370\043\032\366\302\300\060 +\015\006\011\052\206\110\206\367\015\001\001\013\005\000\060\155 +\061\013\060\011\006\003\125\004\006\023\002\103\110\061\020\060 +\016\006\003\125\004\012\023\007\127\111\123\145\113\145\171\061 +\042\060\040\006\003\125\004\013\023\031\117\111\123\124\105\040 +\106\157\165\156\144\141\164\151\157\156\040\105\156\144\157\162 +\163\145\144\061\050\060\046\006\003\125\004\003\023\037\117\111 +\123\124\105\040\127\111\123\145\113\145\171\040\107\154\157\142 +\141\154\040\122\157\157\164\040\107\102\040\103\101\060\036\027 +\015\061\064\061\062\060\061\061\065\060\060\063\062\132\027\015 +\063\071\061\062\060\061\061\065\061\060\063\061\132\060\155\061 +\013\060\011\006\003\125\004\006\023\002\103\110\061\020\060\016 +\006\003\125\004\012\023\007\127\111\123\145\113\145\171\061\042 +\060\040\006\003\125\004\013\023\031\117\111\123\124\105\040\106 +\157\165\156\144\141\164\151\157\156\040\105\156\144\157\162\163 +\145\144\061\050\060\046\006\003\125\004\003\023\037\117\111\123 +\124\105\040\127\111\123\145\113\145\171\040\107\154\157\142\141 +\154\040\122\157\157\164\040\107\102\040\103\101\060\202\001\042 +\060\015\006\011\052\206\110\206\367\015\001\001\001\005\000\003 +\202\001\017\000\060\202\001\012\002\202\001\001\000\330\027\267 +\034\112\044\052\326\227\261\312\342\036\373\175\070\357\230\365 +\262\071\230\116\047\270\021\135\173\322\045\224\210\202\025\046 +\152\033\061\273\250\133\041\041\053\330\017\116\237\132\361\261 +\132\344\171\326\062\043\053\341\123\314\231\105\134\173\117\255 +\274\277\207\112\013\113\227\132\250\366\110\354\175\173\015\315 +\041\006\337\236\025\375\101\212\110\267\040\364\241\172\033\127 +\324\135\120\377\272\147\330\043\231\037\310\077\343\336\377\157 +\133\167\261\153\156\270\311\144\367\341\312\101\106\016\051\161 +\320\271\043\374\311\201\137\116\367\157\337\277\204\255\163\144 +\273\267\102\216\151\366\324\166\035\176\235\247\270\127\212\121 +\147\162\327\324\250\270\225\124\100\163\003\366\352\364\353\376 +\050\102\167\077\235\043\033\262\266\075\200\024\007\114\056\117 +\367\325\012\026\015\275\146\103\067\176\043\103\171\303\100\206 +\365\114\051\332\216\232\255\015\245\004\207\210\036\205\343\351 +\123\325\233\310\213\003\143\170\353\340\031\112\156\273\057\153 +\063\144\130\223\255\151\277\217\033\357\202\110\307\002\003\001 +\000\001\243\121\060\117\060\013\006\003\125\035\017\004\004\003 +\002\001\206\060\017\006\003\125\035\023\001\001\377\004\005\060 +\003\001\001\377\060\035\006\003\125\035\016\004\026\004\024\065 +\017\310\066\143\136\342\243\354\371\073\146\025\316\121\122\343 +\221\232\075\060\020\006\011\053\006\001\004\001\202\067\025\001 +\004\003\002\001\000\060\015\006\011\052\206\110\206\367\015\001 +\001\013\005\000\003\202\001\001\000\100\114\373\207\262\231\201 +\220\176\235\305\260\260\046\315\210\173\053\062\215\156\270\041 +\161\130\227\175\256\067\024\257\076\347\367\232\342\175\366\161 +\230\231\004\252\103\164\170\243\343\111\141\076\163\214\115\224 +\340\371\161\304\266\026\016\123\170\037\326\242\207\057\002\071 +\201\051\074\257\025\230\041\060\376\050\220\000\214\321\341\313 +\372\136\310\375\370\020\106\073\242\170\102\221\027\164\125\012 +\336\120\147\115\146\321\247\377\375\331\300\265\250\243\212\316 +\146\365\017\103\315\247\053\127\173\143\106\152\252\056\122\330 +\364\355\341\155\255\051\220\170\110\272\341\043\252\243\211\354 +\265\253\226\300\264\113\242\035\227\236\172\362\156\100\161\337 +\150\361\145\115\316\174\005\337\123\145\251\245\360\261\227\004 +\160\025\106\003\230\324\322\277\124\264\240\130\175\122\157\332 +\126\046\142\324\330\333\211\061\157\034\360\042\302\323\142\034 +\065\315\114\151\025\124\032\220\230\336\353\036\137\312\167\307 +\313\216\075\103\151\234\232\130\320\044\073\337\033\100\226\176 +\065\255\201\307\116\161\272\210\023 +END + +# Trust for "OISTE WISeKey Global Root GB CA" +# Issuer: CN=OISTE WISeKey Global Root GB CA,OU=OISTE Foundation Endorsed,O=WISeKey,C=CH +# Serial Number:76:b1:20:52:74:f0:85:87:46:b3:f8:23:1a:f6:c2:c0 +# Subject: CN=OISTE WISeKey Global Root GB CA,OU=OISTE Foundation Endorsed,O=WISeKey,C=CH +# Not Valid Before: Mon Dec 01 15:00:32 2014 +# Not Valid After : Thu Dec 01 15:10:31 2039 +# Fingerprint (SHA-256): 6B:9C:08:E8:6E:B0:F7:67:CF:AD:65:CD:98:B6:21:49:E5:49:4A:67:F5:84:5E:7B:D1:ED:01:9F:27:B8:6B:D6 +# Fingerprint (SHA1): 0F:F9:40:76:18:D3:D7:6A:4B:98:F0:A8:35:9E:0C:FD:27:AC:CC:ED +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "OISTE WISeKey Global Root GB CA" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\017\371\100\166\030\323\327\152\113\230\360\250\065\236\014\375 +\047\254\314\355 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\244\353\271\141\050\056\267\057\230\260\065\046\220\231\121\035 +END +CKA_ISSUER MULTILINE_OCTAL +\060\155\061\013\060\011\006\003\125\004\006\023\002\103\110\061 +\020\060\016\006\003\125\004\012\023\007\127\111\123\145\113\145 +\171\061\042\060\040\006\003\125\004\013\023\031\117\111\123\124 +\105\040\106\157\165\156\144\141\164\151\157\156\040\105\156\144 +\157\162\163\145\144\061\050\060\046\006\003\125\004\003\023\037 +\117\111\123\124\105\040\127\111\123\145\113\145\171\040\107\154 +\157\142\141\154\040\122\157\157\164\040\107\102\040\103\101 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\166\261\040\122\164\360\205\207\106\263\370\043\032\366 +\302\300 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "Certification Authority of WoSign G2" +# +# Issuer: CN=Certification Authority of WoSign G2,O=WoSign CA Limited,C=CN +# Serial Number:6b:25:da:8a:88:9d:7c:bc:0f:05:b3:b1:7a:61:45:44 +# Subject: CN=Certification Authority of WoSign G2,O=WoSign CA Limited,C=CN +# Not Valid Before: Sat Nov 08 00:58:58 2014 +# Not Valid After : Tue Nov 08 00:58:58 2044 +# Fingerprint (SHA-256): D4:87:A5:6F:83:B0:74:82:E8:5E:96:33:94:C1:EC:C2:C9:E5:1D:09:03:EE:94:6B:02:C3:01:58:1E:D9:9E:16 +# Fingerprint (SHA1): FB:ED:DC:90:65:B7:27:20:37:BC:55:0C:9C:56:DE:BB:F2:78:94:E1 +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certification Authority of WoSign G2" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\130\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\055\060\053\006 +\003\125\004\003\023\044\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\040\157\146 +\040\127\157\123\151\147\156\040\107\062 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\130\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\055\060\053\006 +\003\125\004\003\023\044\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\040\157\146 +\040\127\157\123\151\147\156\040\107\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\153\045\332\212\210\235\174\274\017\005\263\261\172\141 +\105\104 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\003\174\060\202\002\144\240\003\002\001\002\002\020\153 +\045\332\212\210\235\174\274\017\005\263\261\172\141\105\104\060 +\015\006\011\052\206\110\206\367\015\001\001\013\005\000\060\130 +\061\013\060\011\006\003\125\004\006\023\002\103\116\061\032\060 +\030\006\003\125\004\012\023\021\127\157\123\151\147\156\040\103 +\101\040\114\151\155\151\164\145\144\061\055\060\053\006\003\125 +\004\003\023\044\103\145\162\164\151\146\151\143\141\164\151\157 +\156\040\101\165\164\150\157\162\151\164\171\040\157\146\040\127 +\157\123\151\147\156\040\107\062\060\036\027\015\061\064\061\061 +\060\070\060\060\065\070\065\070\132\027\015\064\064\061\061\060 +\070\060\060\065\070\065\070\132\060\130\061\013\060\011\006\003 +\125\004\006\023\002\103\116\061\032\060\030\006\003\125\004\012 +\023\021\127\157\123\151\147\156\040\103\101\040\114\151\155\151 +\164\145\144\061\055\060\053\006\003\125\004\003\023\044\103\145 +\162\164\151\146\151\143\141\164\151\157\156\040\101\165\164\150 +\157\162\151\164\171\040\157\146\040\127\157\123\151\147\156\040 +\107\062\060\202\001\042\060\015\006\011\052\206\110\206\367\015 +\001\001\001\005\000\003\202\001\017\000\060\202\001\012\002\202 +\001\001\000\276\305\304\240\042\200\111\117\277\331\207\021\306 +\123\341\273\017\275\140\177\257\366\202\016\037\334\260\216\075 +\227\340\120\074\217\072\357\146\073\105\007\233\040\370\343\327 +\045\206\065\220\026\242\135\157\060\031\010\207\013\177\006\262 +\235\142\217\336\257\222\245\140\324\053\200\232\122\077\365\232 +\203\351\064\132\313\331\325\142\134\346\016\340\337\006\230\016 +\200\174\312\264\035\023\210\153\016\250\044\167\003\320\356\133 +\363\312\151\221\065\071\126\305\155\343\367\075\117\136\223\070 +\044\312\030\351\044\313\222\003\335\314\034\075\011\160\344\040 +\344\361\256\254\273\163\151\243\143\072\017\105\017\241\112\232 +\302\321\143\254\313\020\370\075\346\116\050\267\353\304\225\261 +\254\375\136\253\372\101\313\135\235\113\334\364\174\166\357\147 +\177\000\172\215\322\240\032\134\115\042\341\265\332\335\166\263 +\324\166\337\136\270\213\230\310\024\124\314\153\027\222\267\340 +\112\277\111\224\141\013\070\220\217\135\044\154\045\173\073\171 +\331\342\176\235\255\237\230\241\006\374\170\024\140\127\370\356 +\200\167\261\002\003\001\000\001\243\102\060\100\060\016\006\003 +\125\035\017\001\001\377\004\004\003\002\001\006\060\017\006\003 +\125\035\023\001\001\377\004\005\060\003\001\001\377\060\035\006 +\003\125\035\016\004\026\004\024\372\140\251\353\145\305\335\026 +\024\010\116\014\017\215\233\340\367\144\257\147\060\015\006\011 +\052\206\110\206\367\015\001\001\013\005\000\003\202\001\001\000 +\127\303\172\066\202\234\215\230\342\253\100\252\107\217\307\247 +\133\355\174\347\075\146\132\073\061\273\337\363\026\063\221\374 +\174\173\245\302\246\146\343\252\260\267\047\230\077\111\327\140 +\147\147\077\066\117\112\313\361\024\372\132\207\050\034\355\217 +\101\062\306\225\371\175\332\275\173\133\302\260\041\343\217\106 +\334\041\070\103\164\114\373\060\370\027\162\301\062\374\310\221 +\027\304\314\130\067\116\013\314\132\367\041\065\050\203\154\140 +\055\104\353\122\214\120\075\265\154\022\327\372\011\273\154\262 +\112\261\305\211\344\374\323\122\330\141\027\376\172\224\204\217 +\171\266\063\131\272\017\304\013\342\160\240\113\170\056\372\310 +\237\375\257\221\145\012\170\070\025\345\227\027\024\335\371\340 +\054\064\370\070\320\204\042\000\300\024\121\030\053\002\334\060 +\132\360\350\001\174\065\072\043\257\010\344\257\252\216\050\102 +\111\056\360\365\231\064\276\355\017\113\030\341\322\044\074\273 +\135\107\267\041\362\215\321\012\231\216\343\156\076\255\160\340 +\217\271\312\314\156\201\061\366\173\234\172\171\344\147\161\030 +END + +# Trust for "Certification Authority of WoSign G2" +# Issuer: CN=Certification Authority of WoSign G2,O=WoSign CA Limited,C=CN +# Serial Number:6b:25:da:8a:88:9d:7c:bc:0f:05:b3:b1:7a:61:45:44 +# Subject: CN=Certification Authority of WoSign G2,O=WoSign CA Limited,C=CN +# Not Valid Before: Sat Nov 08 00:58:58 2014 +# Not Valid After : Tue Nov 08 00:58:58 2044 +# Fingerprint (SHA-256): D4:87:A5:6F:83:B0:74:82:E8:5E:96:33:94:C1:EC:C2:C9:E5:1D:09:03:EE:94:6B:02:C3:01:58:1E:D9:9E:16 +# Fingerprint (SHA1): FB:ED:DC:90:65:B7:27:20:37:BC:55:0C:9C:56:DE:BB:F2:78:94:E1 +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certification Authority of WoSign G2" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\373\355\334\220\145\267\047\040\067\274\125\014\234\126\336\273 +\362\170\224\341 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\310\034\175\031\252\313\161\223\362\120\370\122\250\036\272\140 +END +CKA_ISSUER MULTILINE_OCTAL +\060\130\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\055\060\053\006 +\003\125\004\003\023\044\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\040\157\146 +\040\127\157\123\151\147\156\040\107\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\153\045\332\212\210\235\174\274\017\005\263\261\172\141 +\105\104 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "CA WoSign ECC Root" +# +# Issuer: CN=CA WoSign ECC Root,O=WoSign CA Limited,C=CN +# Serial Number:68:4a:58:70:80:6b:f0:8f:02:fa:f6:de:e8:b0:90:90 +# Subject: CN=CA WoSign ECC Root,O=WoSign CA Limited,C=CN +# Not Valid Before: Sat Nov 08 00:58:58 2014 +# Not Valid After : Tue Nov 08 00:58:58 2044 +# Fingerprint (SHA-256): 8B:45:DA:1C:06:F7:91:EB:0C:AB:F2:6B:E5:88:F5:FB:23:16:5C:2E:61:4B:F8:85:56:2D:0D:CE:50:B2:9B:02 +# Fingerprint (SHA1): D2:7A:D2:BE:ED:94:C0:A1:3C:C7:25:21:EA:5D:71:BE:81:19:F3:2B +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "CA WoSign ECC Root" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\106\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\033\060\031\006 +\003\125\004\003\023\022\103\101\040\127\157\123\151\147\156\040 +\105\103\103\040\122\157\157\164 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\106\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\033\060\031\006 +\003\125\004\003\023\022\103\101\040\127\157\123\151\147\156\040 +\105\103\103\040\122\157\157\164 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\150\112\130\160\200\153\360\217\002\372\366\336\350\260 +\220\220 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\002\011\060\202\001\217\240\003\002\001\002\002\020\150 +\112\130\160\200\153\360\217\002\372\366\336\350\260\220\220\060 +\012\006\010\052\206\110\316\075\004\003\003\060\106\061\013\060 +\011\006\003\125\004\006\023\002\103\116\061\032\060\030\006\003 +\125\004\012\023\021\127\157\123\151\147\156\040\103\101\040\114 +\151\155\151\164\145\144\061\033\060\031\006\003\125\004\003\023 +\022\103\101\040\127\157\123\151\147\156\040\105\103\103\040\122 +\157\157\164\060\036\027\015\061\064\061\061\060\070\060\060\065 +\070\065\070\132\027\015\064\064\061\061\060\070\060\060\065\070 +\065\070\132\060\106\061\013\060\011\006\003\125\004\006\023\002 +\103\116\061\032\060\030\006\003\125\004\012\023\021\127\157\123 +\151\147\156\040\103\101\040\114\151\155\151\164\145\144\061\033 +\060\031\006\003\125\004\003\023\022\103\101\040\127\157\123\151 +\147\156\040\105\103\103\040\122\157\157\164\060\166\060\020\006 +\007\052\206\110\316\075\002\001\006\005\053\201\004\000\042\003 +\142\000\004\341\375\216\270\103\044\253\226\173\205\302\272\013 +\255\215\340\072\343\044\271\322\261\276\210\072\312\277\112\270 +\371\357\054\057\257\121\120\074\107\165\154\370\224\267\233\374 +\050\036\305\124\314\143\235\026\113\123\301\347\040\253\315\254 +\045\322\177\217\302\301\132\202\136\060\213\172\124\316\003\265 +\221\177\252\224\320\321\212\110\314\202\005\046\241\325\121\022 +\326\173\066\243\102\060\100\060\016\006\003\125\035\017\001\001 +\377\004\004\003\002\001\006\060\017\006\003\125\035\023\001\001 +\377\004\005\060\003\001\001\377\060\035\006\003\125\035\016\004 +\026\004\024\252\375\325\132\243\366\207\213\062\205\375\321\062 +\133\200\105\223\363\003\270\060\012\006\010\052\206\110\316\075 +\004\003\003\003\150\000\060\145\002\061\000\344\244\204\260\201 +\325\075\260\164\254\224\244\350\016\075\000\164\114\241\227\153 +\371\015\121\074\241\331\073\364\015\253\251\237\276\116\162\312 +\205\324\331\354\265\062\105\030\157\253\255\002\060\175\307\367 +\151\143\057\241\341\230\357\023\020\321\171\077\321\376\352\073 +\177\336\126\364\220\261\025\021\330\262\042\025\320\057\303\046 +\056\153\361\221\262\220\145\364\232\346\220\356\112 +END + +# Trust for "CA WoSign ECC Root" +# Issuer: CN=CA WoSign ECC Root,O=WoSign CA Limited,C=CN +# Serial Number:68:4a:58:70:80:6b:f0:8f:02:fa:f6:de:e8:b0:90:90 +# Subject: CN=CA WoSign ECC Root,O=WoSign CA Limited,C=CN +# Not Valid Before: Sat Nov 08 00:58:58 2014 +# Not Valid After : Tue Nov 08 00:58:58 2044 +# Fingerprint (SHA-256): 8B:45:DA:1C:06:F7:91:EB:0C:AB:F2:6B:E5:88:F5:FB:23:16:5C:2E:61:4B:F8:85:56:2D:0D:CE:50:B2:9B:02 +# Fingerprint (SHA1): D2:7A:D2:BE:ED:94:C0:A1:3C:C7:25:21:EA:5D:71:BE:81:19:F3:2B +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "CA WoSign ECC Root" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\322\172\322\276\355\224\300\241\074\307\045\041\352\135\161\276 +\201\031\363\053 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\200\306\123\356\141\202\050\162\360\377\041\271\027\312\262\040 +END +CKA_ISSUER MULTILINE_OCTAL +\060\106\061\013\060\011\006\003\125\004\006\023\002\103\116\061 +\032\060\030\006\003\125\004\012\023\021\127\157\123\151\147\156 +\040\103\101\040\114\151\155\151\164\145\144\061\033\060\031\006 +\003\125\004\003\023\022\103\101\040\127\157\123\151\147\156\040 +\105\103\103\040\122\157\157\164 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\150\112\130\160\200\153\360\217\002\372\366\336\350\260 +\220\220 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "SZAFIR ROOT CA2" +# +# Issuer: CN=SZAFIR ROOT CA2,O=Krajowa Izba Rozliczeniowa S.A.,C=PL +# Serial Number:3e:8a:5d:07:ec:55:d2:32:d5:b7:e3:b6:5f:01:eb:2d:dc:e4:d6:e4 +# Subject: CN=SZAFIR ROOT CA2,O=Krajowa Izba Rozliczeniowa S.A.,C=PL +# Not Valid Before: Mon Oct 19 07:43:30 2015 +# Not Valid After : Fri Oct 19 07:43:30 2035 +# Fingerprint (SHA-256): A1:33:9D:33:28:1A:0B:56:E5:57:D3:D3:2B:1C:E7:F9:36:7E:B0:94:BD:5F:A7:2A:7E:50:04:C8:DE:D7:CA:FE +# Fingerprint (SHA1): E2:52:FA:95:3F:ED:DB:24:60:BD:6E:28:F3:9C:CC:CF:5E:B3:3F:DE +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "SZAFIR ROOT CA2" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\121\061\013\060\011\006\003\125\004\006\023\002\120\114\061 +\050\060\046\006\003\125\004\012\014\037\113\162\141\152\157\167 +\141\040\111\172\142\141\040\122\157\172\154\151\143\172\145\156 +\151\157\167\141\040\123\056\101\056\061\030\060\026\006\003\125 +\004\003\014\017\123\132\101\106\111\122\040\122\117\117\124\040 +\103\101\062 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\121\061\013\060\011\006\003\125\004\006\023\002\120\114\061 +\050\060\046\006\003\125\004\012\014\037\113\162\141\152\157\167 +\141\040\111\172\142\141\040\122\157\172\154\151\143\172\145\156 +\151\157\167\141\040\123\056\101\056\061\030\060\026\006\003\125 +\004\003\014\017\123\132\101\106\111\122\040\122\117\117\124\040 +\103\101\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\024\076\212\135\007\354\125\322\062\325\267\343\266\137\001 +\353\055\334\344\326\344 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\003\162\060\202\002\132\240\003\002\001\002\002\024\076 +\212\135\007\354\125\322\062\325\267\343\266\137\001\353\055\334 +\344\326\344\060\015\006\011\052\206\110\206\367\015\001\001\013 +\005\000\060\121\061\013\060\011\006\003\125\004\006\023\002\120 +\114\061\050\060\046\006\003\125\004\012\014\037\113\162\141\152 +\157\167\141\040\111\172\142\141\040\122\157\172\154\151\143\172 +\145\156\151\157\167\141\040\123\056\101\056\061\030\060\026\006 +\003\125\004\003\014\017\123\132\101\106\111\122\040\122\117\117 +\124\040\103\101\062\060\036\027\015\061\065\061\060\061\071\060 +\067\064\063\063\060\132\027\015\063\065\061\060\061\071\060\067 +\064\063\063\060\132\060\121\061\013\060\011\006\003\125\004\006 +\023\002\120\114\061\050\060\046\006\003\125\004\012\014\037\113 +\162\141\152\157\167\141\040\111\172\142\141\040\122\157\172\154 +\151\143\172\145\156\151\157\167\141\040\123\056\101\056\061\030 +\060\026\006\003\125\004\003\014\017\123\132\101\106\111\122\040 +\122\117\117\124\040\103\101\062\060\202\001\042\060\015\006\011 +\052\206\110\206\367\015\001\001\001\005\000\003\202\001\017\000 +\060\202\001\012\002\202\001\001\000\267\274\076\120\250\113\315 +\100\265\316\141\347\226\312\264\241\332\014\042\260\372\265\173 +\166\000\167\214\013\317\175\250\206\314\046\121\344\040\075\205 +\014\326\130\343\347\364\052\030\235\332\321\256\046\356\353\123 +\334\364\220\326\023\112\014\220\074\303\364\332\322\216\015\222 +\072\334\261\261\377\070\336\303\272\055\137\200\271\002\275\112 +\235\033\017\264\303\302\301\147\003\335\334\033\234\075\263\260 +\336\000\036\250\064\107\273\232\353\376\013\024\275\066\204\332 +\015\040\277\372\133\313\251\026\040\255\071\140\356\057\165\266 +\347\227\234\371\076\375\176\115\157\115\057\357\210\015\152\372 +\335\361\075\156\040\245\240\022\264\115\160\271\316\327\162\073 +\211\223\247\200\204\034\047\111\162\111\265\377\073\225\236\301 +\314\310\001\354\350\016\212\012\226\347\263\246\207\345\326\371 +\005\053\015\227\100\160\074\272\254\165\132\234\325\115\235\002 +\012\322\113\233\146\113\106\007\027\145\255\237\154\210\000\334 +\042\211\340\341\144\324\147\274\061\171\141\074\273\312\101\315 +\134\152\000\310\074\070\216\130\257\002\003\001\000\001\243\102 +\060\100\060\017\006\003\125\035\023\001\001\377\004\005\060\003 +\001\001\377\060\016\006\003\125\035\017\001\001\377\004\004\003 +\002\001\006\060\035\006\003\125\035\016\004\026\004\024\056\026 +\251\112\030\265\313\314\365\157\120\363\043\137\370\135\347\254 +\360\310\060\015\006\011\052\206\110\206\367\015\001\001\013\005 +\000\003\202\001\001\000\265\163\370\003\334\131\133\035\166\351 +\243\052\173\220\050\262\115\300\063\117\252\232\261\324\270\344 +\047\377\251\226\231\316\106\340\155\174\114\242\070\244\006\160 +\360\364\101\021\354\077\107\215\077\162\207\371\073\375\244\157 +\053\123\000\340\377\071\271\152\007\016\353\035\034\366\242\162 +\220\313\202\075\021\202\213\322\273\237\052\257\041\346\143\206 +\235\171\031\357\367\273\014\065\220\303\212\355\117\017\365\314 +\022\331\244\076\273\240\374\040\225\137\117\046\057\021\043\203 +\116\165\007\017\277\233\321\264\035\351\020\004\376\312\140\217 +\242\114\270\255\317\341\220\017\315\256\012\307\135\173\267\120 +\322\324\141\372\325\025\333\327\237\207\121\124\353\245\343\353 +\311\205\240\045\040\067\373\216\316\014\064\204\341\074\201\262 +\167\116\103\245\210\137\206\147\241\075\346\264\134\141\266\076 +\333\376\267\050\305\242\007\256\265\312\312\215\052\022\357\227 +\355\302\060\244\311\052\172\373\363\115\043\033\231\063\064\240 +\056\365\251\013\077\324\135\341\317\204\237\342\031\302\137\212 +\326\040\036\343\163\267 +END + +# Trust for "SZAFIR ROOT CA2" +# Issuer: CN=SZAFIR ROOT CA2,O=Krajowa Izba Rozliczeniowa S.A.,C=PL +# Serial Number:3e:8a:5d:07:ec:55:d2:32:d5:b7:e3:b6:5f:01:eb:2d:dc:e4:d6:e4 +# Subject: CN=SZAFIR ROOT CA2,O=Krajowa Izba Rozliczeniowa S.A.,C=PL +# Not Valid Before: Mon Oct 19 07:43:30 2015 +# Not Valid After : Fri Oct 19 07:43:30 2035 +# Fingerprint (SHA-256): A1:33:9D:33:28:1A:0B:56:E5:57:D3:D3:2B:1C:E7:F9:36:7E:B0:94:BD:5F:A7:2A:7E:50:04:C8:DE:D7:CA:FE +# Fingerprint (SHA1): E2:52:FA:95:3F:ED:DB:24:60:BD:6E:28:F3:9C:CC:CF:5E:B3:3F:DE +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "SZAFIR ROOT CA2" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\342\122\372\225\077\355\333\044\140\275\156\050\363\234\314\317 +\136\263\077\336 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\021\144\301\211\260\044\261\214\261\007\176\211\236\121\236\231 +END +CKA_ISSUER MULTILINE_OCTAL +\060\121\061\013\060\011\006\003\125\004\006\023\002\120\114\061 +\050\060\046\006\003\125\004\012\014\037\113\162\141\152\157\167 +\141\040\111\172\142\141\040\122\157\172\154\151\143\172\145\156 +\151\157\167\141\040\123\056\101\056\061\030\060\026\006\003\125 +\004\003\014\017\123\132\101\106\111\122\040\122\117\117\124\040 +\103\101\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\024\076\212\135\007\354\125\322\062\325\267\343\266\137\001 +\353\055\334\344\326\344 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE + +# +# Certificate "Certum Trusted Network CA 2" +# +# Issuer: CN=Certum Trusted Network CA 2,OU=Certum Certification Authority,O=Unizeto Technologies S.A.,C=PL +# Serial Number:21:d6:d0:4a:4f:25:0f:c9:32:37:fc:aa:5e:12:8d:e9 +# Subject: CN=Certum Trusted Network CA 2,OU=Certum Certification Authority,O=Unizeto Technologies S.A.,C=PL +# Not Valid Before: Thu Oct 06 08:39:56 2011 +# Not Valid After : Sat Oct 06 08:39:56 2046 +# Fingerprint (SHA-256): B6:76:F2:ED:DA:E8:77:5C:D3:6C:B0:F6:3C:D1:D4:60:39:61:F4:9E:62:65:BA:01:3A:2F:03:07:B6:D0:B8:04 +# Fingerprint (SHA1): D3:DD:48:3E:2B:BF:4C:05:E8:AF:10:F5:FA:76:26:CF:D3:DC:30:92 +CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certum Trusted Network CA 2" +CKA_CERTIFICATE_TYPE CK_CERTIFICATE_TYPE CKC_X_509 +CKA_SUBJECT MULTILINE_OCTAL +\060\201\200\061\013\060\011\006\003\125\004\006\023\002\120\114 +\061\042\060\040\006\003\125\004\012\023\031\125\156\151\172\145 +\164\157\040\124\145\143\150\156\157\154\157\147\151\145\163\040 +\123\056\101\056\061\047\060\045\006\003\125\004\013\023\036\103 +\145\162\164\165\155\040\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\061\044\060 +\042\006\003\125\004\003\023\033\103\145\162\164\165\155\040\124 +\162\165\163\164\145\144\040\116\145\164\167\157\162\153\040\103 +\101\040\062 +END +CKA_ID UTF8 "0" +CKA_ISSUER MULTILINE_OCTAL +\060\201\200\061\013\060\011\006\003\125\004\006\023\002\120\114 +\061\042\060\040\006\003\125\004\012\023\031\125\156\151\172\145 +\164\157\040\124\145\143\150\156\157\154\157\147\151\145\163\040 +\123\056\101\056\061\047\060\045\006\003\125\004\013\023\036\103 +\145\162\164\165\155\040\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\061\044\060 +\042\006\003\125\004\003\023\033\103\145\162\164\165\155\040\124 +\162\165\163\164\145\144\040\116\145\164\167\157\162\153\040\103 +\101\040\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\041\326\320\112\117\045\017\311\062\067\374\252\136\022 +\215\351 +END +CKA_VALUE MULTILINE_OCTAL +\060\202\005\322\060\202\003\272\240\003\002\001\002\002\020\041 +\326\320\112\117\045\017\311\062\067\374\252\136\022\215\351\060 +\015\006\011\052\206\110\206\367\015\001\001\015\005\000\060\201 +\200\061\013\060\011\006\003\125\004\006\023\002\120\114\061\042 +\060\040\006\003\125\004\012\023\031\125\156\151\172\145\164\157 +\040\124\145\143\150\156\157\154\157\147\151\145\163\040\123\056 +\101\056\061\047\060\045\006\003\125\004\013\023\036\103\145\162 +\164\165\155\040\103\145\162\164\151\146\151\143\141\164\151\157 +\156\040\101\165\164\150\157\162\151\164\171\061\044\060\042\006 +\003\125\004\003\023\033\103\145\162\164\165\155\040\124\162\165 +\163\164\145\144\040\116\145\164\167\157\162\153\040\103\101\040 +\062\060\042\030\017\062\060\061\061\061\060\060\066\060\070\063 +\071\065\066\132\030\017\062\060\064\066\061\060\060\066\060\070 +\063\071\065\066\132\060\201\200\061\013\060\011\006\003\125\004 +\006\023\002\120\114\061\042\060\040\006\003\125\004\012\023\031 +\125\156\151\172\145\164\157\040\124\145\143\150\156\157\154\157 +\147\151\145\163\040\123\056\101\056\061\047\060\045\006\003\125 +\004\013\023\036\103\145\162\164\165\155\040\103\145\162\164\151 +\146\151\143\141\164\151\157\156\040\101\165\164\150\157\162\151 +\164\171\061\044\060\042\006\003\125\004\003\023\033\103\145\162 +\164\165\155\040\124\162\165\163\164\145\144\040\116\145\164\167 +\157\162\153\040\103\101\040\062\060\202\002\042\060\015\006\011 +\052\206\110\206\367\015\001\001\001\005\000\003\202\002\017\000 +\060\202\002\012\002\202\002\001\000\275\371\170\370\346\325\200 +\014\144\235\206\033\226\144\147\077\042\072\036\165\001\175\357 +\373\134\147\214\311\314\134\153\251\221\346\271\102\345\040\113 +\233\332\233\173\271\231\135\331\233\200\113\327\204\100\053\047 +\323\350\272\060\273\076\011\032\247\111\225\357\053\100\044\302 +\227\307\247\356\233\045\357\250\012\000\227\205\132\252\235\334 +\051\311\342\065\007\353\160\115\112\326\301\263\126\270\241\101 +\070\233\321\373\061\177\217\340\137\341\261\077\017\216\026\111 +\140\327\006\215\030\371\252\046\020\253\052\323\320\321\147\215 +\033\106\276\107\060\325\056\162\321\305\143\332\347\143\171\104 +\176\113\143\044\211\206\056\064\077\051\114\122\213\052\247\300 +\342\221\050\211\271\300\133\371\035\331\347\047\255\377\232\002 +\227\301\306\120\222\233\002\054\275\251\271\064\131\012\277\204 +\112\377\337\376\263\237\353\331\236\340\230\043\354\246\153\167 +\026\052\333\314\255\073\034\244\207\334\106\163\136\031\142\150 +\105\127\344\220\202\102\273\102\326\360\141\340\301\243\075\146 +\243\135\364\030\356\210\311\215\027\105\051\231\062\165\002\061 +\356\051\046\310\153\002\346\265\142\105\177\067\025\132\043\150 +\211\324\076\336\116\047\260\360\100\014\274\115\027\313\115\242 +\263\036\320\006\132\335\366\223\317\127\165\231\365\372\206\032 +\147\170\263\277\226\376\064\334\275\347\122\126\345\263\345\165 +\173\327\101\221\005\334\135\151\343\225\015\103\271\374\203\226 +\071\225\173\154\200\132\117\023\162\306\327\175\051\172\104\272 +\122\244\052\325\101\106\011\040\376\042\240\266\133\060\215\274 +\211\014\325\327\160\370\207\122\375\332\357\254\121\056\007\263 +\116\376\320\011\332\160\357\230\372\126\346\155\333\265\127\113 +\334\345\054\045\025\310\236\056\170\116\370\332\234\236\206\054 +\312\127\363\032\345\310\222\213\032\202\226\172\303\274\120\022 +\151\330\016\132\106\213\072\353\046\372\043\311\266\260\201\276 +\102\000\244\370\326\376\060\056\307\322\106\366\345\216\165\375 +\362\314\271\320\207\133\314\006\020\140\273\203\065\267\136\147 +\336\107\354\231\110\361\244\241\025\376\255\214\142\216\071\125 +\117\071\026\271\261\143\235\377\267\002\003\001\000\001\243\102 +\060\100\060\017\006\003\125\035\023\001\001\377\004\005\060\003 +\001\001\377\060\035\006\003\125\035\016\004\026\004\024\266\241 +\124\071\002\303\240\077\216\212\274\372\324\370\034\246\321\072 +\016\375\060\016\006\003\125\035\017\001\001\377\004\004\003\002 +\001\006\060\015\006\011\052\206\110\206\367\015\001\001\015\005 +\000\003\202\002\001\000\161\245\016\316\344\351\277\077\070\325 +\211\132\304\002\141\373\114\305\024\027\055\213\117\123\153\020 +\027\374\145\204\307\020\111\220\336\333\307\046\223\210\046\157 +\160\326\002\136\071\240\367\217\253\226\265\245\023\134\201\024 +\155\016\201\202\021\033\212\116\306\117\245\335\142\036\104\337 +\011\131\364\133\167\013\067\351\213\040\306\370\012\116\056\130 +\034\353\063\320\317\206\140\311\332\373\200\057\236\114\140\204 +\170\075\041\144\326\373\101\037\030\017\347\311\165\161\275\275 +\134\336\064\207\076\101\260\016\366\271\326\077\011\023\226\024 +\057\336\232\035\132\271\126\316\065\072\260\137\160\115\136\343 +\051\361\043\050\162\131\266\253\302\214\146\046\034\167\054\046 +\166\065\213\050\247\151\240\371\073\365\043\335\205\020\164\311 +\220\003\126\221\347\257\272\107\324\022\227\021\042\343\242\111 +\224\154\347\267\224\113\272\055\244\332\063\213\114\246\104\377 +\132\074\306\035\144\330\265\061\344\246\074\172\250\127\013\333 +\355\141\032\313\361\316\163\167\143\244\207\157\114\121\070\326 +\344\137\307\237\266\201\052\344\205\110\171\130\136\073\370\333 +\002\202\147\301\071\333\303\164\113\075\066\036\371\051\223\210 +\150\133\250\104\031\041\360\247\350\201\015\054\350\223\066\264 +\067\262\312\260\033\046\172\232\045\037\232\232\200\236\113\052 +\077\373\243\232\376\163\062\161\302\236\306\162\341\212\150\047 +\361\344\017\264\304\114\245\141\223\370\227\020\007\052\060\045 +\251\271\310\161\270\357\150\314\055\176\365\340\176\017\202\250 +\157\266\272\154\203\103\167\315\212\222\027\241\236\133\170\026 +\075\105\342\063\162\335\341\146\312\231\323\311\305\046\375\015 +\150\004\106\256\266\331\233\214\276\031\276\261\306\362\031\343 +\134\002\312\054\330\157\112\007\331\311\065\332\100\165\362\304 +\247\031\157\236\102\020\230\165\346\225\213\140\274\355\305\022 +\327\212\316\325\230\134\126\226\003\305\356\167\006\065\377\317 +\344\356\077\023\141\356\333\332\055\205\360\315\256\235\262\030 +\011\105\303\222\241\162\027\374\107\266\240\013\054\361\304\336 +\103\150\010\152\137\073\360\166\143\373\314\006\054\246\306\342 +\016\265\271\276\044\217 +END + +# Trust for "Certum Trusted Network CA 2" +# Issuer: CN=Certum Trusted Network CA 2,OU=Certum Certification Authority,O=Unizeto Technologies S.A.,C=PL +# Serial Number:21:d6:d0:4a:4f:25:0f:c9:32:37:fc:aa:5e:12:8d:e9 +# Subject: CN=Certum Trusted Network CA 2,OU=Certum Certification Authority,O=Unizeto Technologies S.A.,C=PL +# Not Valid Before: Thu Oct 06 08:39:56 2011 +# Not Valid After : Sat Oct 06 08:39:56 2046 +# Fingerprint (SHA-256): B6:76:F2:ED:DA:E8:77:5C:D3:6C:B0:F6:3C:D1:D4:60:39:61:F4:9E:62:65:BA:01:3A:2F:03:07:B6:D0:B8:04 +# Fingerprint (SHA1): D3:DD:48:3E:2B:BF:4C:05:E8:AF:10:F5:FA:76:26:CF:D3:DC:30:92 +CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST +CKA_TOKEN CK_BBOOL CK_TRUE +CKA_PRIVATE CK_BBOOL CK_FALSE +CKA_MODIFIABLE CK_BBOOL CK_FALSE +CKA_LABEL UTF8 "Certum Trusted Network CA 2" +CKA_CERT_SHA1_HASH MULTILINE_OCTAL +\323\335\110\076\053\277\114\005\350\257\020\365\372\166\046\317 +\323\334\060\222 +END +CKA_CERT_MD5_HASH MULTILINE_OCTAL +\155\106\236\331\045\155\010\043\133\136\164\175\036\047\333\362 +END +CKA_ISSUER MULTILINE_OCTAL +\060\201\200\061\013\060\011\006\003\125\004\006\023\002\120\114 +\061\042\060\040\006\003\125\004\012\023\031\125\156\151\172\145 +\164\157\040\124\145\143\150\156\157\154\157\147\151\145\163\040 +\123\056\101\056\061\047\060\045\006\003\125\004\013\023\036\103 +\145\162\164\165\155\040\103\145\162\164\151\146\151\143\141\164 +\151\157\156\040\101\165\164\150\157\162\151\164\171\061\044\060 +\042\006\003\125\004\003\023\033\103\145\162\164\165\155\040\124 +\162\165\163\164\145\144\040\116\145\164\167\157\162\153\040\103 +\101\040\062 +END +CKA_SERIAL_NUMBER MULTILINE_OCTAL +\002\020\041\326\320\112\117\045\017\311\062\067\374\252\136\022 +\215\351 +END +CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_EMAIL_PROTECTION CK_TRUST CKT_NSS_TRUSTED_DELEGATOR +CKA_TRUST_CODE_SIGNING CK_TRUST CKT_NSS_MUST_VERIFY_TRUST +CKA_TRUST_STEP_UP_APPROVED CK_BBOOL CK_FALSE From 1e0cede3a6d7c817474ca454dba1cd0a2b16c7f9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 12:16:49 +0200 Subject: [PATCH 159/261] crypto: update root certificates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update the list of root certificates in src/node_root_certs.h with tools/mk-ca-bundle.pl. Certificates added: - CA WoSign ECC Root - Certification Authority of WoSign G2 - Certinomis - Root CA - Certum Trusted Network CA 2 - OISTE WISeKey Global Root GB CA - SZAFIR ROOT CA2 - TURKTRUST Elektronik Sertifika Hizmet Sa?layıcısı H5 - TURKTRUST Elektronik Sertifika Hizmet Sa?layıcısı H6 Certificates removed: - A-Trust-nual-03 - Buypass Class 3 CA 1 - CA Disig - ComSign Secured CA - Equifax Secure CA - NetLock Notary (Class A) Root - Staat der Nederlanden Root CA - TC TrustCenter Class 2 CA II - TC TrustCenter Universal CA I - TURKTRUST Certificate Services Provider Root 1 - TURKTRUST Certificate Services Provider Root 2 - UTN DATACorp SGC Root CA - Verisign Class 4 Public Primary Certification Authority - G3 PR-URL: https://github.com/nodejs/node/pull/7363 Reviewed-By: Fedor Indutny Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- src/node_root_certs.h | 501 ++++++++++++++++-------------------------- 1 file changed, 189 insertions(+), 312 deletions(-) diff --git a/src/node_root_certs.h b/src/node_root_certs.h index bab6992602aa1f..cc01d8fe63e598 100644 --- a/src/node_root_certs.h +++ b/src/node_root_certs.h @@ -1,23 +1,4 @@ -/* Equifax Secure CA */ -"-----BEGIN CERTIFICATE-----\n" -"MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJVUzEQMA4G\n" -"A1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0\n" -"aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1MVowTjELMAkGA1UEBhMCVVMx\n" -"EDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVxdWlmYXggU2VjdXJlIENlcnRpZmljYXRl\n" -"IEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2R\n" -"FGiYCh7+2gRvE4RiIcPRfM6fBeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP\n" -"/PvwDN1Dulsr4R+AcJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/\n" -"FP3gx7kCAwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ\n" -"MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUg\n" -"QXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgwODIyMTY0MTUxWjAL\n" -"BgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gjIBBPM5iQn9QwHQYDVR0OBBYE\n" -"FEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQFMAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsF\n" -"VjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaS\n" -"bn+2kmOeUJXRmm/kEd5jhW6Y7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA\n" -"2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4\n" -"-----END CERTIFICATE-----\n", - /* GlobalSign Root CA */ "-----BEGIN CERTIFICATE-----\n" "MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMC\n" @@ -85,30 +66,6 @@ "t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==\n" "-----END CERTIFICATE-----\n", -/* Verisign Class 4 Public Primary Certification Authority - G3 */ -"-----BEGIN CERTIFICATE-----\n" -"MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQG\n" -"EwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0\n" -"IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv\n" -"cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1h\n" -"cnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3\n" -"MTYyMzU5NTlaMIHKMQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAd\n" -"BgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlT\n" -"aWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu\n" -"IENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCC\n" -"ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYl\n" -"S+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaStBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0\n" -"qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM8BDcVHOLBKFGMzNcF0C5nk3T875V\n" -"g+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiWLugs+BGzOA1mppvqySNb247i\n" -"8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrXRazwa2rvTl/4EYIeOGM0\n" -"ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAj/ola09b5KROJ1Wr\n" -"IhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXttmhwwjIDLk5Mq\n" -"g6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKmfjaF3H48\n" -"ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJdRTjD\n" -"OPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG\n" -"UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg==\n" -"-----END CERTIFICATE-----\n", - /* Entrust.net Premium 2048 Secure Server CA */ "-----BEGIN CERTIFICATE-----\n" "MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVz\n" @@ -653,53 +610,6 @@ "4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M\n" "-----END CERTIFICATE-----\n", -/* Staat der Nederlanden Root CA */ -"-----BEGIN CERTIFICATE-----\n" -"MIIDujCCAqKgAwIBAgIEAJiWijANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJOTDEeMBwG\n" -"A1UEChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFhdCBkZXIgTmVkZXJs\n" -"YW5kZW4gUm9vdCBDQTAeFw0wMjEyMTcwOTIzNDlaFw0xNTEyMTYwOTE1MzhaMFUxCzAJBgNV\n" -"BAYTAk5MMR4wHAYDVQQKExVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xJjAkBgNVBAMTHVN0YWF0\n" -"IGRlciBOZWRlcmxhbmRlbiBSb290IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\n" -"AQEAmNK1URF6gaYUmHFtvsznExvWJw56s2oYHLZhWtVhCb/ekBPHZ+7d89rFDBKeNVU+LCeI\n" -"QGv33N0iYfXCxw719tV2U02PjLwYdjeFnejKScfST5gTCaI+Ioicf9byEGW07l8Y1Rfj+MX9\n" -"4p2i71MOhXeiD+EwR+4A5zN9RGcaC1Hoi6CeUJhoNFIfLm0B8mBF8jHrqTFoKbt6QZ7GGX+U\n" -"tFE5A3+y3qcym7RHjm+0Sq7lr7HcsBthvJly3uSJt3omXdozSVtSnA71iq3DuD3oBmrC1SoL\n" -"bHuEvVYFy4ZlkuxEK7COudxwC0barbxjiDn622r+I/q85Ej0ZytqERAhSQIDAQABo4GRMIGO\n" -"MAwGA1UdEwQFMAMBAf8wTwYDVR0gBEgwRjBEBgRVHSAAMDwwOgYIKwYBBQUHAgEWLmh0dHA6\n" -"Ly93d3cucGtpb3ZlcmhlaWQubmwvcG9saWNpZXMvcm9vdC1wb2xpY3kwDgYDVR0PAQH/BAQD\n" -"AgEGMB0GA1UdDgQWBBSofeu8Y6R0E3QA7Jbg0zTBLL9s+DANBgkqhkiG9w0BAQUFAAOCAQEA\n" -"BYSHVXQ2YcG70dTGFagTtJ+k/rvuFbQvBgwp8qiSpGEN/KtcCFtREytNwiphyPgJWPwtArI5\n" -"fZlmgb9uXJVFIGzmeafR2Bwp/MIgJ1HI8XxdNGdphREwxgDS1/PTfLbwMVcoEoJz6TMvplW0\n" -"C5GUR5z6u3pCMuiufi3IvKwUv9kP2Vv8wfl6leF9fpb8cbDCTMjfRTTJzg3ynGQI0DvDKcWy\n" -"7ZAEwbEpkcUwb8GpcjPM/l0WFywRaed+/sWDCN+83CI6LiBpIzlWYGeQiy52OfsRiJf2fL1L\n" -"uCAWZwWN4jvBcj+UlTfHXbme2JOhF4//DGYVwSR8MnwDHTuhWEUykw==\n" -"-----END CERTIFICATE-----\n", - -/* UTN DATACorp SGC Root CA */ -"-----BEGIN CERTIFICATE-----\n" -"MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCBkzELMAkG\n" -"A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEeMBwGA1UE\n" -"ChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8vd3d3LnVzZXJ0cnVz\n" -"dC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3JwIFNHQzAeFw05OTA2MjQxODU3MjFaFw0x\n" -"OTA2MjQxOTA2MzBaMIGTMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNh\n" -"bHQgTGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsT\n" -"GGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dD\n" -"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6\n" -"E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZD0/Ww5y0\n" -"vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK4ESGoE1O1kduSUrL\n" -"Z9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykqlXvY8qdOD1R8oQ2AswkDwf9c\n" -"3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulWbfXv33i+Ybqypa4ETLyorGkVl73v67SM\n" -"vzX41MPRKA5cOp9wGDMgd8SirwIDAQABo4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8E\n" -"BTADAQH/MB0GA1UdDgQWBBRTMtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAu\n" -"hixodHRwOi8vY3JsLnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUE\n" -"IzAhBggrBgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB\n" -"AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowftGzet/Hy+\n" -"UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyjj98C5OBxOvG0I3Kg\n" -"qgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVHKWss5nbZqSl9Mt3JNjy9rjXx\n" -"EZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jF\n" -"VkwPDPafepE39peC4N1xaf92P2BNPM/3mfnGV/TJVTl4uix5yaaIK/QI\n" -"-----END CERTIFICATE-----\n", - /* UTN USERFirst Hardware Root CA */ "-----BEGIN CERTIFICATE-----\n" "MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCBlzELMAkG\n" @@ -780,41 +690,6 @@ "oHflCStFREest2d/AYoFWpO+ocH/+OcOZ6RHSXZddZAa9SaP8A==\n" "-----END CERTIFICATE-----\n", -/* NetLock Notary (Class A) Root */ -"-----BEGIN CERTIFICATE-----\n" -"MIIGfTCCBWWgAwIBAgICAQMwDQYJKoZIhvcNAQEEBQAwga8xCzAJBgNVBAYTAkhVMRAwDgYD\n" -"VQQIEwdIdW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxv\n" -"emF0Yml6dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UE\n" -"AxMtTmV0TG9jayBLb3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMB4XDTk5\n" -"MDIyNDIzMTQ0N1oXDTE5MDIxOTIzMTQ0N1owga8xCzAJBgNVBAYTAkhVMRAwDgYDVQQIEwdI\n" -"dW5nYXJ5MREwDwYDVQQHEwhCdWRhcGVzdDEnMCUGA1UEChMeTmV0TG9jayBIYWxvemF0Yml6\n" -"dG9uc2FnaSBLZnQuMRowGAYDVQQLExFUYW51c2l0dmFueWtpYWRvazE2MDQGA1UEAxMtTmV0\n" -"TG9jayBLb3pqZWd5em9pIChDbGFzcyBBKSBUYW51c2l0dmFueWtpYWRvMIIBIjANBgkqhkiG\n" -"9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvHSMD7tM9DceqQWC2ObhbHDqeLVu0ThEDaiDzl3S1tWB\n" -"xdRL51uUcCbbO51qTGL3cfNk1mE7PetzozfZz+qMkjvN9wfcZnSX9EUi3fRc4L9t875lM+QV\n" -"Or/bmJBVOMTtplVjC7B4BPTjbsE/jvxReB+SnoPC/tmwqcm8WgD/qaiYdPv2LD4VOQ22BFWo\n" -"DpggQrOxJa1+mm9dU7GrDPzr4PN6s6iz/0b2Y6LYOph7tqyF/7AlT3Rj5xMHpQqPBffAZG9+\n" -"pyeAlt7ULoZgx2srXnN7F+eRP2QM2EsiNCubMvJIH5+hCoR64sKtlz2O1cH5VqNQ6ca0+pii\n" -"7pXmKgOM3wIDAQABo4ICnzCCApswDgYDVR0PAQH/BAQDAgAGMBIGA1UdEwEB/wQIMAYBAf8C\n" -"AQQwEQYJYIZIAYb4QgEBBAQDAgAHMIICYAYJYIZIAYb4QgENBIICURaCAk1GSUdZRUxFTSEg\n" -"RXplbiB0YW51c2l0dmFueSBhIE5ldExvY2sgS2Z0LiBBbHRhbGFub3MgU3pvbGdhbHRhdGFz\n" -"aSBGZWx0ZXRlbGVpYmVuIGxlaXJ0IGVsamFyYXNvayBhbGFwamFuIGtlc3p1bHQuIEEgaGl0\n" -"ZWxlc2l0ZXMgZm9seWFtYXRhdCBhIE5ldExvY2sgS2Z0LiB0ZXJtZWtmZWxlbG9zc2VnLWJp\n" -"enRvc2l0YXNhIHZlZGkuIEEgZGlnaXRhbGlzIGFsYWlyYXMgZWxmb2dhZGFzYW5hayBmZWx0\n" -"ZXRlbGUgYXogZWxvaXJ0IGVsbGVub3J6ZXNpIGVsamFyYXMgbWVndGV0ZWxlLiBBeiBlbGph\n" -"cmFzIGxlaXJhc2EgbWVndGFsYWxoYXRvIGEgTmV0TG9jayBLZnQuIEludGVybmV0IGhvbmxh\n" -"cGphbiBhIGh0dHBzOi8vd3d3Lm5ldGxvY2submV0L2RvY3MgY2ltZW4gdmFneSBrZXJoZXRv\n" -"IGF6IGVsbGVub3J6ZXNAbmV0bG9jay5uZXQgZS1tYWlsIGNpbWVuLiBJTVBPUlRBTlQhIFRo\n" -"ZSBpc3N1YW5jZSBhbmQgdGhlIHVzZSBvZiB0aGlzIGNlcnRpZmljYXRlIGlzIHN1YmplY3Qg\n" -"dG8gdGhlIE5ldExvY2sgQ1BTIGF2YWlsYWJsZSBhdCBodHRwczovL3d3dy5uZXRsb2NrLm5l\n" -"dC9kb2NzIG9yIGJ5IGUtbWFpbCBhdCBjcHNAbmV0bG9jay5uZXQuMA0GCSqGSIb3DQEBBAUA\n" -"A4IBAQBIJEb3ulZv+sgoA0BO5TE5ayZrU3/b39/zcT0mwBQOxmd7I6gMc90Bu8bKbjc5VdXH\n" -"jFYgDigKDtIqpLBJUsY4B/6+CgmM0ZjPytoUMaFP0jn8DxEsQ8Pdq5PHVT5HfBgaANzze9jy\n" -"f1JsIPQLX2lS9O74silg6+NJMSEN1rUQQeJBCWziGppWS3cC9qCbmieH6FUpccKQn0V4GuEV\n" -"ZD3QDtigdp+uxdAu6tYPVuxkf1qbFFgBJ34TUMdrKuZoPL9coAob4Q566eKAw+np9v1sEZ7Q\n" -"5SgnK1QyQhSCdeZK8CtmdWOMovsEPoMOmzbwGOQmIMOM8CgHrTwXZoi1/baI\n" -"-----END CERTIFICATE-----\n", - /* XRamp Global CA Root */ "-----BEGIN CERTIFICATE-----\n" "MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkG\n" @@ -1121,54 +996,6 @@ "oKfN5XozNmr6mis=\n" "-----END CERTIFICATE-----\n", -/* TURKTRUST Certificate Services Provider Root 1 */ -"-----BEGIN CERTIFICATE-----\n" -"MIID+zCCAuOgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBtzE/MD0GA1UEAww2VMOcUktUUlVT\n" -"VCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQG\n" -"DAJUUjEPMA0GA1UEBwwGQU5LQVJBMVYwVAYDVQQKDE0oYykgMjAwNSBUw5xSS1RSVVNUIEJp\n" -"bGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWe\n" -"LjAeFw0wNTA1MTMxMDI3MTdaFw0xNTAzMjIxMDI3MTdaMIG3MT8wPQYDVQQDDDZUw5xSS1RS\n" -"VVNUIEVsZWt0cm9uaWsgU2VydGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLExCzAJBgNV\n" -"BAYMAlRSMQ8wDQYDVQQHDAZBTktBUkExVjBUBgNVBAoMTShjKSAyMDA1IFTDnFJLVFJVU1Qg\n" -"QmlsZ2kgxLBsZXRpxZ9pbSB2ZSBCaWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEu\n" -"xZ4uMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylIF1mMD2Bxf3dJ7XfIMYGFb\n" -"azt0K3gNfUW9InTojAPBxhEqPZW8qZSwu5GXyGl8hMW0kWxsE2qkVa2kheiVfrMArwDCBRj1\n" -"cJ02i67L5BuBf5OI+2pVu32Fks66WJ/bMsW9Xe8iSi9BB35JYbOG7E6mQW6EvAPs9TscyB/C\n" -"7qju6hJKjRTP8wrgUDn5CDX4EVmt5yLqS8oUBt5CurKZ8y1UiBAG6uEaPj1nH/vO+3yC6BFd\n" -"SsG5FOpU2WabfIl9BJpiyelSPJ6c79L1JuTm5Rh8i27fbMx4W09ysstcP4wFjdFMjK2Sx+F4\n" -"f2VsSQZQLJ4ywtdKxnWKWU51b0dewQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3\n" -"DQEBBQUAA4IBAQAV9VX/N5aAWSGk/KEVTCD21F/aAyT8z5Aa9CEKmu46sWrv7/hg0Uw2ZkUd\n" -"82YCdAR7kjCo3gp2D++Vbr3JN+YaDayJSFvMgzbC9UZcWYJWtNX+I7TYVBxEq8Sn5RTOPEFh\n" -"fEPmzcSBCYsk+1Ql1haolgxnB2+zUEfjHCQo3SqYpGH+2+oSN7wBGjSFvW5P55FyB0SFHljK\n" -"VETd96y5y4khctuPwGkplyqjrhgjlxxBKot8KsF8kOipKMDTkcatKIdAaLX/7KfS0zgYnNN9\n" -"aV3wxqUeJBujR/xpB2jn5Jq07Q+hh4cCzofSSE7hvP/L8XKSRGQDJereW26fyfJOrN3H\n" -"-----END CERTIFICATE-----\n", - -/* TURKTRUST Certificate Services Provider Root 2 */ -"-----BEGIN CERTIFICATE-----\n" -"MIIEPDCCAySgAwIBAgIBATANBgkqhkiG9w0BAQUFADCBvjE/MD0GA1UEAww2VMOcUktUUlVT\n" -"VCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxMQswCQYDVQQG\n" -"EwJUUjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJpbGdpIMSwbGV0\n" -"acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLiAoYykgS2Fz\n" -"xLFtIDIwMDUwHhcNMDUxMTA3MTAwNzU3WhcNMTUwOTE2MTAwNzU3WjCBvjE/MD0GA1UEAww2\n" -"VMOcUktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8Sx\n" -"MQswCQYDVQQGEwJUUjEPMA0GA1UEBwwGQW5rYXJhMV0wWwYDVQQKDFRUw5xSS1RSVVNUIEJp\n" -"bGdpIMSwbGV0acWfaW0gdmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWe\n" -"LiAoYykgS2FzxLFtIDIwMDUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpNn7D\n" -"kUNMwxmYCMjHWHtPFoylzkkBH3MOrHUTpvqeLCDe2JAOCtFp0if7qnefJ1Il4std2NiDUBd9\n" -"irWCPwSOtNXwSadktx4uXyCcUHVPr+G1QRT0mJKIx+XlZEdhR3n9wFHxwZnn3M5q+6+1ATDc\n" -"RhzviuyV79z/rxAc653YsKpqhRgNF8k+v/Gb0AmJQv2gQrSdiVFVKc8bcLyEVK3BEx+Y9C52\n" -"YItdP5qtygy/p1Zbj3e41Z55SZI/4PGXJHpsmxcPbe9TmJEr5A++WXkHeLuXlfSfadRYhwqp\n" -"48y2WBmfJiGxxFmNskF1wK1pzpwACPI2/z7woQ8arBT9pmAPAgMBAAGjQzBBMB0GA1UdDgQW\n" -"BBTZN7NOBf3Zz58SFq62iS/rJTqIHDAPBgNVHQ8BAf8EBQMDBwYAMA8GA1UdEwEB/wQFMAMB\n" -"Af8wDQYJKoZIhvcNAQEFBQADggEBAHJglrfJ3NgpXiOFX7KzLXb7iNcX/nttRbj2hWyfIvwq\n" -"ECLsqrkw9qtY1jkQMZkpAL2JZkH7dN6RwRgLn7Vhy506vvWolKMiVW4XSf/SKfE4Jl3vpao6\n" -"+XF75tpYHdN0wgH6PmlYX63LaL4ULptswLbcoCb6dxriJNoaN+BnrdFzgw2lGh1uEpJ+hGIA\n" -"F728JRhX8tepb1mIvDS3LoV4nZbcFMMsilKbloxSZj2GFotHuFEJjOp9zYhys2AzsfAKRO8P\n" -"9Qk3iCQOLGsgOqL6EfJANZxEaGM7rDNvY7wsu/LSy3Z9fYjYHcgFHW68lKlmjHdxx/qR+i9R\n" -"nuk5UrbnBEI=\n" -"-----END CERTIFICATE-----\n", - /* SwissSign Gold CA - G2 */ "-----BEGIN CERTIFICATE-----\n" "MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNI\n" @@ -1571,56 +1398,6 @@ "vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==\n" "-----END CERTIFICATE-----\n", -/* TC TrustCenter Class 2 CA II */ -"-----BEGIN CERTIFICATE-----\n" -"MIIEqjCCA5KgAwIBAgIOLmoAAQACH9dSISwRXDswDQYJKoZIhvcNAQEFBQAwdjELMAkGA1UE\n" -"BhMCREUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxIjAgBgNVBAsTGVRDIFRydXN0\n" -"Q2VudGVyIENsYXNzIDIgQ0ExJTAjBgNVBAMTHFRDIFRydXN0Q2VudGVyIENsYXNzIDIgQ0Eg\n" -"SUkwHhcNMDYwMTEyMTQzODQzWhcNMjUxMjMxMjI1OTU5WjB2MQswCQYDVQQGEwJERTEcMBoG\n" -"A1UEChMTVEMgVHJ1c3RDZW50ZXIgR21iSDEiMCAGA1UECxMZVEMgVHJ1c3RDZW50ZXIgQ2xh\n" -"c3MgMiBDQTElMCMGA1UEAxMcVEMgVHJ1c3RDZW50ZXIgQ2xhc3MgMiBDQSBJSTCCASIwDQYJ\n" -"KoZIhvcNAQEBBQADggEPADCCAQoCggEBAKuAh5uO8MN8h9foJIIRszzdQ2Lu+MNF2ujhoF/R\n" -"KrLqk2jftMjWQ+nEdVl//OEd+DFwIxuInie5e/060smp6RQvkL4DUsFJzfb95AhmC1eKokKg\n" -"uNV/aVyQMrKXDcpK3EY+AlWJU+MaWss2xgdW94zPEfRMuzBwBJWl9jmM/XOBCH2JXjIeIqki\n" -"RUuwZi4wzJ9l/fzLganx4Duvo4bRierERXlQXa7pIXSSTYtZgo+U4+lK8edJsBTj9WLL1XK9\n" -"H7nSn6DNqPoByNkN39r8R52zyFTfSUrxIan+GE7uSNQZu+995OKdy1u2bv/jzVrndIIFuoAl\n" -"OMvkaZ6vQaoahPUCAwEAAaOCATQwggEwMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD\n" -"AgEGMB0GA1UdDgQWBBTjq1RMgKHbVkO3kUrL84J6E1wIqzCB7QYDVR0fBIHlMIHiMIHfoIHc\n" -"oIHZhjVodHRwOi8vd3d3LnRydXN0Y2VudGVyLmRlL2NybC92Mi90Y19jbGFzc18yX2NhX0lJ\n" -"LmNybIaBn2xkYXA6Ly93d3cudHJ1c3RjZW50ZXIuZGUvQ049VEMlMjBUcnVzdENlbnRlciUy\n" -"MENsYXNzJTIwMiUyMENBJTIwSUksTz1UQyUyMFRydXN0Q2VudGVyJTIwR21iSCxPVT1yb290\n" -"Y2VydHMsREM9dHJ1c3RjZW50ZXIsREM9ZGU/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdD9i\n" -"YXNlPzANBgkqhkiG9w0BAQUFAAOCAQEAjNfffu4bgBCzg/XbEeprS6iSGNn3Bzn1LL4GdXpo\n" -"UxUc6krtXvwjshOg0wn/9vYua0Fxec3ibf2uWWuFHbhOIprtZjluS5TmVfwLG4t3wVMTZonZ\n" -"KNaL80VKY7f9ewthXbhtvsPcW3nS7Yblok2+XnR8au0WOB9/WIFaGusyiC2y8zl3gK9etmF1\n" -"KdsjTYjKUCjLhdLTEKJZbtOTVAB6okaVhgWcqRmY5TFyDADiZ9lA4CQze28suVyrZZ0srHbq\n" -"NZn1l7kPJOzHdiEoZa5X6AeIdUpWoNIFOqTmjZKILPPy4cHGYdtBxceb9w4aUUXCYWvcZCcX\n" -"jFq32nQozZfkvQ==\n" -"-----END CERTIFICATE-----\n", - -/* TC TrustCenter Universal CA I */ -"-----BEGIN CERTIFICATE-----\n" -"MIID3TCCAsWgAwIBAgIOHaIAAQAC7LdggHiNtgYwDQYJKoZIhvcNAQEFBQAweTELMAkGA1UE\n" -"BhMCREUxHDAaBgNVBAoTE1RDIFRydXN0Q2VudGVyIEdtYkgxJDAiBgNVBAsTG1RDIFRydXN0\n" -"Q2VudGVyIFVuaXZlcnNhbCBDQTEmMCQGA1UEAxMdVEMgVHJ1c3RDZW50ZXIgVW5pdmVyc2Fs\n" -"IENBIEkwHhcNMDYwMzIyMTU1NDI4WhcNMjUxMjMxMjI1OTU5WjB5MQswCQYDVQQGEwJERTEc\n" -"MBoGA1UEChMTVEMgVHJ1c3RDZW50ZXIgR21iSDEkMCIGA1UECxMbVEMgVHJ1c3RDZW50ZXIg\n" -"VW5pdmVyc2FsIENBMSYwJAYDVQQDEx1UQyBUcnVzdENlbnRlciBVbml2ZXJzYWwgQ0EgSTCC\n" -"ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKR3I5ZEr5D0MacQ9CaHnPM42Q9e3s9B\n" -"6DGtxnSRJJZ4Hgmgm5qVSkr1YnwCqMqs+1oEdjneX/H5s7/zA1hV0qq34wQi0fiU2iIIAI3T\n" -"fCZdzHd55yx4Oagmcw6iXSVphU9VDprvxrlE4Vc93x9UIuVvZaozhDrzznq+VZeujRIPFDPi\n" -"UHDDSYcTvFHe15gSWu86gzOSBnWLknwSaHtwag+1m7Z3W0hZneTvWq3zwZ7U10VOylY0Ibw+\n" -"F1tvdwxIAUMpsN0/lm7mlaoMwCC2/T42J5zjXM9OgdwZu5GQfezmlwQek8wiSdeXhrYTCjxD\n" -"I3d+8NzmzSQfO4ObNDqDNOMCAwEAAaNjMGEwHwYDVR0jBBgwFoAUkqR1LKSevoFE63n8isWV\n" -"pesQdXMwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFJKkdSyk\n" -"nr6BROt5/IrFlaXrEHVzMA0GCSqGSIb3DQEBBQUAA4IBAQAo0uCG1eb4e/CX3CJrO5UUVg8R\n" -"MKWaTzqwOuAGy2X17caXJ/4l8lfmXpWMPmRgFVp/Lw0BxbFg/UU1z/CyvwbZ71q+s2IhtNer\n" -"NXxTPqYn8aEt2hojnczd7Dwtnic0XQ/CNnm8yUpiLe1r2X1BQ3y2qsrtYbE3ghUJGooWMNjs\n" -"ydZHcnhLEEYUjl8Or+zHL6sQ17bxbuyGssLoDZJz3KL0Dzq/YSMQiZxIQG5wALPTujdEWBF6\n" -"AmqI8Dc08BnprNRlc/ZpjGSUOnmFKbAWKwyCPwacx/0QK54PLLae4xW/2TYcuiUaUj0a7CIM\n" -"HOCkoj3w6DnPgcB77V0fb8XQC9eY\n" -"-----END CERTIFICATE-----\n", - /* Deutsche Telekom Root CA 2 */ "-----BEGIN CERTIFICATE-----\n" "MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEcMBoGA1UE\n" @@ -1643,28 +1420,6 @@ "hpLzGITY+9HPBVZkVw==\n" "-----END CERTIFICATE-----\n", -/* ComSign Secured CA */ -"-----BEGIN CERTIFICATE-----\n" -"MIIDqzCCApOgAwIBAgIRAMcoRwmzuGxFjB36JPU2TukwDQYJKoZIhvcNAQEFBQAwPDEbMBkG\n" -"A1UEAxMSQ29tU2lnbiBTZWN1cmVkIENBMRAwDgYDVQQKEwdDb21TaWduMQswCQYDVQQGEwJJ\n" -"TDAeFw0wNDAzMjQxMTM3MjBaFw0yOTAzMTYxNTA0NTZaMDwxGzAZBgNVBAMTEkNvbVNpZ24g\n" -"U2VjdXJlZCBDQTEQMA4GA1UEChMHQ29tU2lnbjELMAkGA1UEBhMCSUwwggEiMA0GCSqGSIb3\n" -"DQEBAQUAA4IBDwAwggEKAoIBAQDGtWhfHZQVw6QIVS3joFd67+l0Kru5fFdJGhFeTymHDEjW\n" -"aueP1H5XJLkGieQcPOqs49ohgHMhCu95mGwfCP+hUH3ymBvJVG8+pSjsIQQPRbsHPaHA+iqY\n" -"HU4Gk/v1iDurX8sWv+bznkqH7Rnqwp9D5PGBpX8QTz7RSmKtUxvLg/8HZaWSLWapW7ha9B20\n" -"IZFKF3ueMv5WJDmyVIRD9YTC2LxBkMyd1mja6YJQqTtoz7VdApRgFrFD2UNd3V2Hbuq7s8lr\n" -"9gOUCXDeFhF6K+h2j0kQmHe5Y1yLM5d19guMsqtb3nQgJT/j8xH5h2iGNXHDHYwt6+UarA9z\n" -"1YJZQIDTAgMBAAGjgacwgaQwDAYDVR0TBAUwAwEB/zBEBgNVHR8EPTA7MDmgN6A1hjNodHRw\n" -"Oi8vZmVkaXIuY29tc2lnbi5jby5pbC9jcmwvQ29tU2lnblNlY3VyZWRDQS5jcmwwDgYDVR0P\n" -"AQH/BAQDAgGGMB8GA1UdIwQYMBaAFMFL7XC29z58ADsAj8c+DkWfHl3sMB0GA1UdDgQWBBTB\n" -"S+1wtvc+fAA7AI/HPg5Fnx5d7DANBgkqhkiG9w0BAQUFAAOCAQEAFs/ukhNQq3sUnjO2QiBq\n" -"1BW9Cav8cujvR3qQrFHBZE7piL1DRYHjZiM/EoZNGeQFsOY3wo3aBijJD4mkU6l1P7CW+6tM\n" -"M1X5eCZGbxs2mPtCdsGCuY7e+0X5YxtiOzkGynd6qDwJz2w2PQ8KRUtpFhpFfTMDZflScZAm\n" -"laxMDPWLkz/MdXSFmLr/YnpNH4n+rr2UAJm/EaXc4HnFFgt9AmEd6oX5AhVP51qJThRv4zdL\n" -"hfXBPGHg/QVBspJ/wx2g0K5SZGBrGMYmnNj1ZOQ2GmKfig8+/21OGVZOIJFsnzQzOjRXUDpv\n" -"gV4GxvU+fE6OK85lBi5d0ipTdF7Tbieejw==\n" -"-----END CERTIFICATE-----\n", - /* Cybertrust Global Root */ "-----BEGIN CERTIFICATE-----\n" "MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMP\n" @@ -1768,26 +1523,6 @@ "RxKaJyOkLY4ng5IgodcVf/EuGO70SH8vf/GhGLWhC5SgYiAynB321O+/TIho\n" "-----END CERTIFICATE-----\n", -/* Buypass Class 3 CA 1 */ -"-----BEGIN CERTIFICATE-----\n" -"MIIDUzCCAjugAwIBAgIBAjANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJOTzEdMBsGA1UE\n" -"CgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMyBDQSAx\n" -"MB4XDTA1MDUwOTE0MTMwM1oXDTE1MDUwOTE0MTMwM1owSzELMAkGA1UEBhMCTk8xHTAbBgNV\n" -"BAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MR0wGwYDVQQDDBRCdXlwYXNzIENsYXNzIDMgQ0Eg\n" -"MTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKSO13TZKWTeXx+HgJHqTjnmGcZE\n" -"C4DVC69TB4sSveZn8AKxifZgisRbsELRwCGoy+Gb72RRtqfPFfV0gGgEkKBYouZ0plNTVUhj\n" -"P5JW3SROjvi6K//zNIqeKNc0n6wv1g/xpC+9UrJJhW05NfBEMJNGJPO251P7vGGvqaMU+8IX\n" -"F4Rs4HyI+MkcVyzwPX6UvCWThOiaAJpFBUJXgPROztmuOfbIUxAMZTpHe2DC1vqRycZxbL2R\n" -"hzyRhkmr8w+gbCZ2Xhysm3HljbybIR6c1jh+JIAVMYKWsUnTYjdbiAwKYjT+p0h+mbEwi5A3\n" -"lRyoH6UsjfRVyNvdWQrCrXig9IsCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E\n" -"FgQUOBTmyPCppAP0Tj4io1vy1uCtQHQwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUA\n" -"A4IBAQABZ6OMySU9E2NdFm/soT4JXJEVKirZgCFPBdy7pYmrEzMqnji3jG8CcmPHc3ceCQa6\n" -"Oyh7pEfJYWsICCD8igWKH7y6xsL+z27sEzNxZy5p+qksP2bAEllNC1QCkoS72xLvg3BweMhT\n" -"+t/Gxv/ciC8HwEmdMldg0/L2mSlf56oBzKwzqBwKu5HEA6BvtjT5htOzdlSY9EqBs1OdTUDs\n" -"5XcTRa9bqh/YL0yCe/4qxFi7T/ye/QNlGioOw6UgFpRreaaiErS7GqQjel/wroQk5PMr+4ok\n" -"oyeYZdowdXb8GZHo2+ubPzK/QJcHJrrM85SFSnonk8+QQtS4Wxam58tAA915\n" -"-----END CERTIFICATE-----\n", - /* EBG Elektronik Sertifika Hizmet Sa\xC4\x9Flay\xc4\xb1\x63\xc4\xb1s\xc4\xb1 */ "-----BEGIN CERTIFICATE-----\n" "MIIF5zCCA8+gAwIBAgIITK9zQhyOdAIwDQYJKoZIhvcNAQEFBQAwgYAxODA2BgNVBAMML0VC\n" @@ -2068,30 +1803,6 @@ "nR7SUqTMHW+wmG2UMbX4cQrcufx9MmDm66+KAQ==\n" "-----END CERTIFICATE-----\n", -/* CA Disig */ -"-----BEGIN CERTIFICATE-----\n" -"MIIEDzCCAvegAwIBAgIBATANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQGEwJTSzETMBEGA1UE\n" -"BxMKQnJhdGlzbGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcw\n" -"HhcNMDYwMzIyMDEzOTM0WhcNMTYwMzIyMDEzOTM0WjBKMQswCQYDVQQGEwJTSzETMBEGA1UE\n" -"BxMKQnJhdGlzbGF2YTETMBEGA1UEChMKRGlzaWcgYS5zLjERMA8GA1UEAxMIQ0EgRGlzaWcw\n" -"ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCS9jHBfYj9mQGp2HvycXXxMcbzdWb6\n" -"UShGhJd4NLxs/LxFWYgmGErENx+hSkS943EE9UQX4j/8SFhvXJ56CbpRNyIjZkMhsDxkovhq\n" -"FQ4/61HhVKndBpnXmjxUizkDPw/Fzsbrg3ICqB9x8y34dQjbYkzo+s7552oftms1grrijxaS\n" -"fQUMbEYDXcDtab86wYqg6I7ZuUUohwjstMoVvoLdtUSLLa2GDGhibYVW8qwUYzrG0ZmsNHhW\n" -"S8+2rT+MitcE5eN4TPWGqvWP+j1scaMtymfraHtuM6kMgiioTGohQBUgDCZbg8KpFhXAJIJd\n" -"KxatymP2dACw30PEEGBWZ2NFAgMBAAGjgf8wgfwwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E\n" -"FgQUjbJJaJ1yCCW5wCf1UJNWSEZx+Y8wDgYDVR0PAQH/BAQDAgEGMDYGA1UdEQQvMC2BE2Nh\n" -"b3BlcmF0b3JAZGlzaWcuc2uGFmh0dHA6Ly93d3cuZGlzaWcuc2svY2EwZgYDVR0fBF8wXTAt\n" -"oCugKYYnaHR0cDovL3d3dy5kaXNpZy5zay9jYS9jcmwvY2FfZGlzaWcuY3JsMCygKqAohiZo\n" -"dHRwOi8vY2EuZGlzaWcuc2svY2EvY3JsL2NhX2Rpc2lnLmNybDAaBgNVHSAEEzARMA8GDSuB\n" -"HpGT5goAAAABAQEwDQYJKoZIhvcNAQEFBQADggEBAF00dGFMrzvY/59tWDYcPQuBDRIrRhCA\n" -"/ec8J9B6yKm2fnQwM6M6int0wHl5QpNt/7EpFIKrIYwvF/k/Ji/1WcbvgAa3mkkp7M5+cTxq\n" -"EEHA9tOasnxakZzArFvITV734VP/Q3f8nktnbNfzg9Gg4H8l37iYC5oyOGwwoPP/CBUz91BK\n" -"ez6jPiCp3C9WgArtQVCwyfTssuMmRAAOb54GvCKWU3BlxFAKRmukLyeBEicTXxChds6Kezfq\n" -"wzlhA5WYOudsiCUI/HloDYd9Yvi0X/vF2Ey9WLw/Q1vUHgFNPGO+I++MzVpQuGhU+QqZMxEA\n" -"4Z7CRneC9VkGjCFMhwnN5ag=\n" -"-----END CERTIFICATE-----\n", - /* Juur-SK */ "-----BEGIN CERTIFICATE-----\n" "MIIE5jCCA86gAwIBAgIEO45L/DANBgkqhkiG9w0BAQUFADBdMRgwFgYJKoZIhvcNAQkBFglw\n" @@ -2623,29 +2334,6 @@ "n7fofMM=\n" "-----END CERTIFICATE-----\n", -/* A-Trust-nQual-03 */ -"-----BEGIN CERTIFICATE-----\n" -"MIIDzzCCAregAwIBAgIDAWweMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYDVQQGEwJBVDFIMEYG\n" -"A1UECgw/QS1UcnVzdCBHZXMuIGYuIFNpY2hlcmhlaXRzc3lzdGVtZSBpbSBlbGVrdHIuIERh\n" -"dGVudmVya2VociBHbWJIMRkwFwYDVQQLDBBBLVRydXN0LW5RdWFsLTAzMRkwFwYDVQQDDBBB\n" -"LVRydXN0LW5RdWFsLTAzMB4XDTA1MDgxNzIyMDAwMFoXDTE1MDgxNzIyMDAwMFowgY0xCzAJ\n" -"BgNVBAYTAkFUMUgwRgYDVQQKDD9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1l\n" -"IGltIGVsZWt0ci4gRGF0ZW52ZXJrZWhyIEdtYkgxGTAXBgNVBAsMEEEtVHJ1c3QtblF1YWwt\n" -"MDMxGTAXBgNVBAMMEEEtVHJ1c3QtblF1YWwtMDMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw\n" -"ggEKAoIBAQCtPWFuA/OQO8BBC4SAzewqo51ru27CQoT3URThoKgtUaNR8t4j8DRE/5TrzAUj\n" -"lUC5B3ilJfYKvUWG6Nm9wASOhURh73+nyfrBJcyFLGM/BWBzSQXgYHiVEEvc+RFZznF/QJuK\n" -"qiTfC0Li21a8StKlDJu3Qz7dg9MmEALP6iPESU7l0+m0iKsMrmKS1GWH2WrX9IWf5DMiJaXl\n" -"yDO6w8dB3F/GaswADm0yqLaHNgBid5seHzTLkDx4iHQF63n1k3Flyp3HaxgtPVxO59X4PzF9\n" -"j4fsCiIvI+n+u33J4PTs63zEsMMtYrWacdaxaujs2e3Vcuy+VwHOBVWf3tFgiBCzAgMBAAGj\n" -"NjA0MA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0OBAoECERqlWdVeRFPMA4GA1UdDwEB/wQEAwIB\n" -"BjANBgkqhkiG9w0BAQUFAAOCAQEAVdRU0VlIXLOThaq/Yy/kgM40ozRiPvbY7meIMQQDbwvU\n" -"B/tOdQ/TLtPAF8fGKOwGDREkDg6lXb+MshOWcdzUzg4NCmgybLlBMRmrsQd7TZjTXLDR8KdC\n" -"oLXEjq/+8T/0709GAHbrAvv5ndJAlseIOrifEXnzgGWovR/TeIGgUUw3tKZdJXDRZslo+S4R\n" -"FGjxVJgIrCaSD96JntT6s3kr0qN51OyLrIdTaEJMUVF0HhsnLuP1Hyl0Te2v9+GSmYHovjrH\n" -"F1D2t8b8m7CKa9aIA5GPBnc6hQLdmNVDeD/GMBWsm2vLV7eJUYs66MmEDNuxUCAKGkq6ahq9\n" -"7BvIxYSazQ==\n" -"-----END CERTIFICATE-----\n", - /* TWCA Root Certification Authority */ "-----BEGIN CERTIFICATE-----\n" "MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UE\n" @@ -3976,3 +3664,192 @@ "2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UC\n" "Kc2Jo5YPSjXnTkLAdc0Hz+Ys63su\n" "-----END CERTIFICATE-----\n", + +/* TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H5 */ +"-----BEGIN CERTIFICATE-----\n" +"MIIEJzCCAw+gAwIBAgIHAI4X/iQggTANBgkqhkiG9w0BAQsFADCBsTELMAkGA1UEBhMCVFIx\n" +"DzANBgNVBAcMBkFua2FyYTFNMEsGA1UECgxEVMOcUktUUlVTVCBCaWxnaSDEsGxldGnFn2lt\n" +"IHZlIEJpbGnFn2ltIEfDvHZlbmxpxJ9pIEhpem1ldGxlcmkgQS7Fni4xQjBABgNVBAMMOVTD\n" +"nFJLVFJVU1QgRWxla3Ryb25payBTZXJ0aWZpa2EgSGl6bWV0IFNhxJ9sYXnEsWPEsXPEsSBI\n" +"NTAeFw0xMzA0MzAwODA3MDFaFw0yMzA0MjgwODA3MDFaMIGxMQswCQYDVQQGEwJUUjEPMA0G\n" +"A1UEBwwGQW5rYXJhMU0wSwYDVQQKDERUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0gdmUg\n" +"QmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjFCMEAGA1UEAww5VMOcUktU\n" +"UlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIEg1MIIB\n" +"IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApCUZ4WWe60ghUEoI5RHwWrom/4NZzkQq\n" +"L/7hzmAD/I0Dpe3/a6i6zDQGn1k19uwsu537jVJp45wnEFPzpALFp/kRGml1bsMdi9GYjZOH\n" +"p3GXDSHHmflS0yxjXVW86B8BSLlg/kJK9siArs1mep5Fimh34khon6La8eHBEJ/rPCmBp+Ey\n" +"CNSgBbGM+42WAA4+Jd9ThiI7/PS98wl+d+yG6w8z5UNP9FR1bSmZLmZaQ9/LXMrI5Tjxfjs1\n" +"nQ/0xVqhzPMggCTTV+wVunUlm+hkS7M0hO8EuPbJbKoCPrZV4jI3X/xml1/N1p7HIL9Nxqw/\n" +"dV8c7TKcfGkAaZHjIxhT6QIDAQABo0IwQDAdBgNVHQ4EFgQUVpkHHtOsDGlktAxQR95DLL4g\n" +"wPswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB\n" +"AJ5FdnsXSDLyOIspve6WSk6BGLFRRyDN0GSxDsnZAdkJzsiZ3GglE9Rc8qPoBP5yCccLqh0l\n" +"VX6Wmle3usURehnmp349hQ71+S4pL+f5bFgWV1Al9j4uPqrtd3GqqpmWRgqujuwqURawXs3q\n" +"ZwQcWDD1YIq9pr1N5Za0/EKJAWv2cMhQOQwt1WbZyNKzMrcbGW3LM/nfpeYVhDfwwvJllpKQ\n" +"d/Ct9JDpEXjXk4nAPQu6KfTomZ1yju2dL+6SfaHx/126M2CFYv4HAqGEVka+lgqaE9chTLd8\n" +"B59OTj+RdPsnnRHM3eaxynFNExc5JsUpISuTKWqW+qtB4Uu2NQvAmxU=\n" +"-----END CERTIFICATE-----\n", + +/* TÜRKTRUST Elektronik Sertifika Hizmet Sağlayıcısı H6 */ +"-----BEGIN CERTIFICATE-----\n" +"MIIEJjCCAw6gAwIBAgIGfaHyZeyKMA0GCSqGSIb3DQEBCwUAMIGxMQswCQYDVQQGEwJUUjEP\n" +"MA0GA1UEBwwGQW5rYXJhMU0wSwYDVQQKDERUw5xSS1RSVVNUIEJpbGdpIMSwbGV0acWfaW0g\n" +"dmUgQmlsacWfaW0gR8O8dmVubGnEn2kgSGl6bWV0bGVyaSBBLsWeLjFCMEAGA1UEAww5VMOc\n" +"UktUUlVTVCBFbGVrdHJvbmlrIFNlcnRpZmlrYSBIaXptZXQgU2HEn2xhecSxY8Sxc8SxIEg2\n" +"MB4XDTEzMTIxODA5MDQxMFoXDTIzMTIxNjA5MDQxMFowgbExCzAJBgNVBAYTAlRSMQ8wDQYD\n" +"VQQHDAZBbmthcmExTTBLBgNVBAoMRFTDnFJLVFJVU1QgQmlsZ2kgxLBsZXRpxZ9pbSB2ZSBC\n" +"aWxpxZ9pbSBHw7x2ZW5sacSfaSBIaXptZXRsZXJpIEEuxZ4uMUIwQAYDVQQDDDlUw5xSS1RS\n" +"VVNUIEVsZWt0cm9uaWsgU2VydGlmaWthIEhpem1ldCBTYcSfbGF5xLFjxLFzxLEgSDYwggEi\n" +"MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCdsGjW6L0UlqMACprx9MfMkU1xeHe59yEm\n" +"FXNRFpQJRwXiM/VomjX/3EsvMsew7eKC5W/a2uqsxgbPJQ1BgfbBOCK9+bGlprMBvD9QFyv2\n" +"6WZV1DOzXPhDIHiTVRZwGTLmiddk671IUP320EEDwnS3/faAz1vFq6TWlRKb55cTMgPp1KtD\n" +"WxbtMyJkKbbSk60vbNg9tvYdDjTu0n2pVQ8g9P0pu5FbHH3GQjhtQiht1AH7zYiXSX6484P4\n" +"tZgvsycLSF5W506jM7NE1qXyGJTtHB6plVxiSvgNZ1GpryHV+DKdeboaX+UEVU0TRv/yz3TH\n" +"GmNtwx8XEsMeED5gCLMxAgMBAAGjQjBAMB0GA1UdDgQWBBTdVRcT9qzoSCHK77Wv0QAy7Z6M\n" +"tTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA\n" +"b1gNl0OqFlQ+v6nfkkU/hQu7VtMMUszIv3ZnXuaqs6fvuay0EBQNdH49ba3RfdCaqaXKGDsC\n" +"QC4qnFAUi/5XfldcEQlLNkVS9z2sFP1E34uXI9TDwe7UU5X+LEr+DXCqu4svLcsyo4LyVN/Y\n" +"8t3XSHLuSqMplsNEzm61kod2pLv0kmzOLBQJZo6NrRa1xxsJYTvjIKIDgI6tflEATseWhvtD\n" +"mHd9KMeP2Cpu54Rvl0EpABZeTeIT6lnAY2c6RPuY/ATTMHKm9ocJV612ph1jmv3XZch4gyt1\n" +"O6VbuA1df74jrlZVlFjvH4GMKrLN5ptjnhi85WsGtAuYSyher4hYyw==\n" +"-----END CERTIFICATE-----\n", + +/* Certinomis - Root CA */ +"-----BEGIN CERTIFICATE-----\n" +"MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjETMBEGA1UE\n" +"ChMKQ2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAbBgNVBAMTFENlcnRp\n" +"bm9taXMgLSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMzMTAyMTA5MTcxOFowWjELMAkG\n" +"A1UEBhMCRlIxEzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAz\n" +"MR0wGwYDVQQDExRDZXJ0aW5vbWlzIC0gUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +"ADCCAgoCggIBANTMCQosP5L2fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4\n" +"kkjW4znuzuRZWJflLieY6pOod5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9\n" +"n+ws+hQVWZUKxkd8aRi5pwP5ynapz8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDF\n" +"TKWrteoB4owuZH9kb/2jJZOLyKIOSY008B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb5nPJWqHZ\n" +"ZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09xRLWtwHkziOC/7aOgFLScCbAK42C++PhmiM1b\n" +"8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE6OXWk6RiwsXm9E/G+Z8ajYJJGYrKWUM6\n" +"6A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJwx3tFvYk9CcbXFcx3FXuqB5vbKziRcxX\n" +"V4p1VxngtViZSTYxPDMBbRZKzbgqg4SGm/lg0h9tkQPTYKbVPZrdd5A9NaSfD171UkRpucC6\n" +"3M9933zZxKyGIjK8e2uR73r4F2iw4lNVYC2vPsKD2NkJK/DAZNuHi5HMkesE/Xa0lZrmFAYb\n" +"1TQdvtj/dBxThZngWVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGjYzBhMA4GA1UdDwEB\n" +"/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I6tNxIqSSaHh0\n" +"2TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsFAAOCAgEA\n" +"fj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/0KGRHCwPT5iVWVO9\n" +"0CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWwF6YSjNRieOpWauwK0kDDPAUw\n" +"Pk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZSg081lLMSVX3l4kLr5JyTCcBMWwerx20R\n" +"oFAXlCOotQqSD7J6wWAsOMwaplv/8gzjqh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5n\n" +"U7aJ+BIJy29SWwNyhlCVCNSNh4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrj\n" +"cOa4pvi2WsS9Iff/ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu\n" +"6AdBBR8Vbtaw5BngDwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwj\n" +"Y/M50n92Uaf0yKHxDHYiI0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ8ow7bkrH\n" +"xuaAKzyBvBGAFhAn1/DNP3nMcyrDflOR1m749fPH0FFNjkulW+YZFzvWgQncItzujrnEj1Ph\n" +"Z7szuIgVRs/taTX/dQ1G885x4cVrhkIGuUE=\n" +"-----END CERTIFICATE-----\n", + +/* OISTE WISeKey Global Root GB CA */ +"-----BEGIN CERTIFICATE-----\n" +"MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYD\n" +"VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBF\n" +"bmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0x\n" +"NDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdX\n" +"SVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9P\n" +"SVNURSBXSVNlS2V5IEdsb2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" +"MIIBCgKCAQEA2Be3HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvY\n" +"D06fWvGxWuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX\n" +"1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn2\n" +"1HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiND\n" +"ecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9rM2RYk61pv48b74JIxwIDAQAB\n" +"o1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs\n" +"+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4ey\n" +"mYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHE\n" +"thYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3Z\n" +"wLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf\n" +"aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02IcNc1MaRVU\n" +"GpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=\n" +"-----END CERTIFICATE-----\n", + +/* Certification Authority of WoSign G2 */ +"-----BEGIN CERTIFICATE-----\n" +"MIIDfDCCAmSgAwIBAgIQayXaioidfLwPBbOxemFFRDANBgkqhkiG9w0BAQsFADBYMQswCQYD\n" +"VQQGEwJDTjEaMBgGA1UEChMRV29TaWduIENBIExpbWl0ZWQxLTArBgNVBAMTJENlcnRpZmlj\n" +"YXRpb24gQXV0aG9yaXR5IG9mIFdvU2lnbiBHMjAeFw0xNDExMDgwMDU4NThaFw00NDExMDgw\n" +"MDU4NThaMFgxCzAJBgNVBAYTAkNOMRowGAYDVQQKExFXb1NpZ24gQ0EgTGltaXRlZDEtMCsG\n" +"A1UEAxMkQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgb2YgV29TaWduIEcyMIIBIjANBgkqhkiG\n" +"9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvsXEoCKASU+/2YcRxlPhuw+9YH+v9oIOH9ywjj2X4FA8\n" +"jzrvZjtFB5sg+OPXJYY1kBaiXW8wGQiHC38Gsp1ij96vkqVg1CuAmlI/9ZqD6TRay9nVYlzm\n" +"DuDfBpgOgHzKtB0TiGsOqCR3A9DuW/PKaZE1OVbFbeP3PU9ekzgkyhjpJMuSA93MHD0JcOQg\n" +"5PGurLtzaaNjOg9FD6FKmsLRY6zLEPg95k4ot+vElbGs/V6r+kHLXZ1L3PR8du9nfwB6jdKg\n" +"GlxNIuG12t12s9R23164i5jIFFTMaxeSt+BKv0mUYQs4kI9dJGwlezt52eJ+na2fmKEG/HgU\n" +"YFf47oB3sQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV\n" +"HQ4EFgQU+mCp62XF3RYUCE4MD42b4Pdkr2cwDQYJKoZIhvcNAQELBQADggEBAFfDejaCnI2Y\n" +"4qtAqkePx6db7XznPWZaOzG73/MWM5H8fHulwqZm46qwtyeYP0nXYGdnPzZPSsvxFPpahygc\n" +"7Y9BMsaV+X3avXtbwrAh449G3CE4Q3RM+zD4F3LBMvzIkRfEzFg3TgvMWvchNSiDbGAtROtS\n" +"jFA9tWwS1/oJu2yySrHFieT801LYYRf+epSEj3m2M1m6D8QL4nCgS3gu+sif/a+RZQp4OBXl\n" +"lxcU3fngLDT4ONCEIgDAFFEYKwLcMFrw6AF8NTojrwjkr6qOKEJJLvD1mTS+7Q9LGOHSJDy7\n" +"XUe3IfKN0QqZjuNuPq1w4I+5ysxugTH2e5x6eeRncRg=\n" +"-----END CERTIFICATE-----\n", + +/* CA WoSign ECC Root */ +"-----BEGIN CERTIFICATE-----\n" +"MIICCTCCAY+gAwIBAgIQaEpYcIBr8I8C+vbe6LCQkDAKBggqhkjOPQQDAzBGMQswCQYDVQQG\n" +"EwJDTjEaMBgGA1UEChMRV29TaWduIENBIExpbWl0ZWQxGzAZBgNVBAMTEkNBIFdvU2lnbiBF\n" +"Q0MgUm9vdDAeFw0xNDExMDgwMDU4NThaFw00NDExMDgwMDU4NThaMEYxCzAJBgNVBAYTAkNO\n" +"MRowGAYDVQQKExFXb1NpZ24gQ0EgTGltaXRlZDEbMBkGA1UEAxMSQ0EgV29TaWduIEVDQyBS\n" +"b290MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE4f2OuEMkq5Z7hcK6C62N4DrjJLnSsb6IOsq/\n" +"Srj57ywvr1FQPEd1bPiUt5v8KB7FVMxjnRZLU8HnIKvNrCXSf4/CwVqCXjCLelTOA7WRf6qU\n" +"0NGKSMyCBSah1VES1ns2o0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd\n" +"BgNVHQ4EFgQUqv3VWqP2h4syhf3RMluARZPzA7gwCgYIKoZIzj0EAwMDaAAwZQIxAOSkhLCB\n" +"1T2wdKyUpOgOPQB0TKGXa/kNUTyh2Tv0Daupn75OcsqF1NnstTJFGG+rrQIwfcf3aWMvoeGY\n" +"7xMQ0Xk/0f7qO3/eVvSQsRUR2LIiFdAvwyYua/GRspBl9JrmkO5K\n" +"-----END CERTIFICATE-----\n", + +/* SZAFIR ROOT CA2 */ +"-----BEGIN CERTIFICATE-----\n" +"MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTEL\n" +"MAkGA1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4x\n" +"GDAWBgNVBAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQz\n" +"MzBaMFExCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93\n" +"YSBTLkEuMRgwFgYDVQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" +"DwAwggEKAoIBAQC3vD5QqEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj\n" +"5/QqGJ3a0a4m7utT3PSQ1hNKDJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd\n" +"3BucPbOw3gAeqDRHu5rr/gsUvTaE2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr6\n" +"3fE9biCloBK0TXC5ztdyO4mTp4CEHCdJckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0Bw\n" +"PLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwiieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMB\n" +"AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlK\n" +"GLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOCAQEAtXP4A9xZWx126aMqe5Aosk3A\n" +"M0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2\n" +"onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcP\n" +"v5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4M\n" +"NIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg\n" +"LvWpCz/UXeHPhJ/iGcJfitYgHuNztw==\n" +"-----END CERTIFICATE-----\n", + +/* Certum Trusted Network CA 2 */ +"-----BEGIN CERTIFICATE-----\n" +"MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkG\n" +"A1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsT\n" +"HkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0\n" +"ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGA\n" +"MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUG\n" +"A1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0g\n" +"VHJ1c3RlZCBOZXR3b3JrIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9\n" +"+Xj45tWADGSdhhuWZGc/IjoedQF97/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn\n" +"0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+oCgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/\n" +"j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40bRr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxS\n" +"iyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2puTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq\n" +"28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130GO6IyY0XRSmZMnUCMe4pJshrAua1\n" +"YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ9fqGGmd4s7+W/jTcvedSVuWz\n" +"5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVBRgkg/iKgtlswjbyJDNXX\n" +"cPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pyehizKV/Ma5ciSixqC\n" +"lnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vMBhBgu4M1t15n\n" +"3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0G\n" +"A1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcN\n" +"AQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW\n" +"Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ\n" +"2vuAL55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BN\n" +"XuMp8SMoclm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3\n" +"lEu6LaTaM4tMpkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVI\n" +"eVheO/jbAoJnwTnbw3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksq\n" +"P/ujmv5zMnHCnsZy4YpoJ/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bIND\n" +"d82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXa\n" +"QHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlF\n" +"w5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbiDrW5viSP\n" +"-----END CERTIFICATE-----\n", From 1baa145a1667ffa87c905500dcfb963f0113a13e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 23 Jun 2016 09:25:50 +0200 Subject: [PATCH 160/261] test: remove internet/test-tls-connnect-cnnic Shigeki Ohtsu points out that the test is unreliable because some of the www1.cnnnic.cn servers are misconfigured. Remove it. PR-URL: https://github.com/nodejs/node/pull/7363 Refs: https://github.com/nodejs/node/pull/7363#issuecomment-227801420 Reviewed-By: Fedor Indutny Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- test/internet/test-tls-connnect-cnnic.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 test/internet/test-tls-connnect-cnnic.js diff --git a/test/internet/test-tls-connnect-cnnic.js b/test/internet/test-tls-connnect-cnnic.js deleted file mode 100644 index 038e23d2374584..00000000000000 --- a/test/internet/test-tls-connnect-cnnic.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -// -// The server cert of www1.cnnic.cn is listed in the whitelist of -// { -// { 0x1B, 0xF4, 0x8A, 0x83, 0x3C, 0xE4, 0x05, 0x64, 0x8C, 0xC0, 0xBD, 0xD3, -// 0xB5, 0xB8, 0xC1, 0x8E, 0xB5, 0x13, 0x15, 0x34, 0x29, 0x3A, 0xB2, 0x63, -// 0x44, 0xB5, 0x00, 0x76, 0x48, 0x11, 0x41, 0xED }, -// }, -// in src/CNNICHashWhitelist.inc - -var common = require('../common'); -if (!common.hasCrypto) { - common.skip('missing crypto'); - return; -} - -var tls = require('tls'); -var socket = tls.connect(443, 'www1.cnnic.cn', function() { - socket.resume(); - socket.destroy(); -}); From c03bd57ac6036993a7edf91c70d896757a3c8ffd Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 13:03:46 +0200 Subject: [PATCH 161/261] src: check uv_async_init() return value Pointed out by Coverity. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node.cc | 6 +++--- src/node_win32_etw_provider.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node.cc b/src/node.cc index 9be6fa5c507196..d05237e2b726b4 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3857,9 +3857,9 @@ void Init(int* argc, // init async debug messages dispatching // Main thread uses uv_default_loop - uv_async_init(uv_default_loop(), - &dispatch_debug_messages_async, - DispatchDebugMessagesAsyncCallback); + CHECK_EQ(0, uv_async_init(uv_default_loop(), + &dispatch_debug_messages_async, + DispatchDebugMessagesAsyncCallback)); uv_unref(reinterpret_cast(&dispatch_debug_messages_async)); #if defined(NODE_V8_OPTIONS) diff --git a/src/node_win32_etw_provider.cc b/src/node_win32_etw_provider.cc index 6877f1977dae8b..f2650af93a51d6 100644 --- a/src/node_win32_etw_provider.cc +++ b/src/node_win32_etw_provider.cc @@ -155,9 +155,9 @@ void init_etw() { event_write = (EventWriteFunc)GetProcAddress(advapi, "EventWrite"); // create async object used to invoke main thread from callback - uv_async_init(uv_default_loop(), - &dispatch_etw_events_change_async, - etw_events_change_async); + CHECK_EQ(0, uv_async_init(uv_default_loop(), + &dispatch_etw_events_change_async, + etw_events_change_async)); uv_unref(reinterpret_cast(&dispatch_etw_events_change_async)); if (event_register) { From 67937bca0a13c25aeecbeffa1f5aa4bdf72d0c15 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 13:17:03 +0200 Subject: [PATCH 162/261] src: guard against starting fs watcher twice This commit adds a CHECK that verifies that the file event watcher is not started twice, which would be indicative of a bug in lib/fs.js. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/fs_event_wrap.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index a9f96389121c9e..cd6dc417ba2460 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -85,6 +85,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); FSEventWrap* wrap = Unwrap(args.Holder()); + CHECK_EQ(wrap->initialized_, false); if (args.Length() < 1 || !args[0]->IsString()) { return env->ThrowTypeError("filename must be a valid string"); From e103044b6864ad6943640206eb39c549ef12e419 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 13:35:01 +0200 Subject: [PATCH 163/261] src: remove unused data member write_queue_size_ Remove TLSWrap::write_queue_size_, it's not used anywhere. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/tls_wrap.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 471a92056dd848..8346613b199253 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -148,7 +148,6 @@ class TLSWrap : public AsyncWrap, BIO* enc_out_; NodeBIO* clear_in_; size_t write_size_; - size_t write_queue_size_; typedef ListHead WriteItemList; WriteItemList write_item_queue_; WriteItemList pending_write_items_; From 38baf6a0b7385c46e83007a0bc7bbb9d76d7cef7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 13:56:59 +0200 Subject: [PATCH 164/261] src: remove unused md_ data members The code assigned the result of EVP_get_digestbyname() to data members called md_ that were not used outside the initialization functions. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node_crypto.cc | 34 +++++++++++++++++----------------- src/node_crypto.h | 6 ------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2d508d2cc3d527..1593d9a92b96f0 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3320,17 +3320,17 @@ void Hmac::New(const FunctionCallbackInfo& args) { void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) { HandleScope scope(env()->isolate()); - CHECK_EQ(md_, nullptr); - md_ = EVP_get_digestbyname(hash_type); - if (md_ == nullptr) { + CHECK_EQ(initialised_, false); + const EVP_MD* md = EVP_get_digestbyname(hash_type); + if (md == nullptr) { return env()->ThrowError("Unknown message digest"); } HMAC_CTX_init(&ctx_); int result = 0; if (key_len == 0) { - result = HMAC_Init(&ctx_, "", 0, md_); + result = HMAC_Init(&ctx_, "", 0, md); } else { - result = HMAC_Init(&ctx_, key, key_len, md_); + result = HMAC_Init(&ctx_, key, key_len, md); } if (!result) { return ThrowCryptoError(env(), ERR_get_error()); @@ -3461,12 +3461,12 @@ void Hash::New(const FunctionCallbackInfo& args) { bool Hash::HashInit(const char* hash_type) { - CHECK_EQ(md_, nullptr); - md_ = EVP_get_digestbyname(hash_type); - if (md_ == nullptr) + CHECK_EQ(initialised_, false); + const EVP_MD* md = EVP_get_digestbyname(hash_type); + if (md == nullptr) return false; EVP_MD_CTX_init(&mdctx_); - if (EVP_DigestInit_ex(&mdctx_, md_, nullptr) <= 0) { + if (EVP_DigestInit_ex(&mdctx_, md, nullptr) <= 0) { return false; } initialised_ = true; @@ -3599,13 +3599,13 @@ void Sign::New(const FunctionCallbackInfo& args) { SignBase::Error Sign::SignInit(const char* sign_type) { - CHECK_EQ(md_, nullptr); - md_ = EVP_get_digestbyname(sign_type); - if (!md_) + CHECK_EQ(initialised_, false); + const EVP_MD* md = EVP_get_digestbyname(sign_type); + if (md == nullptr) return kSignUnknownDigest; EVP_MD_CTX_init(&mdctx_); - if (!EVP_SignInit_ex(&mdctx_, md_, nullptr)) + if (!EVP_SignInit_ex(&mdctx_, md, nullptr)) return kSignInit; initialised_ = true; @@ -3799,13 +3799,13 @@ void Verify::New(const FunctionCallbackInfo& args) { SignBase::Error Verify::VerifyInit(const char* verify_type) { - CHECK_EQ(md_, nullptr); - md_ = EVP_get_digestbyname(verify_type); - if (md_ == nullptr) + CHECK_EQ(initialised_, false); + const EVP_MD* md = EVP_get_digestbyname(verify_type); + if (md == nullptr) return kSignUnknownDigest; EVP_MD_CTX_init(&mdctx_); - if (!EVP_VerifyInit_ex(&mdctx_, md_, nullptr)) + if (!EVP_VerifyInit_ex(&mdctx_, md, nullptr)) return kSignInit; initialised_ = true; diff --git a/src/node_crypto.h b/src/node_crypto.h index cb94650e0735d0..d9105fd11a5721 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -495,14 +495,12 @@ class Hmac : public BaseObject { Hmac(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - md_(nullptr), initialised_(false) { MakeWeak(this); } private: HMAC_CTX ctx_; /* coverity[member_decl] */ - const EVP_MD* md_; /* coverity[member_decl] */ bool initialised_; }; @@ -526,14 +524,12 @@ class Hash : public BaseObject { Hash(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - md_(nullptr), initialised_(false) { MakeWeak(this); } private: EVP_MD_CTX mdctx_; /* coverity[member_decl] */ - const EVP_MD* md_; /* coverity[member_decl] */ bool initialised_; }; @@ -551,7 +547,6 @@ class SignBase : public BaseObject { SignBase(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - md_(nullptr), initialised_(false) { } @@ -565,7 +560,6 @@ class SignBase : public BaseObject { void CheckThrow(Error error); EVP_MD_CTX mdctx_; /* coverity[member_decl] */ - const EVP_MD* md_; /* coverity[member_decl] */ bool initialised_; }; From 7305e7b9d24ee2a13a04378425579cf3db728916 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 14:07:56 +0200 Subject: [PATCH 165/261] src: remove duplicate HMAC_Init calls PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node_crypto.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 1593d9a92b96f0..6d2bb54bdee357 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3326,13 +3326,10 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) { return env()->ThrowError("Unknown message digest"); } HMAC_CTX_init(&ctx_); - int result = 0; if (key_len == 0) { - result = HMAC_Init(&ctx_, "", 0, md); - } else { - result = HMAC_Init(&ctx_, key, key_len, md); + key = ""; } - if (!result) { + if (!HMAC_Init(&ctx_, key, key_len, md)) { return ThrowCryptoError(env(), ERR_get_error()); } initialised_ = true; From 61de6e9b47ba4206fc6890b31eec3a3c29339aa4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 14:08:25 +0200 Subject: [PATCH 166/261] src: remove deprecated HMAC_Init, use HMAC_Init_ex PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node_crypto.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 6d2bb54bdee357..96b37fd976ec97 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3329,7 +3329,7 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) { if (key_len == 0) { key = ""; } - if (!HMAC_Init(&ctx_, key, key_len, md)) { + if (!HMAC_Init_ex(&ctx_, key, key_len, md, nullptr)) { return ThrowCryptoError(env(), ERR_get_error()); } initialised_ = true; From e6a27a70d821371aae10e8116f0666855cd5b4cc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 14:32:56 +0200 Subject: [PATCH 167/261] src: fix use-after-return in zlib bindings Pointed out by Coverity. Introduced in commit 5b8e1dab from September 2011 ("Initial pass at zlib bindings".) The asynchronous version of Write() used a pointer to a stack-allocated buffer on flush. A mitigating factor is that zlib does not dereference the pointer for zero-sized writes but it's still technically UB. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node_zlib.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 29649e32c7dbbc..15f58843983c8f 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -145,8 +145,7 @@ class ZCtx : public AsyncWrap { if (args[1]->IsNull()) { // just a flush - Bytef nada[1] = { 0 }; - in = nada; + in = nullptr; in_len = 0; in_off = 0; } else { From 53a67ed6d766f27540acd63d8e9e6164b28a0758 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 21:57:13 +0200 Subject: [PATCH 168/261] src: fix bad logic in uid/gid checks Pointed out by Coverity. Introduced in commits 3546383c ("process_wrap: avoid leaking memory when throwing due to invalid arguments") and fa4eb47c ("bindings: add spawn_sync bindings"). The return statements inside the if blocks were dead code because their guard conditions always evaluated to false. Remove them. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/process_wrap.cc | 14 ++++---------- src/spawn_sync.cc | 33 +++++++-------------------------- src/spawn_sync.h | 1 - 3 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 420c71d7ea4052..3b98b4a3771b3b 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -120,12 +120,9 @@ class ProcessWrap : public HandleWrap { // options.uid Local uid_v = js_options->Get(env->uid_string()); if (uid_v->IsInt32()) { - int32_t uid = uid_v->Int32Value(); - if (uid & ~((uv_uid_t) ~0)) { - return env->ThrowRangeError("options.uid is out of range"); - } + const int32_t uid = uid_v->Int32Value(env->context()).FromJust(); options.flags |= UV_PROCESS_SETUID; - options.uid = (uv_uid_t) uid; + options.uid = static_cast(uid); } else if (!uid_v->IsUndefined() && !uid_v->IsNull()) { return env->ThrowTypeError("options.uid should be a number"); } @@ -133,12 +130,9 @@ class ProcessWrap : public HandleWrap { // options.gid Local gid_v = js_options->Get(env->gid_string()); if (gid_v->IsInt32()) { - int32_t gid = gid_v->Int32Value(); - if (gid & ~((uv_gid_t) ~0)) { - return env->ThrowRangeError("options.gid is out of range"); - } + const int32_t gid = gid_v->Int32Value(env->context()).FromJust(); options.flags |= UV_PROCESS_SETGID; - options.gid = (uv_gid_t) gid; + options.gid = static_cast(gid); } else if (!gid_v->IsUndefined() && !gid_v->IsNull()) { return env->ThrowTypeError("options.gid should be a number"); } diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 62fadb4396ce19..4ff70b48ca9618 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -729,17 +729,19 @@ int SyncProcessRunner::ParseOptions(Local js_value) { } Local js_uid = js_options->Get(env()->uid_string()); if (IsSet(js_uid)) { - if (!CheckRange(js_uid)) + if (!js_uid->IsInt32()) return UV_EINVAL; - uv_process_options_.uid = static_cast(js_uid->Int32Value()); + const int32_t uid = js_uid->Int32Value(env()->context()).FromJust(); + uv_process_options_.uid = static_cast(uid); uv_process_options_.flags |= UV_PROCESS_SETUID; } Local js_gid = js_options->Get(env()->gid_string()); if (IsSet(js_gid)) { - if (!CheckRange(js_gid)) + if (!js_gid->IsInt32()) return UV_EINVAL; - uv_process_options_.gid = static_cast(js_gid->Int32Value()); + const int32_t gid = js_gid->Int32Value(env()->context()).FromJust(); + uv_process_options_.gid = static_cast(gid); uv_process_options_.flags |= UV_PROCESS_SETGID; } @@ -763,7 +765,7 @@ int SyncProcessRunner::ParseOptions(Local js_value) { Local js_max_buffer = js_options->Get(env()->max_buffer_string()); if (IsSet(js_max_buffer)) { - if (!CheckRange(js_max_buffer)) + if (!js_max_buffer->IsUint32()) return UV_EINVAL; max_buffer_ = js_max_buffer->Uint32Value(); } @@ -915,27 +917,6 @@ bool SyncProcessRunner::IsSet(Local value) { } -template -bool SyncProcessRunner::CheckRange(Local js_value) { - if ((t) -1 > 0) { - // Unsigned range check. - if (!js_value->IsUint32()) - return false; - if (js_value->Uint32Value() & ~((t) ~0)) - return false; - - } else { - // Signed range check. - if (!js_value->IsInt32()) - return false; - if (js_value->Int32Value() & ~((t) ~0)) - return false; - } - - return true; -} - - int SyncProcessRunner::CopyJsString(Local js_value, const char** target) { Isolate* isolate = env()->isolate(); diff --git a/src/spawn_sync.h b/src/spawn_sync.h index fab2f09eefea69..1f9fc68809a9dc 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -173,7 +173,6 @@ class SyncProcessRunner { inline int AddStdioInheritFD(uint32_t child_fd, int inherit_fd); static bool IsSet(Local value); - template static bool CheckRange(Local js_value); int CopyJsString(Local js_value, const char** target); int CopyJsStringArray(Local js_value, char** target); From b956635e41f96218a0a5fac6bc25738735f0e315 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 19 May 2016 20:25:05 -0400 Subject: [PATCH 169/261] tls: catch `certCbDone` exceptions Catch and emit `certCbDone` exceptions instead of throwing them as `uncaughtException` and crashing the whole process. Fix: https://github.com/nodejs/node/issues/6822 PR-URL: https://github.com/nodejs/node/pull/6887 Reviewed-By: Ben Noordhuis --- lib/_tls_wrap.js | 6 ++- test/parallel/test-tls-empty-sni-context.js | 42 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-tls-empty-sni-context.js diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 5c5370e09c19e0..6acf5e26a65ebf 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -184,7 +184,11 @@ function oncertcb(info) { if (!self._handle) return self.destroy(new Error('Socket is closed')); - self._handle.certCbDone(); + try { + self._handle.certCbDone(); + } catch (e) { + self.destroy(e); + } }); }); } diff --git a/test/parallel/test-tls-empty-sni-context.js b/test/parallel/test-tls-empty-sni-context.js new file mode 100644 index 00000000000000..3a1934ba3240c0 --- /dev/null +++ b/test/parallel/test-tls-empty-sni-context.js @@ -0,0 +1,42 @@ +'use strict'; + +if (!process.features.tls_sni) { + console.log('1..0 # Skipped: node compiled without OpenSSL or ' + + 'with old OpenSSL version.'); + return; +} + +const common = require('../common'); +const assert = require('assert'); + +if (!common.hasCrypto) { + console.log('1..0 # Skipped: missing crypto'); + return; +} + +const tls = require('tls'); + +const options = { + SNICallback: (name, callback) => { + callback(null, tls.createSecureContext()); + } +}; + +const server = tls.createServer(options, (c) => { + common.fail('Should not be called'); +}).on('clientError', common.mustCall((err, c) => { + assert(/SSL_use_certificate:passed a null parameter/i.test(err.message)); + server.close(); +})).listen(common.PORT, common.mustCall(() => { + const c = tls.connect({ + port: common.PORT, + rejectUnauthorized: false, + servername: 'any.name' + }, () => { + common.fail('Should not be called'); + }); + + c.on('error', common.mustCall((err) => { + assert(/socket hang up/.test(err.message)); + })); +})); From 79bd39c20236aaa22b32076d7cec7622e3bb1752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 29 Jun 2016 20:05:17 +0200 Subject: [PATCH 170/261] build: add v8 requirement to test-v8* in Makefile The test targets expect that V8 is built in deps/v8/out Ref: https://github.com/nodejs/node/issues/7477 PR-URL: https://github.com/nodejs/node/pull/7482 Reviewed-By: Myles Borins Reviewed-By: James M Snell --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a13d7388179dab..69b9799605298c 100644 --- a/Makefile +++ b/Makefile @@ -227,7 +227,7 @@ test-timers: test-timers-clean: $(MAKE) --directory=tools clean -test-v8: +test-v8: v8 # note: performs full test unless QUICKCHECK is specified deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \ --mode=$(BUILDTYPE_LOWER) $(V8_TEST_NO_I18N) $(QUICKCHECK_ARG) \ @@ -235,14 +235,14 @@ test-v8: --shell-dir=$(PWD)/deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) \ $(TAP_V8) -test-v8-intl: +test-v8-intl: v8 # note: performs full test unless QUICKCHECK is specified deps/v8/tools/run-tests.py --arch=$(V8_ARCH) \ --mode=$(BUILDTYPE_LOWER) --no-presubmit $(QUICKCHECK_ARG) \ --shell-dir=deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) intl \ $(TAP_V8_INTL) -test-v8-benchmarks: +test-v8-benchmarks: v8 deps/v8/tools/run-tests.py --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \ --download-data $(QUICKCHECK_ARG) --no-presubmit \ --shell-dir=deps/v8/out/$(V8_ARCH).$(BUILDTYPE_LOWER) benchmarks \ From 5290c9d38c5ecc663a063a46e7a501e05102fcca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 30 Jun 2016 08:06:04 +0200 Subject: [PATCH 171/261] build: use BUILDTYPE when building V8 in Makefile Without this it would always compile Release and Debug builds. Ref: https://github.com/nodejs/node/issues/7477 PR-URL: https://github.com/nodejs/node/pull/7482 Reviewed-By: Myles Borins Reviewed-By: James M Snell --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 69b9799605298c..f316b21ec18b8b 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ cctest: all v8: tools/make-v8.sh v8 - $(MAKE) -C deps/v8 $(V8_ARCH) $(V8_BUILD_OPTIONS) + $(MAKE) -C deps/v8 $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) test: | cctest # Depends on 'all'. $(PYTHON) tools/test.py --mode=release doctool message pseudo-tty parallel sequential -J From a31d3161f5cd58269aa18e6cee7068eb8e57993c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 16:21:21 -0700 Subject: [PATCH 172/261] test: add test for exec() known issue PR-URL: https://github.com/nodejs/node/pull/7375 Refs: https://github.com/nodejs/node/issues/7342 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- ...test-child-process-exec-stdout-data-string.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/known_issues/test-child-process-exec-stdout-data-string.js diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/known_issues/test-child-process-exec-stdout-data-string.js new file mode 100644 index 00000000000000..b267ff5e98347a --- /dev/null +++ b/test/known_issues/test-child-process-exec-stdout-data-string.js @@ -0,0 +1,16 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/7342 +const common = require('../common'); +const assert = require('assert'); +const exec = require('child_process').exec; + +const expectedCalls = 2; + +const cb = common.mustCall((data) => { + assert.strictEqual(typeof data, 'string'); +}, expectedCalls); + +const command = common.isWindows ? 'dir' : 'ls'; +exec(command).stdout.on('data', cb); + +exec('fhqwhgads').stderr.on('data', cb); From fd05b0b2899da47264b589caa3bac3a05ff21522 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Jun 2016 16:21:21 -0700 Subject: [PATCH 173/261] Revert "child_process: measure buffer length in bytes" This reverts commit c9a5990a76ccb15872234948e23bdc12691c2e70. PR-URL: https://github.com/nodejs/node/pull/7391 Reviewed-By: Ben Noordhuis Reviewed-By: Jackson Tian --- lib/child_process.js | 71 ++++++++----------- .../test-child-process-max-buffer.js} | 3 +- ...t-child-process-exec-stdout-data-string.js | 0 .../test-child-process-maxBuffer-stderr.js | 15 ---- 4 files changed, 32 insertions(+), 57 deletions(-) rename test/{parallel/test-child-process-maxBuffer-stdout.js => known_issues/test-child-process-max-buffer.js} (75%) rename test/{known_issues => parallel}/test-child-process-exec-stdout-data-string.js (100%) delete mode 100644 test/parallel/test-child-process-maxBuffer-stderr.js diff --git a/lib/child_process.js b/lib/child_process.js index 7728b89bdb5fba..e43093ace1fa0d 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -157,13 +157,15 @@ exports.execFile = function(file /*, args, options, callback*/) { }); var encoding; - var stdoutState; - var stderrState; - var _stdout = []; - var _stderr = []; + var _stdout; + var _stderr; if (options.encoding !== 'buffer' && Buffer.isEncoding(options.encoding)) { encoding = options.encoding; + _stdout = ''; + _stderr = ''; } else { + _stdout = []; + _stderr = []; encoding = null; } var stdoutLen = 0; @@ -185,23 +187,16 @@ exports.execFile = function(file /*, args, options, callback*/) { if (!callback) return; - var stdout = Buffer.concat(_stdout, stdoutLen); - var stderr = Buffer.concat(_stderr, stderrLen); - - var stdoutEncoding = encoding; - var stderrEncoding = encoding; - - if (stdoutState && stdoutState.decoder) - stdoutEncoding = stdoutState.decoder.encoding; - - if (stderrState && stderrState.decoder) - stderrEncoding = stderrState.decoder.encoding; - - if (stdoutEncoding) - stdout = stdout.toString(stdoutEncoding); - - if (stderrEncoding) - stderr = stderr.toString(stderrEncoding); + // merge chunks + var stdout; + var stderr; + if (!encoding) { + stdout = Buffer.concat(_stdout); + stderr = Buffer.concat(_stderr); + } else { + stdout = _stdout; + stderr = _stderr; + } if (ex) { // Will be handled later @@ -261,45 +256,39 @@ exports.execFile = function(file /*, args, options, callback*/) { } if (child.stdout) { - stdoutState = child.stdout._readableState; + if (encoding) + child.stdout.setEncoding(encoding); child.stdout.addListener('data', function(chunk) { - // If `child.stdout.setEncoding()` happened in userland, convert string to - // Buffer. - if (stdoutState.decoder) { - chunk = Buffer.from(chunk, stdoutState.decoder.encoding); - } - - stdoutLen += chunk.byteLength; + stdoutLen += chunk.length; if (stdoutLen > options.maxBuffer) { ex = new Error('stdout maxBuffer exceeded'); - stdoutLen -= chunk.byteLength; kill(); } else { - _stdout.push(chunk); + if (!encoding) + _stdout.push(chunk); + else + _stdout += chunk; } }); } if (child.stderr) { - stderrState = child.stderr._readableState; + if (encoding) + child.stderr.setEncoding(encoding); child.stderr.addListener('data', function(chunk) { - // If `child.stderr.setEncoding()` happened in userland, convert string to - // Buffer. - if (stderrState.decoder) { - chunk = Buffer.from(chunk, stderrState.decoder.encoding); - } - - stderrLen += chunk.byteLength; + stderrLen += chunk.length; if (stderrLen > options.maxBuffer) { ex = new Error('stderr maxBuffer exceeded'); - stderrLen -= chunk.byteLength; kill(); } else { - _stderr.push(chunk); + if (!encoding) + _stderr.push(chunk); + else + _stderr += chunk; } }); } diff --git a/test/parallel/test-child-process-maxBuffer-stdout.js b/test/known_issues/test-child-process-max-buffer.js similarity index 75% rename from test/parallel/test-child-process-maxBuffer-stdout.js rename to test/known_issues/test-child-process-max-buffer.js index 122dc499f462bf..14a344c7062a5a 100644 --- a/test/parallel/test-child-process-maxBuffer-stdout.js +++ b/test/known_issues/test-child-process-max-buffer.js @@ -1,4 +1,5 @@ 'use strict'; +// Refs: https://github.com/nodejs/node/issues/1901 const common = require('../common'); const assert = require('assert'); const cp = require('child_process'); @@ -9,7 +10,7 @@ if (process.argv[2] === 'child') { } else { const cmd = `${process.execPath} ${__filename} child`; - cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => { + cp.exec(cmd, { maxBuffer: 10 }, common.mustCall((err, stdout, stderr) => { assert.strictEqual(err.message, 'stdout maxBuffer exceeded'); })); } diff --git a/test/known_issues/test-child-process-exec-stdout-data-string.js b/test/parallel/test-child-process-exec-stdout-data-string.js similarity index 100% rename from test/known_issues/test-child-process-exec-stdout-data-string.js rename to test/parallel/test-child-process-exec-stdout-data-string.js diff --git a/test/parallel/test-child-process-maxBuffer-stderr.js b/test/parallel/test-child-process-maxBuffer-stderr.js deleted file mode 100644 index ecaea8b152a0ca..00000000000000 --- a/test/parallel/test-child-process-maxBuffer-stderr.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const cp = require('child_process'); -const unicode = '中文测试'; // Length = 4, Byte length = 13 - -if (process.argv[2] === 'child') { - console.error(unicode); -} else { - const cmd = `${process.execPath} ${__filename} child`; - - cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => { - assert.strictEqual(err.message, 'stderr maxBuffer exceeded'); - })); -} From 6a08535dd10b754a89d5788a6b72dd64e960225c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 23 Jun 2016 10:51:48 -0700 Subject: [PATCH 174/261] child_process: preserve argument type A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: https://github.com/nodejs/node/pull/7391 Reviewed-By: Ben Noordhuis Reviewed-By: Jackson Tian Fixes: https://github.com/nodejs/node/issues/7342 Refs: https://github.com/nodejs/node/issues/1901 --- lib/child_process.js | 24 +++++++------- .../test-child-process-max-buffer.js | 16 ---------- .../test-child-process-exec-maxBuffer.js | 31 +++++++++++++++++++ ...process-exec-stdout-stderr-data-string.js} | 21 ++++++++----- test/parallel/test-exec-max-buffer.js | 11 ------- 5 files changed, 57 insertions(+), 46 deletions(-) delete mode 100644 test/known_issues/test-child-process-max-buffer.js create mode 100644 test/parallel/test-child-process-exec-maxBuffer.js rename test/parallel/{test-child-process-exec-stdout-data-string.js => test-child-process-exec-stdout-stderr-data-string.js} (51%) delete mode 100644 test/parallel/test-exec-max-buffer.js diff --git a/lib/child_process.js b/lib/child_process.js index e43093ace1fa0d..02d7c2344798f0 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -190,12 +190,12 @@ exports.execFile = function(file /*, args, options, callback*/) { // merge chunks var stdout; var stderr; - if (!encoding) { - stdout = Buffer.concat(_stdout); - stderr = Buffer.concat(_stderr); - } else { + if (encoding) { stdout = _stdout; stderr = _stderr; + } else { + stdout = Buffer.concat(_stdout); + stderr = Buffer.concat(_stderr); } if (ex) { @@ -260,16 +260,16 @@ exports.execFile = function(file /*, args, options, callback*/) { child.stdout.setEncoding(encoding); child.stdout.addListener('data', function(chunk) { - stdoutLen += chunk.length; + stdoutLen += encoding ? Buffer.byteLength(chunk, encoding) : chunk.length; if (stdoutLen > options.maxBuffer) { ex = new Error('stdout maxBuffer exceeded'); kill(); } else { - if (!encoding) - _stdout.push(chunk); - else + if (encoding) _stdout += chunk; + else + _stdout.push(chunk); } }); } @@ -279,16 +279,16 @@ exports.execFile = function(file /*, args, options, callback*/) { child.stderr.setEncoding(encoding); child.stderr.addListener('data', function(chunk) { - stderrLen += chunk.length; + stderrLen += encoding ? Buffer.byteLength(chunk, encoding) : chunk.length; if (stderrLen > options.maxBuffer) { ex = new Error('stderr maxBuffer exceeded'); kill(); } else { - if (!encoding) - _stderr.push(chunk); - else + if (encoding) _stderr += chunk; + else + _stderr.push(chunk); } }); } diff --git a/test/known_issues/test-child-process-max-buffer.js b/test/known_issues/test-child-process-max-buffer.js deleted file mode 100644 index 14a344c7062a5a..00000000000000 --- a/test/known_issues/test-child-process-max-buffer.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; -// Refs: https://github.com/nodejs/node/issues/1901 -const common = require('../common'); -const assert = require('assert'); -const cp = require('child_process'); -const unicode = '中文测试'; // Length = 4, Byte length = 13 - -if (process.argv[2] === 'child') { - console.log(unicode); -} else { - const cmd = `${process.execPath} ${__filename} child`; - - cp.exec(cmd, { maxBuffer: 10 }, common.mustCall((err, stdout, stderr) => { - assert.strictEqual(err.message, 'stdout maxBuffer exceeded'); - })); -} diff --git a/test/parallel/test-child-process-exec-maxBuffer.js b/test/parallel/test-child-process-exec-maxBuffer.js new file mode 100644 index 00000000000000..714e029d728b1e --- /dev/null +++ b/test/parallel/test-child-process-exec-maxBuffer.js @@ -0,0 +1,31 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); + +function checkFactory(streamName) { + return common.mustCall((err) => { + const message = `${streamName} maxBuffer exceeded`; + assert.strictEqual(err.message, message); + }); +} + +{ + const cmd = 'echo "hello world"'; + + cp.exec(cmd, { maxBuffer: 5 }, checkFactory('stdout')); +} + +const unicode = '中文测试'; // length = 4, byte length = 12 + +{ + const cmd = `"${process.execPath}" -e "console.log('${unicode}');"`; + + cp.exec(cmd, {maxBuffer: 10}, checkFactory('stdout')); +} + +{ + const cmd = `"${process.execPath}" -e "console.('${unicode}');"`; + + cp.exec(cmd, {maxBuffer: 10}, checkFactory('stderr')); +} diff --git a/test/parallel/test-child-process-exec-stdout-data-string.js b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js similarity index 51% rename from test/parallel/test-child-process-exec-stdout-data-string.js rename to test/parallel/test-child-process-exec-stdout-stderr-data-string.js index b267ff5e98347a..8ab834c98f8d79 100644 --- a/test/parallel/test-child-process-exec-stdout-data-string.js +++ b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js @@ -4,13 +4,20 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -const expectedCalls = 2; - -const cb = common.mustCall((data) => { - assert.strictEqual(typeof data, 'string'); -}, expectedCalls); +var stdoutCalls = 0; +var stderrCalls = 0; const command = common.isWindows ? 'dir' : 'ls'; -exec(command).stdout.on('data', cb); +exec(command).stdout.on('data', (data) => { + stdoutCalls += 1; +}); + +exec('fhqwhgads').stderr.on('data', (data) => { + assert.strictEqual(typeof data, 'string'); + stderrCalls += 1; +}); -exec('fhqwhgads').stderr.on('data', cb); +process.on('exit', () => { + assert(stdoutCalls > 0); + assert(stderrCalls > 0); +}); diff --git a/test/parallel/test-exec-max-buffer.js b/test/parallel/test-exec-max-buffer.js deleted file mode 100644 index 15c6e7025978e2..00000000000000 --- a/test/parallel/test-exec-max-buffer.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; -require('../common'); -var exec = require('child_process').exec; -var assert = require('assert'); - -var cmd = 'echo "hello world"'; - -exec(cmd, { maxBuffer: 5 }, function(err, stdout, stderr) { - assert.ok(err); - assert.ok(/maxBuffer/.test(err.message)); -}); From 09349a8b920dd92df59a08aa0e6ec52b9ee2c303 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 31 May 2016 11:16:02 +0200 Subject: [PATCH 175/261] cluster: don't send messages if no IPC channel Avoid sending messages if the IPC channel is already disconnected. It avoids undesired errors when calling `process.disconnect` when there are still pending IPC messages. PR-URL: https://github.com/nodejs/node/pull/7132 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/cluster.js | 3 +++ .../test-cluster-process-disconnect.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/parallel/test-cluster-process-disconnect.js diff --git a/lib/cluster.js b/lib/cluster.js index da57f5cd08b30a..24e3fafb3d3818 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -722,6 +722,9 @@ function workerInit() { var seq = 0; var callbacks = {}; function sendHelper(proc, message, handle, cb) { + if (!proc.connected) + return false; + // Mark message as internal. See INTERNAL_PREFIX in lib/child_process.js message = util._extend({ cmd: 'NODE_CLUSTER' }, message); if (cb) callbacks[seq] = cb; diff --git a/test/parallel/test-cluster-process-disconnect.js b/test/parallel/test-cluster-process-disconnect.js new file mode 100644 index 00000000000000..f83dd0094998df --- /dev/null +++ b/test/parallel/test-cluster-process-disconnect.js @@ -0,0 +1,18 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); + +if (cluster.isMaster) { + const worker = cluster.fork(); + worker.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0, 'worker did not exit normally'); + assert.strictEqual(signal, null, 'worker did not exit normally'); + })); +} else { + const net = require('net'); + const server = net.createServer(); + server.listen(common.PORT, common.mustCall(() => { + process.disconnect(); + })); +} From 20d337896967ccf04a5b66b5ee3d2bd08562cc17 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Wed, 25 May 2016 23:14:41 +0200 Subject: [PATCH 176/261] cluster: reset handle index on close It allows reopening a server after it has been closed. Fixes: https://github.com/nodejs/node/issues/6693 PR-URL: https://github.com/nodejs/node/pull/6981 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Ron Korving Reviewed-By: James M Snell --- lib/cluster.js | 26 +++++++------ .../test-cluster-server-restart-none.js | 37 +++++++++++++++++++ .../test-cluster-server-restart-rr.js | 37 +++++++++++++++++++ 3 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 test/parallel/test-cluster-server-restart-none.js create mode 100644 test/parallel/test-cluster-server-restart-rr.js diff --git a/lib/cluster.js b/lib/cluster.js index 24e3fafb3d3818..8e8bdefadf03c7 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -555,18 +555,18 @@ function workerInit() { // obj is a net#Server or a dgram#Socket object. cluster._getServer = function(obj, options, cb) { - const key = [ options.address, - options.port, - options.addressType, - options.fd ].join(':'); - if (indexes[key] === undefined) - indexes[key] = 0; + const indexesKey = [ options.address, + options.port, + options.addressType, + options.fd ].join(':'); + if (indexes[indexesKey] === undefined) + indexes[indexesKey] = 0; else - indexes[key]++; + indexes[indexesKey]++; const message = util._extend({ act: 'queryServer', - index: indexes[key], + index: indexes[indexesKey], data: null }, options); @@ -576,9 +576,9 @@ function workerInit() { if (obj._setServerData) obj._setServerData(reply.data); if (handle) - shared(reply, handle, cb); // Shared listen socket. + shared(reply, handle, indexesKey, cb); // Shared listen socket. else - rr(reply, cb); // Round-robin. + rr(reply, indexesKey, cb); // Round-robin. }); obj.once('listening', function() { cluster.worker.state = 'listening'; @@ -590,7 +590,7 @@ function workerInit() { }; // Shared listen socket. - function shared(message, handle, cb) { + function shared(message, handle, indexesKey, cb) { var key = message.key; // Monkey-patch the close() method so we can keep track of when it's // closed. Avoids resource leaks when the handle is short-lived. @@ -598,6 +598,7 @@ function workerInit() { handle.close = function() { send({ act: 'close', key: key }); delete handles[key]; + delete indexes[indexesKey]; return close.apply(this, arguments); }; assert(handles[key] === undefined); @@ -606,7 +607,7 @@ function workerInit() { } // Round-robin. Master distributes handles across workers. - function rr(message, cb) { + function rr(message, indexesKey, cb) { if (message.errno) return cb(message.errno, null); @@ -627,6 +628,7 @@ function workerInit() { if (key === undefined) return; send({ act: 'close', key: key }); delete handles[key]; + delete indexes[indexesKey]; key = undefined; } diff --git a/test/parallel/test-cluster-server-restart-none.js b/test/parallel/test-cluster-server-restart-none.js new file mode 100644 index 00000000000000..dc44bafd66317b --- /dev/null +++ b/test/parallel/test-cluster-server-restart-none.js @@ -0,0 +1,37 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_NONE; + +if (cluster.isMaster) { + const worker1 = cluster.fork(); + worker1.on('listening', common.mustCall(() => { + const worker2 = cluster.fork(); + worker2.on('exit', (code, signal) => { + assert.strictEqual(code, 0, 'worker2 did not exit normally'); + assert.strictEqual(signal, null, 'worker2 did not exit normally'); + worker1.disconnect(); + }); + })); + + worker1.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0, 'worker1 did not exit normally'); + assert.strictEqual(signal, null, 'worker1 did not exit normally'); + })); +} else { + const net = require('net'); + const server = net.createServer(); + server.listen(common.PORT, common.mustCall(() => { + if (cluster.worker.id === 2) { + server.close(() => { + server.listen(common.PORT, common.mustCall(() => { + server.close(() => { + process.disconnect(); + }); + })); + }); + } + })); +} diff --git a/test/parallel/test-cluster-server-restart-rr.js b/test/parallel/test-cluster-server-restart-rr.js new file mode 100644 index 00000000000000..724a77b71a4fa9 --- /dev/null +++ b/test/parallel/test-cluster-server-restart-rr.js @@ -0,0 +1,37 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); + +cluster.schedulingPolicy = cluster.SCHED_RR; + +if (cluster.isMaster) { + const worker1 = cluster.fork(); + worker1.on('listening', common.mustCall(() => { + const worker2 = cluster.fork(); + worker2.on('exit', (code, signal) => { + assert.strictEqual(code, 0, 'worker2 did not exit normally'); + assert.strictEqual(signal, null, 'worker2 did not exit normally'); + worker1.disconnect(); + }); + })); + + worker1.on('exit', common.mustCall((code, signal) => { + assert.strictEqual(code, 0, 'worker1 did not exit normally'); + assert.strictEqual(signal, null, 'worker1 did not exit normally'); + })); +} else { + const net = require('net'); + const server = net.createServer(); + server.listen(common.PORT, common.mustCall(() => { + if (cluster.worker.id === 2) { + server.close(() => { + server.listen(common.PORT, common.mustCall(() => { + server.close(() => { + process.disconnect(); + }); + })); + }); + } + })); +} From 7dbb0d0084373de454b88c789a5de067b3240564 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Sun, 22 May 2016 21:06:42 +0100 Subject: [PATCH 177/261] buffer: fix dataview-set benchmark Improves numbers up to 4x by avoiding repetitive dynamic method lookup. PR-URL: https://github.com/nodejs/node/pull/6922 Reviewed-By: Anna Henningsen Reviewed-By: Trevor Norris Reviewed-By: James M Snell Reviewed-By: Brian White --- benchmark/buffers/dataview-set.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js index ab9c1d1d23b736..be1f6c48876750 100644 --- a/benchmark/buffers/dataview-set.js +++ b/benchmark/buffers/dataview-set.js @@ -40,18 +40,20 @@ function main(conf) { } function benchInt(dv, fn, len, le) { - var m = mod[fn]; + const m = mod[fn]; + const method = dv[fn]; bench.start(); for (var i = 0; i < len; i++) { - dv[fn](0, i % m, le); + method.call(dv, 0, i % m, le); } bench.end(len / 1e6); } function benchFloat(dv, fn, len, le) { + const method = dv[fn]; bench.start(); for (var i = 0; i < len; i++) { - dv[fn](0, i * 0.1, le); + method.call(dv, 0, i * 0.1, le); } bench.end(len / 1e6); } From 855759757acc416f84cdd0b66dd5c655d57e92cb Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 24 Jun 2016 05:50:00 +0200 Subject: [PATCH 178/261] vm: don't print out arrow message for custom error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `AppendExceptionLine()`, which is used both by the `vm` module and the uncaught exception handler, don’t print anything to stderr when called from the `vm` module, even if the thrown object is not a native error instance. Fixes: https://github.com/nodejs/node/issues/7397 PR-URL: https://github.com/nodejs/node/pull/7398 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- src/node.cc | 31 +++++++++++-------- src/node_internals.h | 4 ++- .../message/vm_caught_custom_runtime_error.js | 18 +++++++++++ .../vm_caught_custom_runtime_error.out | 3 ++ 4 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 test/message/vm_caught_custom_runtime_error.js create mode 100644 test/message/vm_caught_custom_runtime_error.out diff --git a/src/node.cc b/src/node.cc index d05237e2b726b4..0a4b9718c02b2a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1439,7 +1439,8 @@ ssize_t DecodeWrite(Isolate* isolate, void AppendExceptionLine(Environment* env, Local er, - Local message) { + Local message, + enum ErrorHandlingMode mode) { if (message.IsEmpty()) return; @@ -1521,19 +1522,23 @@ void AppendExceptionLine(Environment* env, Local arrow_str = String::NewFromUtf8(env->isolate(), arrow); - // Allocation failed, just print it out - if (arrow_str.IsEmpty() || err_obj.IsEmpty() || !err_obj->IsNativeError()) - goto print; - - err_obj->SetHiddenValue(env->arrow_message_string(), arrow_str); - return; + const bool can_set_arrow = !arrow_str.IsEmpty() && !err_obj.IsEmpty(); + // If allocating arrow_str failed, print it out. There's not much else to do. + // If it's not an error, but something needs to be printed out because + // it's a fatal exception, also print it out from here. + // Otherwise, the arrow property will be attached to the object and handled + // by the caller. + if (!can_set_arrow || (mode == FATAL_ERROR && !err_obj->IsNativeError())) { + if (env->printed_error()) + return; + env->set_printed_error(true); - print: - if (env->printed_error()) + uv_tty_reset_mode(); + PrintErrorString("\n%s", arrow); return; - env->set_printed_error(true); - uv_tty_reset_mode(); - PrintErrorString("\n%s", arrow); + } + + err_obj->SetHiddenValue(env->arrow_message_string(), arrow_str); } @@ -1542,7 +1547,7 @@ static void ReportException(Environment* env, Local message) { HandleScope scope(env->isolate()); - AppendExceptionLine(env, er, message); + AppendExceptionLine(env, er, message, FATAL_ERROR); Local trace_value; Local arrow; diff --git a/src/node_internals.h b/src/node_internals.h index 33ae25d6062938..5c94168c916816 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -126,9 +126,11 @@ constexpr size_t arraysize(const T(&)[N]) { return N; } # define NO_RETURN #endif +enum ErrorHandlingMode { FATAL_ERROR, CONTEXTIFY_ERROR }; void AppendExceptionLine(Environment* env, v8::Local er, - v8::Local message); + v8::Local message, + enum ErrorHandlingMode mode = CONTEXTIFY_ERROR); NO_RETURN void FatalError(const char* location, const char* message); diff --git a/test/message/vm_caught_custom_runtime_error.js b/test/message/vm_caught_custom_runtime_error.js new file mode 100644 index 00000000000000..237e8e3a105436 --- /dev/null +++ b/test/message/vm_caught_custom_runtime_error.js @@ -0,0 +1,18 @@ +'use strict'; +require('../common'); +const vm = require('vm'); + +console.error('beginning'); + +// Regression test for https://github.com/nodejs/node/issues/7397: +// vm.runInThisContext() should not print out anything to stderr by itself. +try { + vm.runInThisContext(`throw ({ + name: 'MyCustomError', + message: 'This is a custom message' + })`, { filename: 'test.vm' }); +} catch (e) { + console.error('received error', e.name); +} + +console.error('end'); diff --git a/test/message/vm_caught_custom_runtime_error.out b/test/message/vm_caught_custom_runtime_error.out new file mode 100644 index 00000000000000..9aa1e6c6480e3b --- /dev/null +++ b/test/message/vm_caught_custom_runtime_error.out @@ -0,0 +1,3 @@ +beginning +received error MyCustomError +end From db2b23f06f530157a856dfe33ccab8c763a928ed Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 25 Mar 2016 17:59:07 +0100 Subject: [PATCH 179/261] src: fix sporadic deadlock in SIGUSR1 handler Calling v8::Debug::DebugBreak() directly from the signal handler is unsafe because said function tries to grab a mutex. Work around that by starting a watchdog thread that is woken up from the signal handler, which then calls v8::Debug::DebugBreak(). Using a watchdog thread also removes the need to use atomic operations so this commit does away with that. Fixes: https://github.com/nodejs/node/issues/5368 PR-URL: https://github.com/nodejs/node/pull/5904 Reviewed-By: Anna Henningsen --- src/atomic-polyfill.h | 18 ------- src/node.cc | 115 +++++++++++++++++++++++++++--------------- 2 files changed, 74 insertions(+), 59 deletions(-) delete mode 100644 src/atomic-polyfill.h diff --git a/src/atomic-polyfill.h b/src/atomic-polyfill.h deleted file mode 100644 index 1c5f414fa13a81..00000000000000 --- a/src/atomic-polyfill.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SRC_ATOMIC_POLYFILL_H_ -#define SRC_ATOMIC_POLYFILL_H_ - -#include "util.h" - -namespace nonstd { - -template -struct atomic { - atomic() = default; - T exchange(T value) { return __sync_lock_test_and_set(&value_, value); } - T value_ = T(); - DISALLOW_COPY_AND_ASSIGN(atomic); -}; - -} // namespace nonstd - -#endif // SRC_ATOMIC_POLYFILL_H_ diff --git a/src/node.cc b/src/node.cc index 0a4b9718c02b2a..9ef702d404c457 100644 --- a/src/node.cc +++ b/src/node.cc @@ -73,6 +73,7 @@ #define umask _umask typedef int mode_t; #else +#include #include // getrlimit, setrlimit #include // setuid, getuid #endif @@ -89,14 +90,6 @@ typedef int mode_t; extern char **environ; #endif -#ifdef __APPLE__ -#include "atomic-polyfill.h" // NOLINT(build/include_order) -namespace node { template using atomic = nonstd::atomic; } -#else -#include -namespace node { template using atomic = std::atomic; } -#endif - namespace node { using v8::Array; @@ -166,9 +159,13 @@ static double prog_start_time; static bool debugger_running; static uv_async_t dispatch_debug_messages_async; -static node::atomic node_isolate; +static uv_mutex_t node_isolate_mutex; +static v8::Isolate* node_isolate; static v8::Platform* default_platform; +#ifdef __POSIX__ +static uv_sem_t debug_semaphore; +#endif static void PrintErrorString(const char* format, ...) { va_list ap; @@ -3538,44 +3535,40 @@ static void EnableDebug(Environment* env) { // Called from an arbitrary thread. static void TryStartDebugger() { - // Call only async signal-safe functions here! Don't retry the exchange, - // it will deadlock when the thread is interrupted inside a critical section. - if (auto isolate = node_isolate.exchange(nullptr)) { + uv_mutex_lock(&node_isolate_mutex); + if (auto isolate = node_isolate) { v8::Debug::DebugBreak(isolate); uv_async_send(&dispatch_debug_messages_async); - CHECK_EQ(nullptr, node_isolate.exchange(isolate)); } + uv_mutex_unlock(&node_isolate_mutex); } // Called from the main thread. static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle) { - // Synchronize with signal handler, see TryStartDebugger. - Isolate* isolate; - do { - isolate = node_isolate.exchange(nullptr); - } while (isolate == nullptr); + uv_mutex_lock(&node_isolate_mutex); + if (auto isolate = node_isolate) { + if (debugger_running == false) { + fprintf(stderr, "Starting debugger agent.\n"); - if (debugger_running == false) { - fprintf(stderr, "Starting debugger agent.\n"); + HandleScope scope(isolate); + Environment* env = Environment::GetCurrent(isolate); + Context::Scope context_scope(env->context()); - HandleScope scope(isolate); - Environment* env = Environment::GetCurrent(isolate); - Context::Scope context_scope(env->context()); + StartDebug(env, false); + EnableDebug(env); + } - StartDebug(env, false); - EnableDebug(env); + Isolate::Scope isolate_scope(isolate); + v8::Debug::ProcessDebugMessages(); } - - Isolate::Scope isolate_scope(isolate); - v8::Debug::ProcessDebugMessages(); - CHECK_EQ(nullptr, node_isolate.exchange(isolate)); + uv_mutex_unlock(&node_isolate_mutex); } #ifdef __POSIX__ static void EnableDebugSignalHandler(int signo) { - TryStartDebugger(); + uv_sem_post(&debug_semaphore); } @@ -3614,11 +3607,46 @@ void DebugProcess(const FunctionCallbackInfo& args) { } +inline void* DebugSignalThreadMain(void* unused) { + for (;;) { + uv_sem_wait(&debug_semaphore); + TryStartDebugger(); + } + return nullptr; +} + + static int RegisterDebugSignalHandler() { - // FIXME(bnoordhuis) Should be per-isolate or per-context, not global. + // Start a watchdog thread for calling v8::Debug::DebugBreak() because + // it's not safe to call directly from the signal handler, it can + // deadlock with the thread it interrupts. + CHECK_EQ(0, uv_sem_init(&debug_semaphore, 0)); + pthread_attr_t attr; + CHECK_EQ(0, pthread_attr_init(&attr)); + // Don't shrink the thread's stack on FreeBSD. Said platform decided to + // follow the pthreads specification to the letter rather than in spirit: + // https://lists.freebsd.org/pipermail/freebsd-current/2014-March/048885.html +#ifndef __FreeBSD__ + CHECK_EQ(0, pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN)); +#endif // __FreeBSD__ + CHECK_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); + sigset_t sigmask; + sigfillset(&sigmask); + CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, &sigmask)); + pthread_t thread; + const int err = + pthread_create(&thread, &attr, DebugSignalThreadMain, nullptr); + CHECK_EQ(0, pthread_sigmask(SIG_SETMASK, &sigmask, nullptr)); + CHECK_EQ(0, pthread_attr_destroy(&attr)); + if (err != 0) { + fprintf(stderr, "node[%d]: pthread_create: %s\n", getpid(), strerror(err)); + fflush(stderr); + // Leave SIGUSR1 blocked. We don't install a signal handler, + // receiving the signal would terminate the process. + return -err; + } RegisterSignalHandler(SIGUSR1, EnableDebugSignalHandler); // Unblock SIGUSR1. A pending SIGUSR1 signal will now be delivered. - sigset_t sigmask; sigemptyset(&sigmask); sigaddset(&sigmask, SIGUSR1); CHECK_EQ(0, pthread_sigmask(SIG_UNBLOCK, &sigmask, nullptr)); @@ -3860,6 +3888,8 @@ void Init(int* argc, // Make inherited handles noninheritable. uv_disable_stdio_inheritance(); + CHECK_EQ(0, uv_mutex_init(&node_isolate_mutex)); + // init async debug messages dispatching // Main thread uses uv_default_loop CHECK_EQ(0, uv_async_init(uv_default_loop(), @@ -4146,15 +4176,18 @@ static void StartNodeInstance(void* arg) { params.code_event_handler = vTune::GetVtuneCodeEventHandler(); #endif Isolate* isolate = Isolate::New(params); + + uv_mutex_lock(&node_isolate_mutex); + if (instance_data->is_main()) { + CHECK_EQ(node_isolate, nullptr); + node_isolate = isolate; + } + uv_mutex_unlock(&node_isolate_mutex); + if (track_heap_objects) { isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); } - // Fetch a reference to the main isolate, so we have a reference to it - // even when we need it to access it from another (debugger) thread. - if (instance_data->is_main()) - CHECK_EQ(nullptr, node_isolate.exchange(isolate)); - { Locker locker(isolate); Isolate::Scope isolate_scope(isolate); @@ -4218,10 +4251,10 @@ static void StartNodeInstance(void* arg) { env = nullptr; } - if (instance_data->is_main()) { - // Synchronize with signal handler, see TryStartDebugger. - while (isolate != node_isolate.exchange(nullptr)); // NOLINT - } + uv_mutex_lock(&node_isolate_mutex); + if (node_isolate == isolate) + node_isolate = nullptr; + uv_mutex_unlock(&node_isolate_mutex); CHECK_NE(isolate, nullptr); isolate->Dispose(); From dda81b44b096e5dee604e2f3f6278f41afb40598 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 23 Apr 2016 22:04:30 +0200 Subject: [PATCH 180/261] src: unify implementations of Utf8Value etc. Unify the common code of `Utf8Value`, `TwoByteValue`, `BufferValue` and `StringBytes::InlineDecoder` into one class. Always make the result zero-terminated for the first three. This fixes two problems in passing: * When the conversion of the input value to String fails, make the buffer zero-terminated anyway. Previously, this would have resulted in possibly reading uninitialized data in multiple places in the code. An instance of that problem can be reproduced by running e.g. `valgrind node -e 'net.isIP({ toString() { throw Error() } })'`. * Previously, `BufferValue` copied one byte too much from the source, possibly resulting in an out-of-bounds memory access. This can be reproduced by running e.g. `valgrind node -e \ 'fs.openSync(Buffer.from("node".repeat(8192)), "r")'`. Further minor changes: * This lifts the `out()` method of `StringBytes::InlineDecoder` to the common class so that it can be used when using the overloaded `operator*` does not seem appropiate. * Hopefully clearer variable names. * Add checks to make sure the length of the data does not exceed the allocated storage size, including the possible null terminator. PR-URL: https://github.com/nodejs/node/pull/6357 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Trevor Norris --- src/string_bytes.h | 44 +++++++-------------- src/util.cc | 72 +++++++++++++++++++++++++++------ src/util.h | 99 +++++++++++++++++++++++++++++++++++++++------- 3 files changed, 159 insertions(+), 56 deletions(-) diff --git a/src/string_bytes.h b/src/string_bytes.h index 79520d24705ac0..fa5a7ca697586f 100644 --- a/src/string_bytes.h +++ b/src/string_bytes.h @@ -7,22 +7,14 @@ #include "node.h" #include "env.h" #include "env-inl.h" +#include "util.h" namespace node { class StringBytes { public: - class InlineDecoder { + class InlineDecoder : public MaybeStackBuffer { public: - InlineDecoder() : out_(nullptr) { - } - - ~InlineDecoder() { - if (out_ != out_st_) - delete[] out_; - out_ = nullptr; - } - inline bool Decode(Environment* env, v8::Local string, v8::Local encoding, @@ -33,28 +25,22 @@ class StringBytes { return false; } - size_t buflen = StringBytes::StorageSize(env->isolate(), string, enc); - if (buflen > sizeof(out_st_)) - out_ = new char[buflen]; - else - out_ = out_st_; - size_ = StringBytes::Write(env->isolate(), - out_, - buflen, - string, - enc); + const size_t storage = StringBytes::StorageSize(env->isolate(), + string, + enc); + AllocateSufficientStorage(storage); + const size_t length = StringBytes::Write(env->isolate(), + out(), + storage, + string, + enc); + + // No zero terminator is included when using this method. + SetLength(length); return true; } - inline const char* out() const { return out_; } - inline size_t size() const { return size_; } - - private: - static const int kStorageSize = 1024; - - char out_st_[kStorageSize]; - char* out_; - size_t size_; + inline size_t size() const { return length(); } }; // Does the string match the encoding? Quick but non-exhaustive. diff --git a/src/util.cc b/src/util.cc index 858e4b396534b3..f597015331d7f7 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1,32 +1,78 @@ #include "util.h" +#include "node_buffer.h" #include "string_bytes.h" namespace node { -Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local value) - : length_(0), str_(str_st_) { - // Make sure result is always zero-terminated, even if conversion to string - // fails. - str_st_[0] = '\0'; +using v8::Isolate; +using v8::Local; +using v8::String; +using v8::Value; +template +static void MakeUtf8String(Isolate* isolate, + Local value, + T* target) { + Local string = value->ToString(isolate); + if (string.IsEmpty()) + return; + + const size_t storage = StringBytes::StorageSize(isolate, string, UTF8) + 1; + target->AllocateSufficientStorage(storage); + const int flags = + String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8; + const int length = string->WriteUtf8(target->out(), storage, 0, flags); + target->SetLengthAndZeroTerminate(length); +} + +Utf8Value::Utf8Value(Isolate* isolate, Local value) { if (value.IsEmpty()) return; + MakeUtf8String(isolate, value, this); +} + + +TwoByteValue::TwoByteValue(Isolate* isolate, Local value) { + if (value.IsEmpty()) { + return; + } + v8::Local string = value->ToString(isolate); if (string.IsEmpty()) return; // Allocate enough space to include the null terminator - size_t len = StringBytes::StorageSize(isolate, string, UTF8) + 1; - if (len > sizeof(str_st_)) { - str_ = static_cast(malloc(len)); - CHECK_NE(str_, nullptr); - } + const size_t storage = string->Length() + 1; + AllocateSufficientStorage(storage); const int flags = - v8::String::NO_NULL_TERMINATION | v8::String::REPLACE_INVALID_UTF8; - length_ = string->WriteUtf8(str_, len, 0, flags); - str_[length_] = '\0'; + String::NO_NULL_TERMINATION | String::REPLACE_INVALID_UTF8; + const int length = string->Write(out(), 0, storage, flags); + SetLengthAndZeroTerminate(length); +} + +BufferValue::BufferValue(Isolate* isolate, Local value) { + // Slightly different take on Utf8Value. If value is a String, + // it will return a Utf8 encoded string. If value is a Buffer, + // it will copy the data out of the Buffer as is. + if (value.IsEmpty()) { + // Dereferencing this object will return nullptr. + Invalidate(); + return; + } + + if (value->IsString()) { + MakeUtf8String(isolate, value, this); + } else if (Buffer::HasInstance(value)) { + const size_t len = Buffer::Length(value); + // Leave place for the terminating '\0' byte. + AllocateSufficientStorage(len + 1); + memcpy(out(), Buffer::Data(value), len); + SetLengthAndZeroTerminate(len); + } else { + Invalidate(); + } } } // namespace node diff --git a/src/util.h b/src/util.h index 671b98dd25b191..dce6c343b1b443 100644 --- a/src/util.h +++ b/src/util.h @@ -184,31 +184,102 @@ inline char ToLower(char c); // strcasecmp() is locale-sensitive. Use StringEqualNoCase() instead. inline bool StringEqualNoCase(const char* a, const char* b); -class Utf8Value { +// Allocates an array of member type T. For up to kStackStorageSize items, +// the stack is used, otherwise malloc(). +template +class MaybeStackBuffer { public: - explicit Utf8Value(v8::Isolate* isolate, v8::Local value); + const T* out() const { + return buf_; + } - ~Utf8Value() { - if (str_ != str_st_) - free(str_); + T* out() { + return buf_; } - char* operator*() { - return str_; - }; + // operator* for compatibility with `v8::String::(Utf8)Value` + T* operator*() { + return buf_; + } - const char* operator*() const { - return str_; - }; + const T* operator*() const { + return buf_; + } size_t length() const { return length_; - }; + } + + // Call to make sure enough space for `storage` entries is available. + // There can only be 1 call to AllocateSufficientStorage or Invalidate + // per instance. + void AllocateSufficientStorage(size_t storage) { + if (storage <= kStackStorageSize) { + buf_ = buf_st_; + } else { + // Guard against overflow. + CHECK_LE(storage, sizeof(T) * storage); + + buf_ = static_cast(malloc(sizeof(T) * storage)); + CHECK_NE(buf_, nullptr); + } + + // Remember how much was allocated to check against that in SetLength(). + length_ = storage; + } + + void SetLength(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length, length_); + length_ = length; + } + + void SetLengthAndZeroTerminate(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length + 1, length_); + SetLength(length); + + // T() is 0 for integer types, nullptr for pointers, etc. + buf_[length] = T(); + } + + // Make derefencing this object return nullptr. + // Calling this is mutually exclusive with calling + // AllocateSufficientStorage. + void Invalidate() { + CHECK_EQ(buf_, buf_st_); + length_ = 0; + buf_ = nullptr; + } + MaybeStackBuffer() : length_(0), buf_(buf_st_) { + // Default to a zero-length, null-terminated buffer. + buf_[0] = T(); + } + + ~MaybeStackBuffer() { + if (buf_ != buf_st_) + free(buf_); + } private: size_t length_; - char* str_; - char str_st_[1024]; + T* buf_; + T buf_st_[kStackStorageSize]; +}; + +class Utf8Value : public MaybeStackBuffer { + public: + explicit Utf8Value(v8::Isolate* isolate, v8::Local value); +}; + +class TwoByteValue : public MaybeStackBuffer { + public: + explicit TwoByteValue(v8::Isolate* isolate, v8::Local value); +}; + +class BufferValue : public MaybeStackBuffer { + public: + explicit BufferValue(v8::Isolate* isolate, v8::Local value); }; } // namespace node From 391fc804872372c906c799433ba5b8b219106ed0 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 181/261] tools: update cpplint to r456 PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- tools/cpplint.py | 5090 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 4024 insertions(+), 1066 deletions(-) diff --git a/tools/cpplint.py b/tools/cpplint.py index a120fe77600a7b..94913206f9bf2b 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -28,44 +28,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# Here are some issues that I've had people identify in my code during reviews, -# that I think are possible to flag automatically in a lint tool. If these were -# caught by lint, it would save time both for myself and that of my reviewers. -# Most likely, some of these are beyond the scope of the current lint framework, -# but I think it is valuable to retain these wish-list items even if they cannot -# be immediately implemented. -# -# Suggestions -# ----------- -# - Check for no 'explicit' for multi-arg ctor -# - Check for boolean assign RHS in parens -# - Check for ctor initializer-list colon position and spacing -# - Check that if there's a ctor, there should be a dtor -# - Check accessors that return non-pointer member variables are -# declared const -# - Check accessors that return non-const pointer member vars are -# *not* declared const -# - Check for using public includes for testing -# - Check for spaces between brackets in one-line inline method -# - Check for no assert() -# - Check for spaces surrounding operators -# - Check for 0 in pointer context (should be NULL) -# - Check for 0 in char context (should be '\0') -# - Check for camel-case method name conventions for methods -# that are not simple inline getters and setters -# - Check that base classes have virtual destructors -# put " // namespace" after } that closes a namespace, with -# namespace's name after 'namespace' if it is named. -# - Do not indent namespace contents -# - Avoid inlining non-trivial constructors in header files -# include base/basictypes.h if DISALLOW_EVIL_CONSTRUCTORS is used -# - Check for old-school (void) cast for call-sites of functions -# ignored return value -# - Check gUnit usage of anonymous namespace -# - Check for class declaration order (typedefs, consts, enums, -# ctor(s?), dtor, friend declarations, methods, member vars) -# - """Does google-lint on c++ files. The goal of this script is to identify places in the code that *may* @@ -80,6 +42,7 @@ """ import codecs +import copy import getopt import math # for log import os @@ -88,16 +51,16 @@ import string import sys import unicodedata -import logging -logger = logging.getLogger('testrunner') + _USAGE = """ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] - [--counting=total|toplevel|detailed] + [--counting=total|toplevel|detailed] [--root=subdir] + [--linelength=digits] [file] ... The style guidelines this tries to follow are those in - http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml + https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml Every problem is given a confidence score from 1-5, with 5 meaning we are certain of the problem, and 1 meaning it could be a legitimate construct. @@ -108,7 +71,8 @@ suppresses errors of all categories on that line. The files passed in will be linted; at least one file must be provided. - Linted extensions are .cc, .cpp, and .h. Other file types will be ignored. + Default linted extensions are .cc, .cpp, .cu, .cuh and .h. Change the + extensions with the --extensions flag. Flags: @@ -141,123 +105,342 @@ also be printed. If 'detailed' is provided, then a count is provided for each category like 'build/class'. - logfile=filename - Write TAP output to a logfile. + root=subdir + The root directory used for deriving header guard CPP variable. + By default, the header guard CPP variable is calculated as the relative + path to the directory that contains .git, .hg, or .svn. When this flag + is specified, the relative path is calculated from the specified + directory. If the specified directory does not exist, this flag is + ignored. + + Examples: + Assuming that src/.git exists, the header guard CPP variables for + src/chrome/browser/ui/browser.h are: + + No flag => CHROME_BROWSER_UI_BROWSER_H_ + --root=chrome => BROWSER_UI_BROWSER_H_ + --root=chrome/browser => UI_BROWSER_H_ + + linelength=digits + This is the allowed line length for the project. The default value is + 80 characters. + + Examples: + --linelength=120 + + extensions=extension,extension,... + The allowed file extensions that cpplint will check + + Examples: + --extensions=hpp,cpp + + cpplint.py supports per-directory configurations specified in CPPLINT.cfg + files. CPPLINT.cfg file can contain a number of key=value pairs. + Currently the following options are supported: + + set noparent + filter=+filter1,-filter2,... + exclude_files=regex + linelength=80 + + "set noparent" option prevents cpplint from traversing directory tree + upwards looking for more .cfg files in parent directories. This option + is usually placed in the top-level project directory. + + The "filter" option is similar in function to --filter flag. It specifies + message filters in addition to the |_DEFAULT_FILTERS| and those specified + through --filter command-line flag. + + "exclude_files" allows to specify a regular expression to be matched against + a file name. If the expression matches, the file is skipped and not run + through liner. + + "linelength" allows to specify the allowed line length for the project. + + CPPLINT.cfg has an effect on files in the same directory and all + sub-directories, unless overridden by a nested configuration file. + + Example file: + filter=-build/include_order,+build/include_alpha + exclude_files=.*\.cc + + The above example disables build/include_order warning and enables + build/include_alpha as well as excludes all .cc from being + processed by linter, in the current directory (where the .cfg + file is located) and all sub-directories. """ # We categorize each error message we print. Here are the categories. # We want an explicit list so we can list them all in cpplint --filter=. # If you add a new error message with a new category, add it to the list # here! cpplint_unittest.py should tell you if you forget to do this. -# \ used for clearer layout -- pylint: disable-msg=C6013 _ERROR_CATEGORIES = [ - 'build/class', - 'build/deprecated', - 'build/endif_comment', - 'build/forward_decl', - 'build/header_guard', - 'build/include', - 'build/include_alpha', - 'build/include_order', - 'build/include_what_you_use', - 'build/namespaces', - 'build/printf_format', - 'build/storage_class', - 'legal/copyright', - 'readability/braces', - 'readability/casting', - 'readability/check', - 'readability/constructors', - 'readability/fn_size', - 'readability/function', - 'readability/multiline_comment', - 'readability/multiline_string', - 'readability/nolint', - 'readability/streams', - 'readability/todo', - 'readability/utf8', - 'runtime/arrays', - 'runtime/casting', - 'runtime/explicit', - 'runtime/int', - 'runtime/init', - 'runtime/invalid_increment', - 'runtime/member_string_references', - 'runtime/memset', - 'runtime/operator', - 'runtime/printf', - 'runtime/printf_format', - 'runtime/references', - 'runtime/rtti', - 'runtime/sizeof', - 'runtime/string', - 'runtime/threadsafe_fn', - 'runtime/virtual', - 'whitespace/blank_line', - 'whitespace/braces', - 'whitespace/comma', - 'whitespace/comments', - 'whitespace/end_of_line', - 'whitespace/ending_newline', - 'whitespace/indent', - 'whitespace/labels', - 'whitespace/line_length', - 'whitespace/newline', - 'whitespace/operators', - 'whitespace/parens', - 'whitespace/semicolon', - 'whitespace/tab', - 'whitespace/todo' - ] - -# The default state of the category filter. This is overrided by the --filter= + 'build/class', + 'build/c++11', + 'build/c++14', + 'build/c++tr1', + 'build/deprecated', + 'build/endif_comment', + 'build/explicit_make_pair', + 'build/forward_decl', + 'build/header_guard', + 'build/include', + 'build/include_alpha', + 'build/include_order', + 'build/include_what_you_use', + 'build/namespaces', + 'build/printf_format', + 'build/storage_class', + 'legal/copyright', + 'readability/alt_tokens', + 'readability/braces', + 'readability/casting', + 'readability/check', + 'readability/constructors', + 'readability/fn_size', + 'readability/inheritance', + 'readability/multiline_comment', + 'readability/multiline_string', + 'readability/namespace', + 'readability/nolint', + 'readability/nul', + 'readability/strings', + 'readability/todo', + 'readability/utf8', + 'runtime/arrays', + 'runtime/casting', + 'runtime/explicit', + 'runtime/int', + 'runtime/init', + 'runtime/invalid_increment', + 'runtime/member_string_references', + 'runtime/memset', + 'runtime/indentation_namespace', + 'runtime/operator', + 'runtime/printf', + 'runtime/printf_format', + 'runtime/references', + 'runtime/string', + 'runtime/threadsafe_fn', + 'runtime/vlog', + 'whitespace/blank_line', + 'whitespace/braces', + 'whitespace/comma', + 'whitespace/comments', + 'whitespace/empty_conditional_body', + 'whitespace/empty_if_body', + 'whitespace/empty_loop_body', + 'whitespace/end_of_line', + 'whitespace/ending_newline', + 'whitespace/forcolon', + 'whitespace/indent', + 'whitespace/line_length', + 'whitespace/newline', + 'whitespace/operators', + 'whitespace/parens', + 'whitespace/semicolon', + 'whitespace/tab', + 'whitespace/todo', + ] + +# These error categories are no longer enforced by cpplint, but for backwards- +# compatibility they may still appear in NOLINT comments. +_LEGACY_ERROR_CATEGORIES = [ + 'readability/streams', + 'readability/function', + ] + +# The default state of the category filter. This is overridden by the --filter= # flag. By default all errors are on, so only add here categories that should be # off by default (i.e., categories that must be enabled by the --filter= flags). # All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = [ '-build/include_alpha', '-legal/copyright' ] +_DEFAULT_FILTERS = ['-build/include_alpha'] + +# The default list of categories suppressed for C (not C++) files. +_DEFAULT_C_SUPPRESSED_CATEGORIES = [ + 'readability/casting', + ] + +# The default list of categories suppressed for Linux Kernel files. +_DEFAULT_KERNEL_SUPPRESSED_CATEGORIES = [ + 'whitespace/tab', + ] # We used to check for high-bit characters, but after much discussion we # decided those were OK, as long as they were in UTF-8 and didn't represent -# hard-coded international strings, which belong in a seperate i18n file. - -# Headers that we consider STL headers. -_STL_HEADERS = frozenset([ - 'algobase.h', 'algorithm', 'alloc.h', 'bitset', 'deque', 'exception', - 'function.h', 'functional', 'hash_map', 'hash_map.h', 'hash_set', - 'hash_set.h', 'iterator', 'list', 'list.h', 'map', 'memory', 'new', - 'pair.h', 'pthread_alloc', 'queue', 'set', 'set.h', 'sstream', 'stack', - 'stl_alloc.h', 'stl_relops.h', 'type_traits.h', - 'utility', 'vector', 'vector.h', - ]) +# hard-coded international strings, which belong in a separate i18n file. - -# Non-STL C++ system headers. +# C++ headers _CPP_HEADERS = frozenset([ - 'algo.h', 'builtinbuf.h', 'bvector.h', 'cassert', 'cctype', - 'cerrno', 'cfloat', 'ciso646', 'climits', 'clocale', 'cmath', - 'complex', 'complex.h', 'csetjmp', 'csignal', 'cstdarg', 'cstddef', - 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype', - 'defalloc.h', 'deque.h', 'editbuf.h', 'exception', 'fstream', - 'fstream.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip', - 'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream.h', - 'iterator.h', 'limits', 'map.h', 'multimap.h', 'multiset.h', - 'numeric', 'ostream.h', 'parsestream.h', 'pfstream.h', 'PlotFile.h', - 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', 'ropeimpl.h', - 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', - 'stdiostream.h', 'streambuf.h', 'stream.h', 'strfile.h', 'string', - 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', 'valarray', + # Legacy + 'algobase.h', + 'algo.h', + 'alloc.h', + 'builtinbuf.h', + 'bvector.h', + 'complex.h', + 'defalloc.h', + 'deque.h', + 'editbuf.h', + 'fstream.h', + 'function.h', + 'hash_map', + 'hash_map.h', + 'hash_set', + 'hash_set.h', + 'hashtable.h', + 'heap.h', + 'indstream.h', + 'iomanip.h', + 'iostream.h', + 'istream.h', + 'iterator.h', + 'list.h', + 'map.h', + 'multimap.h', + 'multiset.h', + 'ostream.h', + 'pair.h', + 'parsestream.h', + 'pfstream.h', + 'procbuf.h', + 'pthread_alloc', + 'pthread_alloc.h', + 'rope', + 'rope.h', + 'ropeimpl.h', + 'set.h', + 'slist', + 'slist.h', + 'stack.h', + 'stdiostream.h', + 'stl_alloc.h', + 'stl_relops.h', + 'streambuf.h', + 'stream.h', + 'strfile.h', + 'strstream.h', + 'tempbuf.h', + 'tree.h', + 'type_traits.h', + 'vector.h', + # 17.6.1.2 C++ library headers + 'algorithm', + 'array', + 'atomic', + 'bitset', + 'chrono', + 'codecvt', + 'complex', + 'condition_variable', + 'deque', + 'exception', + 'forward_list', + 'fstream', + 'functional', + 'future', + 'initializer_list', + 'iomanip', + 'ios', + 'iosfwd', + 'iostream', + 'istream', + 'iterator', + 'limits', + 'list', + 'locale', + 'map', + 'memory', + 'mutex', + 'new', + 'numeric', + 'ostream', + 'queue', + 'random', + 'ratio', + 'regex', + 'scoped_allocator', + 'set', + 'sstream', + 'stack', + 'stdexcept', + 'streambuf', + 'string', + 'strstream', + 'system_error', + 'thread', + 'tuple', + 'typeindex', + 'typeinfo', + 'type_traits', + 'unordered_map', + 'unordered_set', + 'utility', + 'valarray', + 'vector', + # 17.6.1.2 C++ headers for C library facilities + 'cassert', + 'ccomplex', + 'cctype', + 'cerrno', + 'cfenv', + 'cfloat', + 'cinttypes', + 'ciso646', + 'climits', + 'clocale', + 'cmath', + 'csetjmp', + 'csignal', + 'cstdalign', + 'cstdarg', + 'cstdbool', + 'cstddef', + 'cstdint', + 'cstdio', + 'cstdlib', + 'cstring', + 'ctgmath', + 'ctime', + 'cuchar', + 'cwchar', + 'cwctype', ]) +# Type names +_TYPES = re.compile( + r'^(?:' + # [dcl.type.simple] + r'(char(16_t|32_t)?)|wchar_t|' + r'bool|short|int|long|signed|unsigned|float|double|' + # [support.types] + r'(ptrdiff_t|size_t|max_align_t|nullptr_t)|' + # [cstdint.syn] + r'(u?int(_fast|_least)?(8|16|32|64)_t)|' + r'(u?int(max|ptr)_t)|' + r')$') + + +# These headers are excluded from [build/include] and [build/include_order] +# checks: +# - Anything not following google file name conventions (containing an +# uppercase character, such as Python.h or nsStringAPI.h, for example). +# - Lua headers. +_THIRD_PARTY_HEADERS_PATTERN = re.compile( + r'^(?:[^/]*[A-Z][^/]*\.h|lua\.h|lauxlib\.h|lualib\.h)$') + +# Pattern for matching FileInfo.BaseName() against test file name +_TEST_FILE_SUFFIX = r'(_test|_unittest|_regtest)$' + +# Pattern that matches only complete whitespace, possibly across multiple lines. +_EMPTY_CONDITIONAL_BODY_PATTERN = re.compile(r'^\s*$', re.DOTALL) # Assertion macros. These are defined in base/logging.h and -# testing/base/gunit.h. Note that the _M versions need to come first -# for substring matching to work. +# testing/base/public/gunit.h. _CHECK_MACROS = [ 'DCHECK', 'CHECK', - 'EXPECT_TRUE_M', 'EXPECT_TRUE', - 'ASSERT_TRUE_M', 'ASSERT_TRUE', - 'EXPECT_FALSE_M', 'EXPECT_FALSE', - 'ASSERT_FALSE_M', 'ASSERT_FALSE', + 'EXPECT_TRUE', 'ASSERT_TRUE', + 'EXPECT_FALSE', 'ASSERT_FALSE', ] # Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE @@ -270,38 +453,92 @@ _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement - _CHECK_REPLACEMENT['EXPECT_TRUE_M'][op] = 'EXPECT_%s_M' % replacement - _CHECK_REPLACEMENT['ASSERT_TRUE_M'][op] = 'ASSERT_%s_M' % replacement for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), ('>=', 'LT'), ('>', 'LE'), ('<=', 'GT'), ('<', 'GE')]: _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement - _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement - _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement + +# Alternative tokens and their replacements. For full list, see section 2.5 +# Alternative tokens [lex.digraph] in the C++ standard. +# +# Digraphs (such as '%:') are not included here since it's a mess to +# match those on a word boundary. +_ALT_TOKEN_REPLACEMENT = { + 'and': '&&', + 'bitor': '|', + 'or': '||', + 'xor': '^', + 'compl': '~', + 'bitand': '&', + 'and_eq': '&=', + 'or_eq': '|=', + 'xor_eq': '^=', + 'not': '!', + 'not_eq': '!=' + } + +# Compile regular expression that matches all the above keywords. The "[ =()]" +# bit is meant to avoid matching these keywords outside of boolean expressions. +# +# False positives include C-style multi-line comments and multi-line strings +# but those have always been troublesome for cpplint. +_ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( + r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') # These constants define types of headers for use with # _IncludeState.CheckNextIncludeOrder(). -_LIKELY_MY_HEADER = 1 -_POSSIBLE_MY_HEADER = 2 -_OTHER_HEADER = 3 -_C_SYS_HEADER = 4 -_CPP_SYS_HEADER = 5 - +_C_SYS_HEADER = 1 +_CPP_SYS_HEADER = 2 +_LIKELY_MY_HEADER = 3 +_POSSIBLE_MY_HEADER = 4 +_OTHER_HEADER = 5 + +# These constants define the current inline assembly state +_NO_ASM = 0 # Outside of inline assembly block +_INSIDE_ASM = 1 # Inside inline assembly block +_END_ASM = 2 # Last line of inline assembly block +_BLOCK_ASM = 3 # The whole block is an inline assembly block + +# Match start of assembly blocks +_MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)' + r'(?:\s+(volatile|__volatile__))?' + r'\s*[{(]') + +# Match strings that indicate we're working on a C (not C++) file. +_SEARCH_C_FILE = re.compile(r'\b(?:LINT_C_FILE|' + r'vim?:\s*.*(\s*|:)filetype=c(\s*|:|$))') + +# Match string that indicates we're working on a Linux Kernel file. +_SEARCH_KERNEL_FILE = re.compile(r'\b(?:LINT_KERNEL_FILE)') _regexp_compile_cache = {} -# Finds occurrences of NOLINT or NOLINT(...). -_RE_SUPPRESSION = re.compile(r'\bNOLINT\b(\([^)]*\))?') - # {str, set(int)}: a map from error categories to sets of linenumbers # on which those errors are expected and should be suppressed. _error_suppressions = {} +# The root directory used for deriving header guard CPP variable. +# This is set by --root flag. +_root = None + +# The allowed line length of files. +# This is set by --linelength flag. +_line_length = 80 + +# The allowed extensions for file names +# This is set by --extensions flag. +_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh']) + +# {str, bool}: a map from error categories to booleans which indicate if the +# category should be suppressed for every line. +_global_error_suppressions = {} + + def ParseNolintSuppressions(filename, raw_line, linenum, error): - """Updates the global list of error-suppressions. + """Updates the global list of line error-suppressions. Parses any NOLINT comments on the current line, updating the global error_suppressions store. Reports an error if the NOLINT comment @@ -313,64 +550,113 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error): linenum: int, the number of the current line. error: function, an error handler. """ - # FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*). - m = _RE_SUPPRESSION.search(raw_line) - if m: - category = m.group(1) + matched = Search(r'\bNOLINT(NEXTLINE)?\b(\([^)]+\))?', raw_line) + if matched: + if matched.group(1): + suppressed_line = linenum + 1 + else: + suppressed_line = linenum + category = matched.group(2) if category in (None, '(*)'): # => "suppress all" - _error_suppressions.setdefault(None, set()).add(linenum) + _error_suppressions.setdefault(None, set()).add(suppressed_line) else: if category.startswith('(') and category.endswith(')'): category = category[1:-1] if category in _ERROR_CATEGORIES: - _error_suppressions.setdefault(category, set()).add(linenum) - else: + _error_suppressions.setdefault(category, set()).add(suppressed_line) + elif category not in _LEGACY_ERROR_CATEGORIES: error(filename, linenum, 'readability/nolint', 5, - 'Unknown NOLINT error category: %s' % category) + 'Unknown NOLINT error category: %s' % category) + + +def ProcessGlobalSuppresions(lines): + """Updates the list of global error suppressions. + + Parses any lint directives in the file that have global effect. + + Args: + lines: An array of strings, each representing a line of the file, with the + last element being empty if the file is terminated with a newline. + """ + for line in lines: + if _SEARCH_C_FILE.search(line): + for category in _DEFAULT_C_SUPPRESSED_CATEGORIES: + _global_error_suppressions[category] = True + if _SEARCH_KERNEL_FILE.search(line): + for category in _DEFAULT_KERNEL_SUPPRESSED_CATEGORIES: + _global_error_suppressions[category] = True def ResetNolintSuppressions(): - "Resets the set of NOLINT suppressions to empty." + """Resets the set of NOLINT suppressions to empty.""" _error_suppressions.clear() + _global_error_suppressions.clear() def IsErrorSuppressedByNolint(category, linenum): """Returns true if the specified error category is suppressed on this line. Consults the global error_suppressions map populated by - ParseNolintSuppressions/ResetNolintSuppressions. + ParseNolintSuppressions/ProcessGlobalSuppresions/ResetNolintSuppressions. Args: category: str, the category of the error. linenum: int, the current line number. Returns: - bool, True iff the error should be suppressed due to a NOLINT comment. + bool, True iff the error should be suppressed due to a NOLINT comment or + global suppression. """ - return (linenum in _error_suppressions.get(category, set()) or + return (_global_error_suppressions.get(category, False) or + linenum in _error_suppressions.get(category, set()) or linenum in _error_suppressions.get(None, set())) + def Match(pattern, s): """Matches the string with the pattern, caching the compiled regexp.""" # The regexp compilation caching is inlined in both Match and Search for # performance reasons; factoring it out into a separate function turns out # to be noticeably expensive. - if not pattern in _regexp_compile_cache: + if pattern not in _regexp_compile_cache: _regexp_compile_cache[pattern] = sre_compile.compile(pattern) return _regexp_compile_cache[pattern].match(s) +def ReplaceAll(pattern, rep, s): + """Replaces instances of pattern in a string with a replacement. + + The compiled regex is kept in a cache shared by Match and Search. + + Args: + pattern: regex pattern + rep: replacement text + s: search string + + Returns: + string with replacements made (or original string if no replacements) + """ + if pattern not in _regexp_compile_cache: + _regexp_compile_cache[pattern] = sre_compile.compile(pattern) + return _regexp_compile_cache[pattern].sub(rep, s) + + def Search(pattern, s): """Searches the string for the pattern, caching the compiled regexp.""" - if not pattern in _regexp_compile_cache: + if pattern not in _regexp_compile_cache: _regexp_compile_cache[pattern] = sre_compile.compile(pattern) return _regexp_compile_cache[pattern].search(s) -class _IncludeState(dict): +def _IsSourceExtension(s): + """File extension (excluding dot) matches a source file extension.""" + return s in ('c', 'cc', 'cpp', 'cxx') + + +class _IncludeState(object): """Tracks line numbers for includes, and the order in which includes appear. - As a dict, an _IncludeState object serves as a mapping between include - filename and line number on which that file was included. + include_list contains list of lists of (header, line number) pairs. + It's a lists of lists rather than just one flat list to make it + easier to update across preprocessor boundaries. Call CheckNextIncludeOrder() once for each header in the file, passing in the type constants defined above. Calls in an illegal order will @@ -381,9 +667,9 @@ class _IncludeState(dict): # needs to move backwards, CheckNextIncludeOrder will raise an error. _INITIAL_SECTION = 0 _MY_H_SECTION = 1 - _OTHER_H_SECTION = 2 - _C_SECTION = 3 - _CPP_SECTION = 4 + _C_SECTION = 2 + _CPP_SECTION = 3 + _OTHER_H_SECTION = 4 _TYPE_NAMES = { _C_SYS_HEADER: 'C system header', @@ -401,14 +687,47 @@ class _IncludeState(dict): } def __init__(self): - dict.__init__(self) + self.include_list = [[]] + self.ResetSection('') + + def FindHeader(self, header): + """Check if a header has already been included. + + Args: + header: header to check. + Returns: + Line number of previous occurrence, or -1 if the header has not + been seen before. + """ + for section_list in self.include_list: + for f in section_list: + if f[0] == header: + return f[1] + return -1 + + def ResetSection(self, directive): + """Reset section checking for preprocessor directive. + + Args: + directive: preprocessor directive (e.g. "if", "else"). + """ # The name of the current section. self._section = self._INITIAL_SECTION # The path of last found header. self._last_header = '' + # Update list of includes. Note that we never pop from the + # include list. + if directive in ('if', 'ifdef', 'ifndef'): + self.include_list.append([]) + elif directive in ('else', 'elif'): + self.include_list[-1] = [] + + def SetLastHeader(self, header_path): + self._last_header = header_path + def CanonicalizeAlphabeticalOrder(self, header_path): - """Returns a path canonicalized for alphabetical comparisson. + """Returns a path canonicalized for alphabetical comparison. - replaces "-" with "_" so they both cmp the same. - removes '-inl' since we don't require them to be after the main header. @@ -422,19 +741,25 @@ def CanonicalizeAlphabeticalOrder(self, header_path): """ return header_path.replace('-inl.h', '.h').replace('-', '_').lower() - def IsInAlphabeticalOrder(self, header_path): + def IsInAlphabeticalOrder(self, clean_lines, linenum, header_path): """Check if a header is in alphabetical order with the previous header. Args: - header_path: Header to be checked. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + header_path: Canonicalized header to be checked. Returns: Returns true if the header is in alphabetical order. """ - canonical_header = self.CanonicalizeAlphabeticalOrder(header_path) - if self._last_header > canonical_header: + # If previous section is different from current section, _last_header will + # be reset to empty string, so it's always less than current header. + # + # If previous line was a blank line, assume that the headers are + # intentionally sorted the way they are. + if (self._last_header > header_path and + Match(r'^\s*#\s*include\b', clean_lines.elided[linenum - 1])): return False - self._last_header = canonical_header return True def CheckNextIncludeOrder(self, header_type): @@ -457,32 +782,33 @@ def CheckNextIncludeOrder(self, header_type): last_section = self._section - if header_type == _LIKELY_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION + if header_type == _C_SYS_HEADER: + if self._section <= self._C_SECTION: + self._section = self._C_SECTION else: self._last_header = '' return error_message - elif header_type == _POSSIBLE_MY_HEADER: - if self._section <= self._MY_H_SECTION: - self._section = self._MY_H_SECTION + elif header_type == _CPP_SYS_HEADER: + if self._section <= self._CPP_SECTION: + self._section = self._CPP_SECTION else: self._last_header = '' return error_message - elif header_type == _OTHER_HEADER: - if self._section <= self._OTHER_H_SECTION: - self._section = self._OTHER_H_SECTION + elif header_type == _LIKELY_MY_HEADER: + if self._section <= self._MY_H_SECTION: + self._section = self._MY_H_SECTION else: - self._last_header = '' - return error_message - elif header_type == _C_SYS_HEADER: - if self._section <= self._C_SECTION: - self._section = self._C_SECTION + self._section = self._OTHER_H_SECTION + elif header_type == _POSSIBLE_MY_HEADER: + if self._section <= self._MY_H_SECTION: + self._section = self._MY_H_SECTION else: - self._section = self._CPP_SECTION + # This will always be the fallback because we're not sure + # enough that the header is associated with this file. + self._section = self._OTHER_H_SECTION else: - assert header_type == _CPP_SYS_HEADER - self._section = self._CPP_SECTION + assert header_type == _OTHER_HEADER + self._section = self._OTHER_H_SECTION if last_section != self._section: self._last_header = '' @@ -498,6 +824,8 @@ def __init__(self): self.error_count = 0 # global count of reported errors # filters to apply when emitting error messages self.filters = _DEFAULT_FILTERS[:] + # backup of filter list. Used to restore the state after each file. + self._filters_backup = self.filters[:] self.counting = 'total' # In what way are we counting errors? self.errors_by_category = {} # string to int dict storing error counts @@ -536,6 +864,10 @@ def SetFilters(self, filters): """ # Default filters always have less priority than the flag ones. self.filters = _DEFAULT_FILTERS[:] + self.AddFilters(filters) + + def AddFilters(self, filters): + """ Adds more filters to the existing list of error-message filters. """ for filt in filters.split(','): clean_filt = filt.strip() if clean_filt: @@ -545,10 +877,13 @@ def SetFilters(self, filters): raise ValueError('Every filter in --filters must start with + or -' ' (%s does not)' % filt) - def setOutputFile(self, filename): - """attempts to create a file which we write output to.""" - fh = logging.FileHandler(filename, mode='wb') - logger.addHandler(fh) + def BackupFilters(self): + """ Saves the current filter list to backup storage.""" + self._filters_backup = self.filters[:] + + def RestoreFilters(self): + """ Restores filters previously backed up.""" + self.filters = self._filters_backup[:] def ResetErrorCounts(self): """Sets the module's error statistic back to zero.""" @@ -567,11 +902,10 @@ def IncrementErrorCount(self, category): def PrintErrorCounts(self): """Print a summary of errors by category, and the total.""" - if not _cpplint_state.output_format == 'tap': - for category, count in self.errors_by_category.iteritems(): - sys.stderr.write('Category \'%s\' errors found: %d\n' % - (category, count)) - sys.stderr.write('Total errors found: %d\n' % self.error_count) + for category, count in self.errors_by_category.iteritems(): + sys.stderr.write('Category \'%s\' errors found: %d\n' % + (category, count)) + sys.stderr.write('Total errors found: %d\n' % self.error_count) _cpplint_state = _CppLintState() @@ -618,9 +952,25 @@ def _SetFilters(filters): """ _cpplint_state.SetFilters(filters) -def _setOutputFile(filename): - _cpplint_state.setOutputFile(filename) +def _AddFilters(filters): + """Adds more filter overrides. + Unlike _SetFilters, this function does not reset the current list of filters + available. + + Args: + filters: A string of comma-separated filters (eg "whitespace/indent"). + Each filter should start with + or -; else we die. + """ + _cpplint_state.AddFilters(filters) + +def _BackupFilters(): + """ Saves the current filter list to backup storage.""" + _cpplint_state.BackupFilters() + +def _RestoreFilters(): + """ Restores filters previously backed up.""" + _cpplint_state.RestoreFilters() class _FunctionState(object): """Tracks current function name and the number of lines in its body.""" @@ -656,6 +1006,9 @@ def Check(self, error, filename, linenum): filename: The name of the current file. linenum: The number of the line to check. """ + if not self.in_a_function: + return + if Match(r'T(EST|est)', self.current_function): base_trigger = self._TEST_TRIGGER else: @@ -674,7 +1027,7 @@ def Check(self, error, filename, linenum): self.current_function, self.lines_in_function, trigger)) def End(self): - """Stop analizing function body.""" + """Stop analyzing function body.""" self.in_a_function = False @@ -683,7 +1036,7 @@ class _IncludeError(Exception): pass -class FileInfo: +class FileInfo(object): """Provides utility functions for filenames. FileInfo provides easy access to the components of a file's path @@ -708,10 +1061,40 @@ def RepositoryName(self): locations won't see bogus errors. """ fullname = self.FullName() - # XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory. - toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) - prefix = os.path.commonprefix([fullname, toplevel]) - return fullname[len(prefix) + 1:] + + if os.path.exists(fullname): + project_dir = os.path.dirname(fullname) + + if os.path.exists(os.path.join(project_dir, ".svn")): + # If there's a .svn file in the current directory, we recursively look + # up the directory tree for the top of the SVN checkout + root_dir = project_dir + one_up_dir = os.path.dirname(root_dir) + while os.path.exists(os.path.join(one_up_dir, ".svn")): + root_dir = os.path.dirname(root_dir) + one_up_dir = os.path.dirname(one_up_dir) + + prefix = os.path.commonprefix([root_dir, project_dir]) + return fullname[len(prefix) + 1:] + + # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by + # searching up from the current path. + root_dir = current_dir = os.path.dirname(fullname) + while current_dir != os.path.dirname(current_dir): + if (os.path.exists(os.path.join(current_dir, ".git")) or + os.path.exists(os.path.join(current_dir, ".hg")) or + os.path.exists(os.path.join(current_dir, ".svn"))): + root_dir = current_dir + current_dir = os.path.dirname(current_dir) + + if (os.path.exists(os.path.join(root_dir, ".git")) or + os.path.exists(os.path.join(root_dir, ".hg")) or + os.path.exists(os.path.join(root_dir, ".svn"))): + prefix = os.path.commonprefix([root_dir, project_dir]) + return fullname[len(prefix) + 1:] + + # Don't know what to do; header guard warnings may be wrong... + return fullname def Split(self): """Splits the file into the directory, basename, and extension. @@ -741,18 +1124,18 @@ def NoExtension(self): def IsSource(self): """File has a source file extension.""" - return self.Extension()[1:] in ('c', 'cc', 'cpp', 'cxx') + return _IsSourceExtension(self.Extension()[1:]) def _ShouldPrintError(category, confidence, linenum): - """Returns true iff confidence >= verbose, category passes - filter and is not NOLINT-suppressed.""" + """If confidence >= verbose, category passes filter and is not suppressed.""" # There are three ways we might decide not to print an error message: # a "NOLINT(category)" comment appears in the source, # the verbosity level isn't high enough, or the filters filter it out. if IsErrorSuppressedByNolint(category, linenum): return False + if confidence < _cpplint_state.verbose_level: return False @@ -799,28 +1182,20 @@ def Error(filename, linenum, category, confidence, message): if _cpplint_state.output_format == 'vs7': sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) - elif _cpplint_state.output_format == 'tap': - template = ('not ok %s\n' - ' ---\n' - ' message: %s\n' - ' data:\n' - ' line: %d\n' - ' ruleId: %s\n' - ' ...') - logger.info(template % (filename, message, linenum, category)) + elif _cpplint_state.output_format == 'eclipse': + sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( + filename, linenum, message, category, confidence)) else: sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) -# Matches standard C++ escape esequences per 2.13.2.3 of the C++ standard. +# Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. _RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)') -# Matches strings. Escape codes should already be removed by ESCAPES. -_RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES = re.compile(r'"[^"]*"') -# Matches characters. Escape codes should already be removed by ESCAPES. -_RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES = re.compile(r"'.'") -# Matches multi-line C++ comments. +# Match a single C style comment on the same line. +_RE_PATTERN_C_COMMENTS = r'/\*(?:[^*]|\*(?!/))*\*/' +# Matches multi-line C style comments. # This RE is a little bit more complicated than one might expect, because we # have to take care of space removals tools so we can handle comments inside # statements better. @@ -829,10 +1204,10 @@ def Error(filename, linenum, category, confidence, message): # if this doesn't work we try on left side but only if there's a non-character # on the right. _RE_PATTERN_CLEANSE_LINE_C_COMMENTS = re.compile( - r"""(\s*/\*.*\*/\s*$| - /\*.*\*/\s+| - \s+/\*.*\*/(?=\W)| - /\*.*\*/)""", re.VERBOSE) + r'(\s*' + _RE_PATTERN_C_COMMENTS + r'\s*$|' + + _RE_PATTERN_C_COMMENTS + r'\s+|' + + r'\s+' + _RE_PATTERN_C_COMMENTS + r'(?=\W)|' + + _RE_PATTERN_C_COMMENTS + r')') def IsCppString(line): @@ -852,6 +1227,82 @@ def IsCppString(line): return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1 +def CleanseRawStrings(raw_lines): + """Removes C++11 raw strings from lines. + + Before: + static const char kData[] = R"( + multi-line string + )"; + + After: + static const char kData[] = "" + (replaced by blank line) + ""; + + Args: + raw_lines: list of raw lines. + + Returns: + list of lines with C++11 raw strings replaced by empty strings. + """ + + delimiter = None + lines_without_raw_strings = [] + for line in raw_lines: + if delimiter: + # Inside a raw string, look for the end + end = line.find(delimiter) + if end >= 0: + # Found the end of the string, match leading space for this + # line and resume copying the original lines, and also insert + # a "" on the last line. + leading_space = Match(r'^(\s*)\S', line) + line = leading_space.group(1) + '""' + line[end + len(delimiter):] + delimiter = None + else: + # Haven't found the end yet, append a blank line. + line = '""' + + # Look for beginning of a raw string, and replace them with + # empty strings. This is done in a loop to handle multiple raw + # strings on the same line. + while delimiter is None: + # Look for beginning of a raw string. + # See 2.14.15 [lex.string] for syntax. + # + # Once we have matched a raw string, we check the prefix of the + # line to make sure that the line is not part of a single line + # comment. It's done this way because we remove raw strings + # before removing comments as opposed to removing comments + # before removing raw strings. This is because there are some + # cpplint checks that requires the comments to be preserved, but + # we don't want to check comments that are inside raw strings. + matched = Match(r'^(.*?)\b(?:R|u8R|uR|UR|LR)"([^\s\\()]*)\((.*)$', line) + if (matched and + not Match(r'^([^\'"]|\'(\\.|[^\'])*\'|"(\\.|[^"])*")*//', + matched.group(1))): + delimiter = ')' + matched.group(2) + '"' + + end = matched.group(3).find(delimiter) + if end >= 0: + # Raw string ended on same line + line = (matched.group(1) + '""' + + matched.group(3)[end + len(delimiter):]) + delimiter = None + else: + # Start of a multi-line raw string + line = matched.group(1) + '""' + else: + break + + lines_without_raw_strings.append(line) + + # TODO(unknown): if delimiter is not None here, we might want to + # emit a warning for unterminated string. + return lines_without_raw_strings + + def FindNextMultiLineCommentStart(lines, lineix): """Find the beginning marker for a multiline comment.""" while lineix < len(lines): @@ -877,7 +1328,7 @@ def RemoveMultiLineCommentsFromRange(lines, begin, end): # Having // dummy comments makes the lines non-empty, so we will not get # unnecessary blank line warnings later in the code. for i in range(begin, end): - lines[i] = '// dummy' + lines[i] = '/**/' def RemoveMultiLineComments(filename, lines, error): @@ -907,18 +1358,20 @@ def CleanseComments(line): """ commentpos = line.find('//') if commentpos != -1 and not IsCppString(line[:commentpos]): - line = line[:commentpos] + line = line[:commentpos].rstrip() # get rid of /* ... */ return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) class CleansedLines(object): - """Holds 3 copies of all lines with different preprocessing applied to them. - - 1) elided member contains lines without strings and comments, - 2) lines member contains lines without comments, and - 3) raw member contains all the lines without processing. - All these three members are of , and of the same length. + """Holds 4 copies of all lines with different preprocessing applied to them. + + 1) elided member contains lines without strings and comments. + 2) lines member contains lines without comments. + 3) raw_lines member contains all the lines without processing. + 4) lines_without_raw_strings member is same as raw_lines, but with C++11 raw + strings removed. + All these members are of , and of the same length. """ def __init__(self, lines): @@ -926,9 +1379,11 @@ def __init__(self, lines): self.lines = [] self.raw_lines = lines self.num_lines = len(lines) - for linenum in range(len(lines)): - self.lines.append(CleanseComments(lines[linenum])) - elided = self._CollapseStrings(lines[linenum]) + self.lines_without_raw_strings = CleanseRawStrings(lines) + for linenum in range(len(self.lines_without_raw_strings)): + self.lines.append(CleanseComments( + self.lines_without_raw_strings[linenum])) + elided = self._CollapseStrings(self.lines_without_raw_strings[linenum]) self.elided.append(CleanseComments(elided)) def NumLines(self): @@ -947,22 +1402,151 @@ def _CollapseStrings(elided): Returns: The line with collapsed strings. """ - if not _RE_PATTERN_INCLUDE.match(elided): - # Remove escaped characters first to make quote/single quote collapsing - # basic. Things that look like escaped characters shouldn't occur - # outside of strings and chars. - elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) - elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided) - elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided) - return elided + if _RE_PATTERN_INCLUDE.match(elided): + return elided + + # Remove escaped characters first to make quote/single quote collapsing + # basic. Things that look like escaped characters shouldn't occur + # outside of strings and chars. + elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) + + # Replace quoted strings and digit separators. Both single quotes + # and double quotes are processed in the same loop, otherwise + # nested quotes wouldn't work. + collapsed = '' + while True: + # Find the first quote character + match = Match(r'^([^\'"]*)([\'"])(.*)$', elided) + if not match: + collapsed += elided + break + head, quote, tail = match.groups() + + if quote == '"': + # Collapse double quoted strings + second_quote = tail.find('"') + if second_quote >= 0: + collapsed += head + '""' + elided = tail[second_quote + 1:] + else: + # Unmatched double quote, don't bother processing the rest + # of the line since this is probably a multiline string. + collapsed += elided + break + else: + # Found single quote, check nearby text to eliminate digit separators. + # + # There is no special handling for floating point here, because + # the integer/fractional/exponent parts would all be parsed + # correctly as long as there are digits on both sides of the + # separator. So we are fine as long as we don't see something + # like "0.'3" (gcc 4.9.0 will not allow this literal). + if Search(r'\b(?:0[bBxX]?|[1-9])[0-9a-fA-F]*$', head): + match_literal = Match(r'^((?:\'?[0-9a-zA-Z_])*)(.*)$', "'" + tail) + collapsed += head + match_literal.group(1).replace("'", '') + elided = match_literal.group(2) + else: + second_quote = tail.find('\'') + if second_quote >= 0: + collapsed += head + "''" + elided = tail[second_quote + 1:] + else: + # Unmatched single quote + collapsed += elided + break + + return collapsed + + +def FindEndOfExpressionInLine(line, startpos, stack): + """Find the position just after the end of current parenthesized expression. + + Args: + line: a CleansedLines line. + startpos: start searching at this position. + stack: nesting stack at startpos. + + Returns: + On finding matching end: (index just after matching end, None) + On finding an unclosed expression: (-1, None) + Otherwise: (-1, new stack at end of this line) + """ + for i in xrange(startpos, len(line)): + char = line[i] + if char in '([{': + # Found start of parenthesized expression, push to expression stack + stack.append(char) + elif char == '<': + # Found potential start of template argument list + if i > 0 and line[i - 1] == '<': + # Left shift operator + if stack and stack[-1] == '<': + stack.pop() + if not stack: + return (-1, None) + elif i > 0 and Search(r'\boperator\s*$', line[0:i]): + # operator<, don't add to stack + continue + else: + # Tentative start of template argument list + stack.append('<') + elif char in ')]}': + # Found end of parenthesized expression. + # + # If we are currently expecting a matching '>', the pending '<' + # must have been an operator. Remove them from expression stack. + while stack and stack[-1] == '<': + stack.pop() + if not stack: + return (-1, None) + if ((stack[-1] == '(' and char == ')') or + (stack[-1] == '[' and char == ']') or + (stack[-1] == '{' and char == '}')): + stack.pop() + if not stack: + return (i + 1, None) + else: + # Mismatched parentheses + return (-1, None) + elif char == '>': + # Found potential end of template argument list. + + # Ignore "->" and operator functions + if (i > 0 and + (line[i - 1] == '-' or Search(r'\boperator\s*$', line[0:i - 1]))): + continue + + # Pop the stack if there is a matching '<'. Otherwise, ignore + # this '>' since it must be an operator. + if stack: + if stack[-1] == '<': + stack.pop() + if not stack: + return (i + 1, None) + elif char == ';': + # Found something that look like end of statements. If we are currently + # expecting a '>', the matching '<' must have been an operator, since + # template argument list should not contain statements. + while stack and stack[-1] == '<': + stack.pop() + if not stack: + return (-1, None) + + # Did not find end of expression or unbalanced parentheses on this line + return (-1, stack) def CloseExpression(clean_lines, linenum, pos): - """If input points to ( or { or [, finds the position that closes it. + """If input points to ( or { or [ or <, finds the position that closes it. - If lines[linenum][pos] points to a '(' or '{' or '[', finds the the + If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the linenum/pos that correspond to the closing of the expression. + TODO(unknown): cpplint spends a fair bit of time matching parentheses. + Ideally we would want to index all opening and closing parentheses once + and have CloseExpression be just a simple lookup, but due to preprocessor + tricks, this is not so easy. + Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. @@ -976,24 +1560,139 @@ def CloseExpression(clean_lines, linenum, pos): """ line = clean_lines.elided[linenum] - startchar = line[pos] - if startchar not in '({[': + if (line[pos] not in '({[<') or Match(r'<[<=]', line[pos:]): return (line, clean_lines.NumLines(), -1) - if startchar == '(': endchar = ')' - if startchar == '[': endchar = ']' - if startchar == '{': endchar = '}' - num_open = line.count(startchar) - line.count(endchar) - while linenum < clean_lines.NumLines() and num_open > 0: + # Check first line + (end_pos, stack) = FindEndOfExpressionInLine(line, pos, []) + if end_pos > -1: + return (line, linenum, end_pos) + + # Continue scanning forward + while stack and linenum < clean_lines.NumLines() - 1: linenum += 1 line = clean_lines.elided[linenum] - num_open += line.count(startchar) - line.count(endchar) - # OK, now find the endchar that actually got us back to even - endpos = len(line) - while num_open >= 0: - endpos = line.rfind(')', 0, endpos) - num_open -= 1 # chopped off another ) - return (line, linenum, endpos + 1) + (end_pos, stack) = FindEndOfExpressionInLine(line, 0, stack) + if end_pos > -1: + return (line, linenum, end_pos) + + # Did not find end of expression before end of file, give up + return (line, clean_lines.NumLines(), -1) + + +def FindStartOfExpressionInLine(line, endpos, stack): + """Find position at the matching start of current expression. + + This is almost the reverse of FindEndOfExpressionInLine, but note + that the input position and returned position differs by 1. + + Args: + line: a CleansedLines line. + endpos: start searching at this position. + stack: nesting stack at endpos. + + Returns: + On finding matching start: (index at matching start, None) + On finding an unclosed expression: (-1, None) + Otherwise: (-1, new stack at beginning of this line) + """ + i = endpos + while i >= 0: + char = line[i] + if char in ')]}': + # Found end of expression, push to expression stack + stack.append(char) + elif char == '>': + # Found potential end of template argument list. + # + # Ignore it if it's a "->" or ">=" or "operator>" + if (i > 0 and + (line[i - 1] == '-' or + Match(r'\s>=\s', line[i - 1:]) or + Search(r'\boperator\s*$', line[0:i]))): + i -= 1 + else: + stack.append('>') + elif char == '<': + # Found potential start of template argument list + if i > 0 and line[i - 1] == '<': + # Left shift operator + i -= 1 + else: + # If there is a matching '>', we can pop the expression stack. + # Otherwise, ignore this '<' since it must be an operator. + if stack and stack[-1] == '>': + stack.pop() + if not stack: + return (i, None) + elif char in '([{': + # Found start of expression. + # + # If there are any unmatched '>' on the stack, they must be + # operators. Remove those. + while stack and stack[-1] == '>': + stack.pop() + if not stack: + return (-1, None) + if ((char == '(' and stack[-1] == ')') or + (char == '[' and stack[-1] == ']') or + (char == '{' and stack[-1] == '}')): + stack.pop() + if not stack: + return (i, None) + else: + # Mismatched parentheses + return (-1, None) + elif char == ';': + # Found something that look like end of statements. If we are currently + # expecting a '<', the matching '>' must have been an operator, since + # template argument list should not contain statements. + while stack and stack[-1] == '>': + stack.pop() + if not stack: + return (-1, None) + + i -= 1 + + return (-1, stack) + + +def ReverseCloseExpression(clean_lines, linenum, pos): + """If input points to ) or } or ] or >, finds the position that opens it. + + If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the + linenum/pos that correspond to the opening of the expression. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + pos: A position on the line. + + Returns: + A tuple (line, linenum, pos) pointer *at* the opening brace, or + (line, 0, -1) if we never find the matching opening brace. Note + we ignore strings and comments when matching; and the line we + return is the 'cleansed' line at linenum. + """ + line = clean_lines.elided[linenum] + if line[pos] not in ')}]>': + return (line, 0, -1) + + # Check last line + (start_pos, stack) = FindStartOfExpressionInLine(line, pos, []) + if start_pos > -1: + return (line, linenum, start_pos) + + # Continue scanning backward + while stack and linenum > 0: + linenum -= 1 + line = clean_lines.elided[linenum] + (start_pos, stack) = FindStartOfExpressionInLine(line, len(line) - 1, stack) + if start_pos > -1: + return (line, linenum, start_pos) + + # Did not find start of expression before beginning of file, give up + return (line, 0, -1) def CheckForCopyright(filename, lines, error): @@ -1009,6 +1708,22 @@ def CheckForCopyright(filename, lines, error): 'You should have a line: "Copyright [year] "') +def GetIndentLevel(line): + """Return the number of leading spaces in line. + + Args: + line: A string to check. + + Returns: + An integer count of leading spaces, possibly zero. + """ + indent = Match(r'^( *)\S', line) + if indent: + return len(indent.group(1)) + else: + return 0 + + def GetHeaderGuardCPPVariable(filename): """Returns the CPP variable that should be used as a header guard. @@ -1024,12 +1739,18 @@ def GetHeaderGuardCPPVariable(filename): # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) + filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename) + # Replace 'c++' with 'cpp'. + filename = filename.replace('C++', 'cpp').replace('c++', 'cpp') fileinfo = FileInfo(filename) - return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' + file_path_from_root = fileinfo.RepositoryName() + if _root: + file_path_from_root = re.sub('^' + _root + os.sep, '', file_path_from_root) + return re.sub(r'[^a-zA-Z0-9]', '_', file_path_from_root).upper() + '_' -def CheckForHeaderGuard(filename, lines, error): +def CheckForHeaderGuard(filename, clean_lines, error): """Checks that the file contains a header guard. Logs an error if no #ifndef header guard is present. For other @@ -1037,18 +1758,29 @@ def CheckForHeaderGuard(filename, lines, error): Args: filename: The name of the C++ header file. - lines: An array of strings, each representing a line of the file. + clean_lines: A CleansedLines instance containing the file. error: The function to call with any errors found. """ + # Don't check for header guards if there are error suppression + # comments somewhere in this file. + # + # Because this is silencing a warning for a nonexistent line, we + # only support the very specific NOLINT(build/header_guard) syntax, + # and not the general NOLINT or NOLINT(*) syntax. + raw_lines = clean_lines.lines_without_raw_strings + for i in raw_lines: + if Search(r'//\s*NOLINT\(build/header_guard\)', i): + return + cppvar = GetHeaderGuardCPPVariable(filename) - ifndef = None + ifndef = '' ifndef_linenum = 0 - define = None - endif = None + define = '' + endif = '' endif_linenum = 0 - for linenum, line in enumerate(lines): + for linenum, line in enumerate(raw_lines): linesplit = line.split() if len(linesplit) >= 2: # find the first occurrence of #ifndef and #define, save arg @@ -1076,31 +1808,82 @@ def CheckForHeaderGuard(filename, lines, error): if ifndef != cppvar + '_': error_level = 5 - ParseNolintSuppressions(filename, lines[ifndef_linenum], ifndef_linenum, + ParseNolintSuppressions(filename, raw_lines[ifndef_linenum], ifndef_linenum, error) error(filename, ifndef_linenum, 'build/header_guard', error_level, '#ifndef header guard has wrong style, please use: %s' % cppvar) - if (endif != ('#endif // %s' % cppvar) and - endif != ('#endif /* %s */' % cppvar)): - error_level = 0 - if (endif != ('#endif // %s' % (cppvar + '_')) and - endif != ('#endif /* %s */' % (cppvar + '_'))): - error_level = 5 + # Check for "//" comments on endif line. + ParseNolintSuppressions(filename, raw_lines[endif_linenum], endif_linenum, + error) + match = Match(r'#endif\s*//\s*' + cppvar + r'(_)?\b', endif) + if match: + if match.group(1) == '_': + # Issue low severity warning for deprecated double trailing underscore + error(filename, endif_linenum, 'build/header_guard', 0, + '#endif line should be "#endif // %s"' % cppvar) + return - ParseNolintSuppressions(filename, lines[endif_linenum], endif_linenum, - error) - error(filename, endif_linenum, 'build/header_guard', error_level, - '#endif line should be "#endif // %s"' % cppvar) + # Didn't find the corresponding "//" comment. If this file does not + # contain any "//" comments at all, it could be that the compiler + # only wants "/**/" comments, look for those instead. + no_single_line_comments = True + for i in xrange(1, len(raw_lines) - 1): + line = raw_lines[i] + if Match(r'^(?:(?:\'(?:\.|[^\'])*\')|(?:"(?:\.|[^"])*")|[^\'"])*//', line): + no_single_line_comments = False + break + + if no_single_line_comments: + match = Match(r'#endif\s*/\*\s*' + cppvar + r'(_)?\s*\*/', endif) + if match: + if match.group(1) == '_': + # Low severity warning for double trailing underscore + error(filename, endif_linenum, 'build/header_guard', 0, + '#endif line should be "#endif /* %s */"' % cppvar) + return + + # Didn't find anything + error(filename, endif_linenum, 'build/header_guard', 5, + '#endif line should be "#endif // %s"' % cppvar) + + +def CheckHeaderFileIncluded(filename, include_state, error): + """Logs an error if a .cc file does not include its header.""" + + # Do not check test files + fileinfo = FileInfo(filename) + if Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()): + return + + headerfile = filename[0:len(filename) - len(fileinfo.Extension())] + '.h' + if not os.path.exists(headerfile): + return + headername = FileInfo(headerfile).RepositoryName() + first_include = 0 + for section_list in include_state.include_list: + for f in section_list: + if headername in f[0] or f[0] in headername: + return + if not first_include: + first_include = f[1] + + error(filename, first_include, 'build/include', 5, + '%s should include its header file %s' % (fileinfo.RepositoryName(), + headername)) + + +def CheckForBadCharacters(filename, lines, error): + """Logs an error for each line containing bad characters. + Two kinds of bad characters: -def CheckForUnicodeReplacementCharacters(filename, lines, error): - """Logs an error for each line containing Unicode replacement characters. + 1. Unicode replacement characters: These indicate that either the file + contained invalid UTF-8 (likely) or Unicode replacement characters (which + it shouldn't). Note that it's possible for this to throw off line + numbering if the invalid UTF-8 occurred adjacent to a newline. - These indicate that either the file contained invalid UTF-8 (likely) - or Unicode replacement characters (which it shouldn't). Note that - it's possible for this to throw off line numbering if the invalid - UTF-8 occurred adjacent to a newline. + 2. NUL bytes. These are problematic for some tools. Args: filename: The name of the current file. @@ -1111,6 +1894,8 @@ def CheckForUnicodeReplacementCharacters(filename, lines, error): if u'\ufffd' in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') + if '\0' in line: + error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') def CheckForNewlineAtEOF(filename, lines, error): @@ -1165,24 +1950,37 @@ def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): if (line.count('"') - line.count('\\"')) % 2: error(filename, linenum, 'readability/multiline_string', 5, 'Multi-line string ("...") found. This lint script doesn\'t ' - 'do well with such strings, and may give bogus warnings. They\'re ' - 'ugly and unnecessary, and you should use concatenation instead".') - - -threading_list = ( - ('asctime(', 'asctime_r('), - ('ctime(', 'ctime_r('), - ('getgrgid(', 'getgrgid_r('), - ('getgrnam(', 'getgrnam_r('), - ('getlogin(', 'getlogin_r('), - ('getpwnam(', 'getpwnam_r('), - ('getpwuid(', 'getpwuid_r('), - ('gmtime(', 'gmtime_r('), - ('localtime(', 'localtime_r('), - ('rand(', 'rand_r('), - ('readdir(', 'readdir_r('), - ('strtok(', 'strtok_r('), - ('ttyname(', 'ttyname_r('), + 'do well with such strings, and may give bogus warnings. ' + 'Use C++11 raw strings or concatenation instead.') + + +# (non-threadsafe name, thread-safe alternative, validation pattern) +# +# The validation pattern is used to eliminate false positives such as: +# _rand(); // false positive due to substring match. +# ->rand(); // some member function rand(). +# ACMRandom rand(seed); // some variable named rand. +# ISAACRandom rand(); // another variable named rand. +# +# Basically we require the return value of these functions to be used +# in some expression context on the same line by matching on some +# operator before the function name. This eliminates constructors and +# member function calls. +_UNSAFE_FUNC_PREFIX = r'(?:[-+*/=%^&|(<]\s*|>\s+)' +_THREADING_LIST = ( + ('asctime(', 'asctime_r(', _UNSAFE_FUNC_PREFIX + r'asctime\([^)]+\)'), + ('ctime(', 'ctime_r(', _UNSAFE_FUNC_PREFIX + r'ctime\([^)]+\)'), + ('getgrgid(', 'getgrgid_r(', _UNSAFE_FUNC_PREFIX + r'getgrgid\([^)]+\)'), + ('getgrnam(', 'getgrnam_r(', _UNSAFE_FUNC_PREFIX + r'getgrnam\([^)]+\)'), + ('getlogin(', 'getlogin_r(', _UNSAFE_FUNC_PREFIX + r'getlogin\(\)'), + ('getpwnam(', 'getpwnam_r(', _UNSAFE_FUNC_PREFIX + r'getpwnam\([^)]+\)'), + ('getpwuid(', 'getpwuid_r(', _UNSAFE_FUNC_PREFIX + r'getpwuid\([^)]+\)'), + ('gmtime(', 'gmtime_r(', _UNSAFE_FUNC_PREFIX + r'gmtime\([^)]+\)'), + ('localtime(', 'localtime_r(', _UNSAFE_FUNC_PREFIX + r'localtime\([^)]+\)'), + ('rand(', 'rand_r(', _UNSAFE_FUNC_PREFIX + r'rand\(\)'), + ('strtok(', 'strtok_r(', + _UNSAFE_FUNC_PREFIX + r'strtok\([^)]+\)'), + ('ttyname(', 'ttyname_r(', _UNSAFE_FUNC_PREFIX + r'ttyname\([^)]+\)'), ) @@ -1202,17 +2000,34 @@ def CheckPosixThreading(filename, clean_lines, linenum, error): error: The function to call with any errors found. """ line = clean_lines.elided[linenum] - for single_thread_function, multithread_safe_function in threading_list: - ix = line.find(single_thread_function) - # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 - if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and - line[ix - 1] not in ('_', '.', '>'))): + for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST: + # Additional pattern matching check to confirm that this is the + # function we are looking for + if Search(pattern, line): error(filename, linenum, 'runtime/threadsafe_fn', 2, - 'Consider using ' + multithread_safe_function + - '...) instead of ' + single_thread_function + + 'Consider using ' + multithread_safe_func + + '...) instead of ' + single_thread_func + '...) for improved thread safety.') +def CheckVlogArguments(filename, clean_lines, linenum, error): + """Checks that VLOG() is only used for defining a logging level. + + For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and + VLOG(FATAL) are not. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + if Search(r'\bVLOG\((INFO|ERROR|WARNING|DFATAL|FATAL)\)', line): + error(filename, linenum, 'runtime/vlog', 5, + 'VLOG() should be used with numeric verbosity level. ' + 'Use LOG() if you want symbolic severity levels.') + # Matches invalid increment: *count++, which moves pointer instead of # incrementing a value. _RE_PATTERN_INVALID_INCREMENT = re.compile( @@ -1241,75 +2056,620 @@ def CheckInvalidIncrement(filename, clean_lines, linenum, error): 'Changing pointer instead of value (or unused value of operator*).') -class _ClassInfo(object): - """Stores information about a class.""" +def IsMacroDefinition(clean_lines, linenum): + if Search(r'^#define', clean_lines[linenum]): + return True - def __init__(self, name, linenum): - self.name = name - self.linenum = linenum - self.seen_open_brace = False - self.is_derived = False - self.virtual_method_linenumber = None - self.has_virtual_destructor = False - self.brace_depth = 0 + if linenum > 0 and Search(r'\\$', clean_lines[linenum - 1]): + return True + return False -class _ClassState(object): - """Holds the current state of the parse relating to class declarations. - It maintains a stack of _ClassInfos representing the parser's guess - as to the current nesting of class declarations. The innermost class - is at the top (back) of the stack. Typically, the stack will either - be empty or have exactly one entry. - """ +def IsForwardClassDeclaration(clean_lines, linenum): + return Match(r'^\s*(\btemplate\b)*.*class\s+\w+;\s*$', clean_lines[linenum]) - def __init__(self): - self.classinfo_stack = [] - def CheckFinished(self, filename, error): - """Checks that all classes have been completely parsed. +class _BlockInfo(object): + """Stores information about a generic block of code.""" + + def __init__(self, linenum, seen_open_brace): + self.starting_linenum = linenum + self.seen_open_brace = seen_open_brace + self.open_parentheses = 0 + self.inline_asm = _NO_ASM + self.check_namespace_indentation = False + + def CheckBegin(self, filename, clean_lines, linenum, error): + """Run checks that applies to text up to the opening brace. + + This is mostly for checking the text after the class identifier + and the "{", usually where the base class is specified. For other + blocks, there isn't much to check, so we always pass. - Call this when all lines in a file have been processed. Args: filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. error: The function to call with any errors found. """ - if self.classinfo_stack: - # Note: This test can result in false positives if #ifdef constructs - # get in the way of brace matching. See the testBuildClass test in - # cpplint_unittest.py for an example of this. - error(filename, self.classinfo_stack[0].linenum, 'build/class', 5, - 'Failed to find complete declaration of class %s' % - self.classinfo_stack[0].name) - - -def CheckForNonStandardConstructs(filename, clean_lines, linenum, - class_state, error): - """Logs an error if we see certain non-ANSI constructs ignored by gcc-2. + pass - Complain about several constructs which gcc-2 accepts, but which are - not standard C++. Warning about these in lint is one way to ease the - transition to new compilers. - - put storage class first (e.g. "static const" instead of "const static"). - - "%lld" instead of %qd" in printf-type functions. - - "%1$d" is non-standard in printf-type functions. - - "\%" is an undefined character escape sequence. - - text after #endif is not allowed. - - invalid inner-style forward declaration. - - >? and ?= and ." with the + # period at the end. + # + # Besides these, we don't accept anything else, otherwise we might + # get false negatives when existing comment is a substring of the + # expected namespace. + if self.name: + # Named namespace + if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' + + re.escape(self.name) + r'[\*/\.\\\s]*$'), + line): + error(filename, linenum, 'readability/namespace', 5, + 'Namespace should be terminated with "// namespace %s"' % + self.name) + else: + # Anonymous namespace + if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): + # If "// namespace anonymous" or "// anonymous namespace (more text)", + # mention "// anonymous namespace" as an acceptable form + if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line): + error(filename, linenum, 'readability/namespace', 5, + 'Anonymous namespace should be terminated with "// namespace"' + ' or "// anonymous namespace"') + else: + error(filename, linenum, 'readability/namespace', 5, + 'Anonymous namespace should be terminated with "// namespace"') + + +class _PreprocessorInfo(object): + """Stores checkpoints of nesting stacks when #if/#else is seen.""" + + def __init__(self, stack_before_if): + # The entire nesting stack before #if + self.stack_before_if = stack_before_if + + # The entire nesting stack up to #else + self.stack_before_else = [] + + # Whether we have already seen #else or #elif + self.seen_else = False + + +class NestingState(object): + """Holds states related to parsing braces.""" + + def __init__(self): + # Stack for tracking all braces. An object is pushed whenever we + # see a "{", and popped when we see a "}". Only 3 types of + # objects are possible: + # - _ClassInfo: a class or struct. + # - _NamespaceInfo: a namespace. + # - _BlockInfo: some other type of block. + self.stack = [] + + # Top of the previous stack before each Update(). + # + # Because the nesting_stack is updated at the end of each line, we + # had to do some convoluted checks to find out what is the current + # scope at the beginning of the line. This check is simplified by + # saving the previous top of nesting stack. + # + # We could save the full stack, but we only need the top. Copying + # the full nesting stack would slow down cpplint by ~10%. + self.previous_stack_top = [] + + # Stack of _PreprocessorInfo objects. + self.pp_stack = [] + + def SeenOpenBrace(self): + """Check if we have seen the opening brace for the innermost block. + + Returns: + True if we have seen the opening brace, False if the innermost + block is still expecting an opening brace. + """ + return (not self.stack) or self.stack[-1].seen_open_brace + + def InNamespaceBody(self): + """Check if we are currently one level inside a namespace body. + + Returns: + True if top of the stack is a namespace block, False otherwise. + """ + return self.stack and isinstance(self.stack[-1], _NamespaceInfo) + + def InExternC(self): + """Check if we are currently one level inside an 'extern "C"' block. + + Returns: + True if top of the stack is an extern block, False otherwise. + """ + return self.stack and isinstance(self.stack[-1], _ExternCInfo) + + def InClassDeclaration(self): + """Check if we are currently one level inside a class or struct declaration. + + Returns: + True if top of the stack is a class/struct, False otherwise. + """ + return self.stack and isinstance(self.stack[-1], _ClassInfo) + + def InAsmBlock(self): + """Check if we are currently one level inside an inline ASM block. + + Returns: + True if the top of the stack is a block containing inline ASM. + """ + return self.stack and self.stack[-1].inline_asm != _NO_ASM + + def InTemplateArgumentList(self, clean_lines, linenum, pos): + """Check if current position is inside template argument list. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + pos: position just after the suspected template argument. + Returns: + True if (linenum, pos) is inside template arguments. + """ + while linenum < clean_lines.NumLines(): + # Find the earliest character that might indicate a template argument + line = clean_lines.elided[linenum] + match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:]) + if not match: + linenum += 1 + pos = 0 + continue + token = match.group(1) + pos += len(match.group(0)) + + # These things do not look like template argument list: + # class Suspect { + # class Suspect x; } + if token in ('{', '}', ';'): return False + + # These things look like template argument list: + # template + # template + # template + # template + if token in ('>', '=', '[', ']', '.'): return True + + # Check if token is an unmatched '<'. + # If not, move on to the next character. + if token != '<': + pos += 1 + if pos >= len(line): + linenum += 1 + pos = 0 + continue + + # We can't be sure if we just find a single '<', and need to + # find the matching '>'. + (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) + if end_pos < 0: + # Not sure if template argument list or syntax error in file + return False + linenum = end_line + pos = end_pos + return False + + def UpdatePreprocessor(self, line): + """Update preprocessor stack. + + We need to handle preprocessors due to classes like this: + #ifdef SWIG + struct ResultDetailsPageElementExtensionPoint { + #else + struct ResultDetailsPageElementExtensionPoint : public Extension { + #endif + + We make the following assumptions (good enough for most files): + - Preprocessor condition evaluates to true from #if up to first + #else/#elif/#endif. + + - Preprocessor condition evaluates to false from #else/#elif up + to #endif. We still perform lint checks on these lines, but + these do not affect nesting stack. + + Args: + line: current line to check. + """ + if Match(r'^\s*#\s*(if|ifdef|ifndef)\b', line): + # Beginning of #if block, save the nesting stack here. The saved + # stack will allow us to restore the parsing state in the #else case. + self.pp_stack.append(_PreprocessorInfo(copy.deepcopy(self.stack))) + elif Match(r'^\s*#\s*(else|elif)\b', line): + # Beginning of #else block + if self.pp_stack: + if not self.pp_stack[-1].seen_else: + # This is the first #else or #elif block. Remember the + # whole nesting stack up to this point. This is what we + # keep after the #endif. + self.pp_stack[-1].seen_else = True + self.pp_stack[-1].stack_before_else = copy.deepcopy(self.stack) + + # Restore the stack to how it was before the #if + self.stack = copy.deepcopy(self.pp_stack[-1].stack_before_if) + else: + # TODO(unknown): unexpected #else, issue warning? + pass + elif Match(r'^\s*#\s*endif\b', line): + # End of #if or #else blocks. + if self.pp_stack: + # If we saw an #else, we will need to restore the nesting + # stack to its former state before the #else, otherwise we + # will just continue from where we left off. + if self.pp_stack[-1].seen_else: + # Here we can just use a shallow copy since we are the last + # reference to it. + self.stack = self.pp_stack[-1].stack_before_else + # Drop the corresponding #if + self.pp_stack.pop() + else: + # TODO(unknown): unexpected #endif, issue warning? + pass + + # TODO(unknown): Update() is too long, but we will refactor later. + def Update(self, filename, clean_lines, linenum, error): + """Update nesting state with current line. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # Remember top of the previous nesting stack. + # + # The stack is always pushed/popped and not modified in place, so + # we can just do a shallow copy instead of copy.deepcopy. Using + # deepcopy would slow down cpplint by ~28%. + if self.stack: + self.previous_stack_top = self.stack[-1] + else: + self.previous_stack_top = None + + # Update pp_stack + self.UpdatePreprocessor(line) + + # Count parentheses. This is to avoid adding struct arguments to + # the nesting stack. + if self.stack: + inner_block = self.stack[-1] + depth_change = line.count('(') - line.count(')') + inner_block.open_parentheses += depth_change + + # Also check if we are starting or ending an inline assembly block. + if inner_block.inline_asm in (_NO_ASM, _END_ASM): + if (depth_change != 0 and + inner_block.open_parentheses == 1 and + _MATCH_ASM.match(line)): + # Enter assembly block + inner_block.inline_asm = _INSIDE_ASM + else: + # Not entering assembly block. If previous line was _END_ASM, + # we will now shift to _NO_ASM state. + inner_block.inline_asm = _NO_ASM + elif (inner_block.inline_asm == _INSIDE_ASM and + inner_block.open_parentheses == 0): + # Exit assembly block + inner_block.inline_asm = _END_ASM + + # Consume namespace declaration at the beginning of the line. Do + # this in a loop so that we catch same line declarations like this: + # namespace proto2 { namespace bridge { class MessageSet; } } + while True: + # Match start of namespace. The "\b\s*" below catches namespace + # declarations even if it weren't followed by a whitespace, this + # is so that we don't confuse our namespace checker. The + # missing spaces will be flagged by CheckSpacing. + namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line) + if not namespace_decl_match: + break + + new_namespace = _NamespaceInfo(namespace_decl_match.group(1), linenum) + self.stack.append(new_namespace) + + line = namespace_decl_match.group(2) + if line.find('{') != -1: + new_namespace.seen_open_brace = True + line = line[line.find('{') + 1:] + + # Look for a class declaration in whatever is left of the line + # after parsing namespaces. The regexp accounts for decorated classes + # such as in: + # class LOCKABLE API Object { + # }; + class_decl_match = Match( + r'^(\s*(?:template\s*<[\w\s<>,:]*>\s*)?' + r'(class|struct)\s+(?:[A-Z_]+\s+)*(\w+(?:::\w+)*))' + r'(.*)$', line) + if (class_decl_match and + (not self.stack or self.stack[-1].open_parentheses == 0)): + # We do not want to accept classes that are actually template arguments: + # template , + # template class Ignore3> + # void Function() {}; + # + # To avoid template argument cases, we scan forward and look for + # an unmatched '>'. If we see one, assume we are inside a + # template argument list. + end_declaration = len(class_decl_match.group(1)) + if not self.InTemplateArgumentList(clean_lines, linenum, end_declaration): + self.stack.append(_ClassInfo( + class_decl_match.group(3), class_decl_match.group(2), + clean_lines, linenum)) + line = class_decl_match.group(4) + + # If we have not yet seen the opening brace for the innermost block, + # run checks here. + if not self.SeenOpenBrace(): + self.stack[-1].CheckBegin(filename, clean_lines, linenum, error) + + # Update access control if we are inside a class/struct + if self.stack and isinstance(self.stack[-1], _ClassInfo): + classinfo = self.stack[-1] + access_match = Match( + r'^(.*)\b(public|private|protected|signals)(\s+(?:slots\s*)?)?' + r':(?:[^:]|$)', + line) + if access_match: + classinfo.access = access_match.group(2) + + # Check that access keywords are indented +1 space. Skip this + # check if the keywords are not preceded by whitespaces. + indent = access_match.group(1) + if (len(indent) != classinfo.class_indent + 1 and + Match(r'^\s*$', indent)): + if classinfo.is_struct: + parent = 'struct ' + classinfo.name + else: + parent = 'class ' + classinfo.name + slots = '' + if access_match.group(3): + slots = access_match.group(3) + error(filename, linenum, 'whitespace/indent', 3, + '%s%s: should be indented +1 space inside %s' % ( + access_match.group(2), slots, parent)) + + # Consume braces or semicolons from what's left of the line + while True: + # Match first brace, semicolon, or closed parenthesis. + matched = Match(r'^[^{;)}]*([{;)}])(.*)$', line) + if not matched: + break + + token = matched.group(1) + if token == '{': + # If namespace or class hasn't seen a opening brace yet, mark + # namespace/class head as complete. Push a new block onto the + # stack otherwise. + if not self.SeenOpenBrace(): + self.stack[-1].seen_open_brace = True + elif Match(r'^extern\s*"[^"]*"\s*\{', line): + self.stack.append(_ExternCInfo(linenum)) + else: + self.stack.append(_BlockInfo(linenum, True)) + if _MATCH_ASM.match(line): + self.stack[-1].inline_asm = _BLOCK_ASM + + elif token == ';' or token == ')': + # If we haven't seen an opening brace yet, but we already saw + # a semicolon, this is probably a forward declaration. Pop + # the stack for these. + # + # Similarly, if we haven't seen an opening brace yet, but we + # already saw a closing parenthesis, then these are probably + # function arguments with extra "class" or "struct" keywords. + # Also pop these stack for these. + if not self.SeenOpenBrace(): + self.stack.pop() + else: # token == '}' + # Perform end of block checks and pop the stack. + if self.stack: + self.stack[-1].CheckEnd(filename, clean_lines, linenum, error) + self.stack.pop() + line = matched.group(2) + + def InnermostClass(self): + """Get class info on the top of the stack. + + Returns: + A _ClassInfo object if we are inside a class, or None otherwise. + """ + for i in range(len(self.stack), 0, -1): + classinfo = self.stack[i - 1] + if isinstance(classinfo, _ClassInfo): + return classinfo + return None + + def CheckCompletedBlocks(self, filename, error): + """Checks that all classes and namespaces have been completely parsed. + + Call this when all lines in a file have been processed. + Args: + filename: The name of the current file. + error: The function to call with any errors found. + """ + # Note: This test can result in false positives if #ifdef constructs + # get in the way of brace matching. See the testBuildClass test in + # cpplint_unittest.py for an example of this. + for obj in self.stack: + if isinstance(obj, _ClassInfo): + error(filename, obj.starting_linenum, 'build/class', 5, + 'Failed to find complete declaration of class %s' % + obj.name) + elif isinstance(obj, _NamespaceInfo): + error(filename, obj.starting_linenum, 'build/namespaces', 5, + 'Failed to find complete declaration of namespace %s' % + obj.name) + + +def CheckForNonStandardConstructs(filename, clean_lines, linenum, + nesting_state, error): + r"""Logs an error if we see certain non-ANSI constructs ignored by gcc-2. + + Complain about several constructs which gcc-2 accepts, but which are + not standard C++. Warning about these in lint is one way to ease the + transition to new compilers. + - put storage class first (e.g. "static const" instead of "const static"). + - "%lld" instead of %qd" in printf-type functions. + - "%1$d" is non-standard in printf-type functions. + - "\%" is an undefined character escape sequence. + - text after #endif is not allowed. + - invalid inner-style forward declaration. + - >? and ?= and ,:]*>\s*)?(class|struct)\s+' + - r'(?:NODE_EXTERN\s+)?(\w+(::\w+)*)', line) - if class_decl_match: - classinfo_stack.append(_ClassInfo(class_decl_match.group(3), linenum)) - - # Everything else in this function uses the top of the stack if it's - # not empty. - if not classinfo_stack: + # Everything else in this function operates on class declarations. + # Return early if the top of the nesting stack is not a class, or if + # the class head is not completed yet. + classinfo = nesting_state.InnermostClass() + if not classinfo or not classinfo.seen_open_brace: return - classinfo = classinfo_stack[-1] - - # If the opening brace hasn't been seen look for it and also - # parent class declarations. - if not classinfo.seen_open_brace: - # If the line has a ';' in it, assume it's a forward declaration or - # a single-line class declaration, which we won't process. - if line.find(';') != -1: - classinfo_stack.pop() - return - classinfo.seen_open_brace = (line.find('{') != -1) - # Look for a bare ':' - if Search('(^|[^:]):($|[^:])', line): - classinfo.is_derived = True - if not classinfo.seen_open_brace: - return # Everything else in this function is for after open brace - # The class may have been declared with namespace or classname qualifiers. # The constructor and destructor will not have those qualifiers. base_classname = classinfo.name.split('::')[-1] # Look for single-argument constructors that aren't marked explicit. # Technically a valid construct, but against style. - args = Match(r'(? constructor_arg.count('>') or + constructor_arg.count('(') > constructor_arg.count(')')): + constructor_arg += ',' + constructor_args[i + 1] + del constructor_args[i + 1] + constructor_args[i] = constructor_arg + i += 1 + + defaulted_args = [arg for arg in constructor_args if '=' in arg] + noarg_constructor = (not constructor_args or # empty arg list + # 'void' arg specifier + (len(constructor_args) == 1 and + constructor_args[0].strip() == 'void')) + onearg_constructor = ((len(constructor_args) == 1 and # exactly one arg + not noarg_constructor) or + # all but at most one arg defaulted + (len(constructor_args) >= 1 and + not noarg_constructor and + len(defaulted_args) >= len(constructor_args) - 1)) + initializer_list_constructor = bool( + onearg_constructor and + Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0])) + copy_constructor = bool( + onearg_constructor and + Match(r'(const\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&' + % re.escape(base_classname), constructor_args[0].strip())) + + if (not is_marked_explicit and + onearg_constructor and + not initializer_list_constructor and + not copy_constructor): + if defaulted_args: + error(filename, linenum, 'runtime/explicit', 5, + 'Constructors callable with one argument ' + 'should be marked explicit.') + else: + error(filename, linenum, 'runtime/explicit', 5, + 'Single-parameter constructors should be marked explicit.') + elif is_marked_explicit and not onearg_constructor: + if noarg_constructor: + error(filename, linenum, 'runtime/explicit', 5, + 'Zero-parameter constructors should not be marked explicit.') -def CheckSpacingForFunctionCall(filename, line, linenum, error): + +def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): """Checks for the correctness of various spacing around function calls. Args: filename: The name of the current file. - line: The text of the line to check. + clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found. """ + line = clean_lines.elided[linenum] # Since function calls often occur inside if/for/while/switch # expressions - which have their own, more liberal conventions - we @@ -1487,7 +2843,8 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): # Note that we assume the contents of [] to be short enough that # they'll never need to wrap. if ( # Ignore control structures. - not Search(r'\b(if|for|while|switch|return|delete)\b', fncall) and + not Search(r'\b(if|for|while|switch|return|new|delete|catch|sizeof)\b', + fncall) and # Ignore pointers/references to functions. not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and # Ignore pointers/references to arrays. @@ -1499,14 +2856,29 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): error(filename, linenum, 'whitespace/parens', 2, 'Extra space after (') if (Search(r'\w\s+\(', fncall) and - not Search(r'#\s*define|typedef', fncall)): - error(filename, linenum, 'whitespace/parens', 4, - 'Extra space before ( in function call') + not Search(r'_{0,2}asm_{0,2}\s+_{0,2}volatile_{0,2}\s+\(', fncall) and + not Search(r'#\s*define|typedef|using\s+\w+\s*=', fncall) and + not Search(r'\w\s+\((\w+::)*\*\w+\)\(', fncall) and + not Search(r'\bcase\s+\(', fncall)): + # TODO(unknown): Space after an operator function seem to be a common + # error, silence those for now by restricting them to highest verbosity. + if Search(r'\boperator_*\b', line): + error(filename, linenum, 'whitespace/parens', 0, + 'Extra space before ( in function call') + else: + error(filename, linenum, 'whitespace/parens', 4, + 'Extra space before ( in function call') # If the ) is followed only by a newline or a { + newline, assume it's # part of a control statement (if/while/etc), and don't complain if Search(r'[^)]\s+\)\s*[^{\s]', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space before )') + # If the closing parenthesis is preceded by only whitespaces, + # try to give a more descriptive error message. + if Search(r'^\s+\)', fncall): + error(filename, linenum, 'whitespace/parens', 2, + 'Closing ) should be moved to the previous line') + else: + error(filename, linenum, 'whitespace/parens', 2, + 'Extra space before )') def IsBlankLine(line): @@ -1524,12 +2896,26 @@ def IsBlankLine(line): return not line or line.isspace() +def CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, + error): + is_namespace_indent_item = ( + len(nesting_state.stack) > 1 and + nesting_state.stack[-1].check_namespace_indentation and + isinstance(nesting_state.previous_stack_top, _NamespaceInfo) and + nesting_state.previous_stack_top == nesting_state.stack[-2]) + + if ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, + clean_lines.elided, line): + CheckItemIndentationInNamespace(filename, clean_lines.elided, + line, error) + + def CheckForFunctionLengths(filename, clean_lines, linenum, function_state, error): """Reports for long function bodies. For an overview why this is done, see: - http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions + https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions Uses a simplistic algorithm assuming other style guidelines (especially spacing) are followed. @@ -1537,7 +2923,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, Trivial bodies are unchecked, so constructors with huge initializer lists may be missed. Blank/comment lines are not counted so as to avoid encouraging the removal - of vertical space and commments just to get through a lint check. + of vertical space and comments just to get through a lint check. NOLINT *on the last line of a function* disables this check. Args: @@ -1549,8 +2935,6 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, """ lines = clean_lines.lines line = lines[linenum] - raw = clean_lines.raw_lines - raw_line = raw[linenum] joined_line = '' starting_func = False @@ -1597,59 +2981,132 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, _RE_PATTERN_TODO = re.compile(r'^//(\s*)TODO(\(.+?\))?:?(\s|$)?') -def CheckComment(comment, filename, linenum, error): - """Checks for common mistakes in TODO comments. +def CheckComment(line, filename, linenum, next_line_start, error): + """Checks for common mistakes in comments. Args: - comment: The text of the comment from the line in question. + line: The line in question. filename: The name of the current file. linenum: The number of the line to check. + next_line_start: The first non-whitespace column of the next line. error: The function to call with any errors found. """ - match = _RE_PATTERN_TODO.match(comment) - if match: - # One whitespace is correct; zero whitespace is handled elsewhere. - leading_whitespace = match.group(1) - if len(leading_whitespace) > 1: - error(filename, linenum, 'whitespace/todo', 2, - 'Too many spaces before TODO') - - username = match.group(2) - if not username: - error(filename, linenum, 'readability/todo', 2, - 'Missing username in TODO; it should look like ' - '"// TODO(my_username): Stuff."') - - middle_whitespace = match.group(3) - # Comparisons made explicit for correctness -- pylint: disable-msg=C6403 - if middle_whitespace != ' ' and middle_whitespace != '': - error(filename, linenum, 'whitespace/todo', 2, - 'TODO(my_username) should be followed by a space') - - -def CheckSpacing(filename, clean_lines, linenum, error): + commentpos = line.find('//') + if commentpos != -1: + # Check if the // may be in quotes. If so, ignore it + if re.sub(r'\\.', '', line[0:commentpos]).count('"') % 2 == 0: + # Allow one space for new scopes, two spaces otherwise: + if (not (Match(r'^.*{ *//', line) and next_line_start == commentpos) and + ((commentpos >= 1 and + line[commentpos-1] not in string.whitespace) or + (commentpos >= 2 and + line[commentpos-2] not in string.whitespace))): + error(filename, linenum, 'whitespace/comments', 2, + 'At least two spaces is best between code and comments') + + # Checks for common mistakes in TODO comments. + comment = line[commentpos:] + match = _RE_PATTERN_TODO.match(comment) + if match: + # One whitespace is correct; zero whitespace is handled elsewhere. + leading_whitespace = match.group(1) + if len(leading_whitespace) > 1: + error(filename, linenum, 'whitespace/todo', 2, + 'Too many spaces before TODO') + + username = match.group(2) + if not username: + error(filename, linenum, 'readability/todo', 2, + 'Missing username in TODO; it should look like ' + '"// TODO(my_username): Stuff."') + + middle_whitespace = match.group(3) + # Comparisons made explicit for correctness -- pylint: disable=g-explicit-bool-comparison + if middle_whitespace != ' ' and middle_whitespace != '': + error(filename, linenum, 'whitespace/todo', 2, + 'TODO(my_username) should be followed by a space') + + # If the comment contains an alphanumeric character, there + # should be a space somewhere between it and the // unless + # it's a /// or //! Doxygen comment. + if (Match(r'//[^ ]*\w', comment) and + not Match(r'(///|//\!)(\s+|$)', comment)): + error(filename, linenum, 'whitespace/comments', 4, + 'Should have a space between // and comment') + + +def CheckAccess(filename, clean_lines, linenum, nesting_state, error): + """Checks for improper use of DISALLOW* macros. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] # get rid of comments and strings + + matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|' + r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line) + if not matched: + return + if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo): + if nesting_state.stack[-1].access != 'private': + error(filename, linenum, 'readability/constructors', 3, + '%s must be in the private: section' % matched.group(1)) + + else: + # Found DISALLOW* macro outside a class declaration, or perhaps it + # was used inside a function when it should have been part of the + # class declaration. We could issue a warning here, but it + # probably resulted in a compiler error already. + pass + + +def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for the correctness of various spacing issues in the code. Things we check for: spaces around operators, spaces after if/for/while/switch, no spaces around parens in function calls, two spaces between code and comment, don't start a block with a blank - line, don't end a function with a blank line, don't have too many - blank lines in a row. + line, don't end a function with a blank line, don't add a blank line + after public/protected/private, don't have too many blank lines in a row. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: The function to call with any errors found. """ - raw = clean_lines.raw_lines + # Don't use "elided" lines here, otherwise we can't check commented lines. + # Don't want to use "raw" either, because we don't want to check inside C++11 + # raw strings, + raw = clean_lines.lines_without_raw_strings line = raw[linenum] # Before nixing comments, check if the line is blank for no good # reason. This includes the first line after a block is opened, and # blank lines at the end of a function (ie, right before a line like '}' - if IsBlankLine(line): + # + # Skip all the blank line checks if we are immediately inside a + # namespace body. In other words, don't issue blank line warnings + # for this block: + # namespace { + # + # } + # + # A warning about missing end of namespace comments will be issued instead. + # + # Also skip blank line checks for 'extern "C"' blocks, which are formatted + # like namespaces. + if (IsBlankLine(line) and + not nesting_state.InNamespaceBody() and + not nesting_state.InExternC()): elided = clean_lines.elided prev_line = elided[linenum - 1] prevbrace = prev_line.rfind('{') @@ -1657,11 +3114,10 @@ def CheckSpacing(filename, clean_lines, linenum, error): # both start with alnums and are indented the same amount. # This ignores whitespace at the start of a namespace block # because those are not usually indented. - if (prevbrace != -1 and prev_line[prevbrace:].find('}') == -1 - and prev_line[:prevbrace].find('namespace') == -1): + if prevbrace != -1 and prev_line[prevbrace:].find('}') == -1: # OK, we have a blank line at the start of a code block. Before we # complain, we check if it is an exception to the rule: The previous - # non-empty line has the paramters of a function header that are indented + # non-empty line has the parameters of a function header that are indented # 4 spaces (because they did not fit in a 80 column line when placed on # the same line as the function name). We also check for the case where # the previous line is indented 6 spaces, which may happen when the @@ -1689,13 +3145,9 @@ def CheckSpacing(filename, clean_lines, linenum, error): if not exception: error(filename, linenum, 'whitespace/blank_line', 2, - 'Blank line at the start of a code block. Is this needed?') - # This doesn't ignore whitespace at the end of a namespace block - # because that is too hard without pairing open/close braces; - # however, a special exception is made for namespace closing - # brackets which have a comment containing "namespace". - # - # Also, ignore blank lines at the end of a block in a long if-else + 'Redundant blank line at the start of a code block ' + 'should be deleted.') + # Ignore blank lines at the end of a block in a long if-else # chain, like this: # if (condition1) { # // Something followed by a blank line @@ -1707,87 +3159,147 @@ def CheckSpacing(filename, clean_lines, linenum, error): next_line = raw[linenum + 1] if (next_line and Match(r'\s*}', next_line) - and next_line.find('namespace') == -1 - and next_line.find('extern') == -1 and next_line.find('} else ') == -1): error(filename, linenum, 'whitespace/blank_line', 3, - 'Blank line at the end of a code block. Is this needed?') + 'Redundant blank line at the end of a code block ' + 'should be deleted.') - # Next, we complain if there's a comment too near the text - commentpos = line.find('//') - if commentpos != -1: - # Check if the // may be in quotes. If so, ignore it - # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 - if (line.count('"', 0, commentpos) - - line.count('\\"', 0, commentpos)) % 2 == 0: # not in quotes - # Allow one space for new scopes, two spaces otherwise: - if (not Match(r'^\s*{ //', line) and - ((commentpos >= 1 and - line[commentpos-1] not in string.whitespace) or - (commentpos >= 2 and - line[commentpos-2] not in string.whitespace))): - error(filename, linenum, 'whitespace/comments', 2, - 'At least two spaces is best between code and comments') - # There should always be a space between the // and the comment - commentend = commentpos + 2 - if commentend < len(line) and not line[commentend] == ' ': - # but some lines are exceptions -- e.g. if they're big - # comment delimiters like: - # //---------------------------------------------------------- - # or are an empty C++ style Doxygen comment, like: - # /// - # or they begin with multiple slashes followed by a space: - # //////// Header comment - match = (Search(r'[=/-]{4,}\s*$', line[commentend:]) or - Search(r'^/$', line[commentend:]) or - Search(r'^/+ ', line[commentend:])) - if not match: - error(filename, linenum, 'whitespace/comments', 4, - 'Should have a space between // and comment') - CheckComment(line[commentpos:], filename, linenum, error) + matched = Match(r'\s*(public|protected|private):', prev_line) + if matched: + error(filename, linenum, 'whitespace/blank_line', 3, + 'Do not leave a blank line after "%s:"' % matched.group(1)) - line = clean_lines.elided[linenum] # get rid of comments and strings + # Next, check comments + next_line_start = 0 + if linenum + 1 < clean_lines.NumLines(): + next_line = raw[linenum + 1] + next_line_start = len(next_line) - len(next_line.lstrip()) + CheckComment(line, filename, linenum, next_line_start, error) + + # get rid of comments and strings + line = clean_lines.elided[linenum] + + # You shouldn't have spaces before your brackets, except maybe after + # 'delete []' or 'return []() {};' + if Search(r'\w\s+\[', line) and not Search(r'(?:delete|return)\s+\[', line): + error(filename, linenum, 'whitespace/braces', 5, + 'Extra space before [') + + # In range-based for, we wanted spaces before and after the colon, but + # not around "::" tokens that might appear. + if (Search(r'for *\(.*[^:]:[^: ]', line) or + Search(r'for *\(.*[^: ]:[^:]', line)): + error(filename, linenum, 'whitespace/forcolon', 2, + 'Missing space around colon in range-based for loop') + + +def CheckOperatorSpacing(filename, clean_lines, linenum, error): + """Checks for horizontal spacing around operators. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] - # Don't try to do spacing checks for operator methods - line = re.sub(r'operator(==|!=|<|<<|<=|>=|>>|>)\(', 'operator\(', line) + # Don't try to do spacing checks for operator methods. Do this by + # replacing the troublesome characters with something else, + # preserving column position for all other characters. + # + # The replacement is done repeatedly to avoid false positives from + # operators that call operators. + while True: + match = Match(r'^(.*\boperator\b)(\S+)(\s*\(.*)$', line) + if match: + line = match.group(1) + ('_' * len(match.group(2))) + match.group(3) + else: + break # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )". # Otherwise not. Note we only check for non-spaces on *both* sides; # sometimes people put non-spaces on one side when aligning ='s among # many lines (not that this is behavior that I approve of...) - if Search(r'[\w.]=[\w.]', line) and not Search(r'\b(if|while) ', line): + if ((Search(r'[\w.]=', line) or + Search(r'=[\w.]', line)) + and not Search(r'\b(if|while|for) ', line) + # Operators taken from [lex.operators] in C++11 standard. + and not Search(r'(>=|<=|==|!=|&=|\^=|\|=|\+=|\*=|\/=|\%=)', line) + and not Search(r'operator=', line)): error(filename, linenum, 'whitespace/operators', 4, 'Missing spaces around =') - if Match(r'^\s*(if|while) .*[^\{,)&|\\]$', line): - error(filename, linenum, 'whitespace/if-one-line', 4, - 'If\'s body on the same line as if itself') - # It's ok not to have spaces around binary operators like + - * /, but if # there's too little whitespace, we get concerned. It's hard to tell, # though, so we punt on this one for now. TODO. # You should always have whitespace around binary operators. - # Alas, we can't test < or > because they're legitimately used sans spaces - # (a->b, vector a). The only time we can tell is a < with no >, and - # only if it's not template params list spilling into the next line. - match = Search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line) - if not match: - # Note that while it seems that the '<[^<]*' term in the following - # regexp could be simplified to '<.*', which would indeed match - # the same class of strings, the [^<] means that searching for the - # regexp takes linear rather than quadratic time. - if not Search(r'<[^<]*,\s*$', line): # template params spill - match = Search(r'[^<>=!\s](<)[^<>=!\s]([^>]|->)*$', line) + # + # Check <= and >= first to avoid false positives with < and >, then + # check non-include lines for spacing around < and >. + # + # If the operator is followed by a comma, assume it's be used in a + # macro context and don't do any checks. This avoids false + # positives. + # + # Note that && is not included here. This is because there are too + # many false positives due to RValue references. + match = Search(r'[^<>=!\s](==|!=|<=|>=|\|\|)[^<>=!\s,;\)]', line) if match: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around %s' % match.group(1)) - # We allow no-spaces around << and >> when used like this: 10<<20, but + elif not Match(r'#.*include', line): + # Look for < that is not surrounded by spaces. This is only + # triggered if both sides are missing spaces, even though + # technically should should flag if at least one side is missing a + # space. This is done to avoid some false positives with shifts. + match = Match(r'^(.*[^\s<])<[^\s=<,]', line) + if match: + (_, _, end_pos) = CloseExpression( + clean_lines, linenum, len(match.group(1))) + if end_pos <= -1: + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around <') + + # Look for > that is not surrounded by spaces. Similar to the + # above, we only trigger if both sides are missing spaces to avoid + # false positives with shifts. + match = Match(r'^(.*[^-\s>])>[^\s=>,]', line) + if match: + (_, _, start_pos) = ReverseCloseExpression( + clean_lines, linenum, len(match.group(1))) + if start_pos <= -1: + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around >') + + # We allow no-spaces around << when used like this: 10<<20, but # not otherwise (particularly, not when used as streams) - match = Search(r'[^0-9\s](<<|>>)[^0-9\s]', line) + # + # We also allow operators following an opening parenthesis, since + # those tend to be macros that deal with operators. + match = Search(r'(operator|[^\s(<])(?:L|UL|LL|ULL|l|ul|ll|ull)?<<([^\s,=<])', line) + if (match and not (match.group(1).isdigit() and match.group(2).isdigit()) and + not (match.group(1) == 'operator' and match.group(2) == ';')): + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around <<') + + # We allow no-spaces around >> for almost anything. This is because + # C++11 allows ">>" to close nested templates, which accounts for + # most cases when ">>" is not followed by a space. + # + # We still warn on ">>" followed by alpha character, because that is + # likely due to ">>" being used for right shifts, e.g.: + # value >> alpha + # + # When ">>" is used to close templates, the alphanumeric letter that + # follows would be part of an identifier, and there should still be + # a space separating the template type and the identifier. + # type> alpha + match = Search(r'>>[a-zA-Z_]', line) if match: error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around %s' % match.group(1)) + 'Missing spaces around >>') # There shouldn't be space around unary operators match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) @@ -1795,7 +3307,19 @@ def CheckSpacing(filename, clean_lines, linenum, error): error(filename, linenum, 'whitespace/operators', 4, 'Extra space for operator %s' % match.group(1)) - # A pet peeve of mine: no spaces after an if, while, switch, or for + +def CheckParenthesisSpacing(filename, clean_lines, linenum, error): + """Checks for horizontal spacing around parentheses. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # No spaces after an if, while, switch, or for match = Search(r' (if\(|for\(|while\(|switch\()', line) if match: error(filename, linenum, 'whitespace/parens', 5, @@ -1816,52 +3340,271 @@ def CheckSpacing(filename, clean_lines, linenum, error): not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)): error(filename, linenum, 'whitespace/parens', 5, 'Mismatching spaces inside () in %s' % match.group(1)) - if not len(match.group(2)) in [0, 1]: + if len(match.group(2)) not in [0, 1]: error(filename, linenum, 'whitespace/parens', 5, 'Should have zero or one spaces inside ( and ) in %s' % match.group(1)) - # You should always have a space after a comma (either as fn arg or operator) - if Search(r',[^\s]', line): - error(filename, linenum, 'whitespace/comma', 3, - 'Missing space after ,') - - # Next we will look for issues with function calls. - CheckSpacingForFunctionCall(filename, line, linenum, error) - # Except after an opening paren, you should have spaces before your braces. - # And since you should never have braces at the beginning of a line, this is - # an easy test. - if Search(r'[^ (]{', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Missing space before {') +def CheckCommaSpacing(filename, clean_lines, linenum, error): + """Checks for horizontal spacing near commas and semicolons. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + raw = clean_lines.lines_without_raw_strings + line = clean_lines.elided[linenum] + + # You should always have a space after a comma (either as fn arg or operator) + # + # This does not apply when the non-space character following the + # comma is another comma, since the only time when that happens is + # for empty macro arguments. + # + # We run this check in two passes: first pass on elided lines to + # verify that lines contain missing whitespaces, second pass on raw + # lines to confirm that those missing whitespaces are not due to + # elided comments. + if (Search(r',[^,\s]', ReplaceAll(r'\boperator\s*,\s*\(', 'F(', line)) and + Search(r',[^,\s]', raw[linenum])): + error(filename, linenum, 'whitespace/comma', 3, + 'Missing space after ,') + + # You should always have a space after a semicolon + # except for few corner cases + # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more + # space after ; + if Search(r';[^\s};\\)/]', line): + error(filename, linenum, 'whitespace/semicolon', 3, + 'Missing space after ;') + + +def _IsType(clean_lines, nesting_state, expr): + """Check if expression looks like a type name, returns true if so. + + Args: + clean_lines: A CleansedLines instance containing the file. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. + expr: The expression to check. + Returns: + True, if token looks like a type. + """ + # Keep only the last token in the expression + last_word = Match(r'^.*(\b\S+)$', expr) + if last_word: + token = last_word.group(1) + else: + token = expr + + # Match native types and stdint types + if _TYPES.match(token): + return True + + # Try a bit harder to match templated types. Walk up the nesting + # stack until we find something that resembles a typename + # declaration for what we are looking for. + typename_pattern = (r'\b(?:typename|class|struct)\s+' + re.escape(token) + + r'\b') + block_index = len(nesting_state.stack) - 1 + while block_index >= 0: + if isinstance(nesting_state.stack[block_index], _NamespaceInfo): + return False + + # Found where the opening brace is. We want to scan from this + # line up to the beginning of the function, minus a few lines. + # template + # class C + # : public ... { // start scanning here + last_line = nesting_state.stack[block_index].starting_linenum + + next_block_start = 0 + if block_index > 0: + next_block_start = nesting_state.stack[block_index - 1].starting_linenum + first_line = last_line + while first_line >= next_block_start: + if clean_lines.elided[first_line].find('template') >= 0: + break + first_line -= 1 + if first_line < next_block_start: + # Didn't find any "template" keyword before reaching the next block, + # there are probably no template things to check for this block + block_index -= 1 + continue + + # Look for typename in the specified range + for i in xrange(first_line, last_line + 1, 1): + if Search(typename_pattern, clean_lines.elided[i]): + return True + block_index -= 1 + + return False + + +def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error): + """Checks for horizontal spacing near commas. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # Except after an opening paren, or after another opening brace (in case of + # an initializer list, for instance), you should have spaces before your + # braces when they are delimiting blocks, classes, namespaces etc. + # And since you should never have braces at the beginning of a line, + # this is an easy test. Except that braces used for initialization don't + # follow the same rule; we often don't want spaces before those. + match = Match(r'^(.*[^ ({>]){', line) + + if match: + # Try a bit harder to check for brace initialization. This + # happens in one of the following forms: + # Constructor() : initializer_list_{} { ... } + # Constructor{}.MemberFunction() + # Type variable{}; + # FunctionCall(type{}, ...); + # LastArgument(..., type{}); + # LOG(INFO) << type{} << " ..."; + # map_of_type[{...}] = ...; + # ternary = expr ? new type{} : nullptr; + # OuterTemplate{}> + # + # We check for the character following the closing brace, and + # silence the warning if it's one of those listed above, i.e. + # "{.;,)<>]:". + # + # To account for nested initializer list, we allow any number of + # closing braces up to "{;,)<". We can't simply silence the + # warning on first sight of closing brace, because that would + # cause false negatives for things that are not initializer lists. + # Silence this: But not this: + # Outer{ if (...) { + # Inner{...} if (...){ // Missing space before { + # }; } + # + # There is a false negative with this approach if people inserted + # spurious semicolons, e.g. "if (cond){};", but we will catch the + # spurious semicolon with a separate check. + leading_text = match.group(1) + (endline, endlinenum, endpos) = CloseExpression( + clean_lines, linenum, len(match.group(1))) + trailing_text = '' + if endpos > -1: + trailing_text = endline[endpos:] + for offset in xrange(endlinenum + 1, + min(endlinenum + 3, clean_lines.NumLines() - 1)): + trailing_text += clean_lines.elided[offset] + # We also suppress warnings for `uint64_t{expression}` etc., as the style + # guide recommends brace initialization for integral types to avoid + # overflow/truncation. + if (not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text) + and not _IsType(clean_lines, nesting_state, leading_text)): + error(filename, linenum, 'whitespace/braces', 5, + 'Missing space before {') # Make sure '} else {' has spaces. if Search(r'}else', line): error(filename, linenum, 'whitespace/braces', 5, 'Missing space before else') - # You shouldn't have spaces before your brackets, except maybe after - # 'delete []' or 'new char * []'. - if Search(r'\w\s+\[', line) and not Search(r'delete\s+\[', line): - error(filename, linenum, 'whitespace/braces', 5, - 'Extra space before [') - # You shouldn't have a space before a semicolon at the end of the line. # There's a special case for "for" since the style guide allows space before # the semicolon there. if Search(r':\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, - 'Semicolon defining empty statement. Use { } instead.') + 'Semicolon defining empty statement. Use {} instead.') elif Search(r'^\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, 'Line contains only semicolon. If this should be an empty statement, ' - 'use { } instead.') + 'use {} instead.') elif (Search(r'\s+;\s*$', line) and not Search(r'\bfor\b', line)): error(filename, linenum, 'whitespace/semicolon', 5, 'Extra space before last semicolon. If this should be an empty ' - 'statement, use { } instead.') + 'statement, use {} instead.') + + +def IsDecltype(clean_lines, linenum, column): + """Check if the token ending on (linenum, column) is decltype(). + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: the number of the line to check. + column: end column of the token to check. + Returns: + True if this token is decltype() expression, False otherwise. + """ + (text, _, start_col) = ReverseCloseExpression(clean_lines, linenum, column) + if start_col < 0: + return False + if Search(r'\bdecltype\s*$', text[0:start_col]): + return True + return False + + +def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): + """Checks for additional blank line issues related to sections. + + Currently the only thing checked here is blank line before protected/private. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + class_info: A _ClassInfo objects. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + # Skip checks if the class is small, where small means 25 lines or less. + # 25 lines seems like a good cutoff since that's the usual height of + # terminals, and any class that can't fit in one screen can't really + # be considered "small". + # + # Also skip checks if we are on the first line. This accounts for + # classes that look like + # class Foo { public: ... }; + # + # If we didn't find the end of the class, last_line would be zero, + # and the check will be skipped by the first condition. + if (class_info.last_line - class_info.starting_linenum <= 24 or + linenum <= class_info.starting_linenum): + return + + matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) + if matched: + # Issue warning if the line before public/protected/private was + # not a blank line, but don't do this if the previous line contains + # "class" or "struct". This can happen two ways: + # - We are at the beginning of the class. + # - We are forward-declaring an inner class that is semantically + # private, but needed to be public for implementation reasons. + # Also ignores cases where the previous line ends with a backslash as can be + # common when defining classes in C macros. + prev_line = clean_lines.lines[linenum - 1] + if (not IsBlankLine(prev_line) and + not Search(r'\b(class|struct)\b', prev_line) and + not Search(r'\\$', prev_line)): + # Try a bit harder to find the beginning of the class. This is to + # account for multi-line base-specifier lists, e.g.: + # class Derived + # : public Base { + end_class_head = class_info.starting_linenum + for i in range(class_info.starting_linenum, linenum): + if Search(r'\{\s*$', clean_lines.lines[i]): + end_class_head = i + break + if end_class_head < linenum - 1: + error(filename, linenum, 'whitespace/blank_line', 3, + '"%s:" should be preceded by a blank line' % matched.group(1)) def GetPreviousNonBlankLine(clean_lines, linenum): @@ -1900,19 +3643,24 @@ def CheckBraces(filename, clean_lines, linenum, error): line = clean_lines.elided[linenum] # get rid of comments and strings if Match(r'\s*{\s*$', line): - # We allow an open brace to start a line in the case where someone - # is using braces in a block to explicitly create a new scope, - # which is commonly used to control the lifetime of - # stack-allocated variables. We don't detect this perfectly: we - # just don't complain if the last non-whitespace character on the - # previous non-blank line is ';', ':', '{', or '}'. + # We allow an open brace to start a line in the case where someone is using + # braces in a block to explicitly create a new scope, which is commonly used + # to control the lifetime of stack-allocated variables. Braces are also + # used for brace initializers inside function calls. We don't detect this + # perfectly: we just don't complain if the last non-whitespace character on + # the previous non-blank line is ',', ';', ':', '(', '{', or '}', or if the + # previous line starts a preprocessor block. We also allow a brace on the + # following line if it is part of an array initialization and would not fit + # within the 80 character limit of the preceding line. prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if not Search(r'[;:}{]\s*$', prevline): + if (not Search(r'[,;:}{(]\s*$', prevline) and + not Match(r'\s*#', prevline) and + not (GetLineWidth(prevline) > _line_length - 2 and '[]' in prevline)): error(filename, linenum, 'whitespace/braces', 4, '{ should almost always be at the end of the previous line') # An else clause should be on the same line as the preceding closing brace. - if Match(r'\s*else\s*', line): + if Match(r'\s*else\b\s*(?:if\b|\{|$)', line): prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] if Match(r'\s*}\s*$', prevline): error(filename, linenum, 'whitespace/newline', 4, @@ -1920,19 +3668,20 @@ def CheckBraces(filename, clean_lines, linenum, error): # If braces come on one side of an else, they should be on both. # However, we have to worry about "else if" that spans multiple lines! - if Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): - if Search(r'}\s*else if([^{]*)$', line): # could be multi-line if - # find the ( after the if - pos = line.find('else if') - pos = line.find('(', pos) - if pos > 0: - (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) - if endline[endpos:].find('{') == -1: # must be brace after if - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') - else: # common case: else not followed by a multi-line if - error(filename, linenum, 'readability/braces', 5, - 'If an else has a brace on one side, it should have it on both') + if Search(r'else if\s*\(', line): # could be multi-line if + brace_on_left = bool(Search(r'}\s*else if\s*\(', line)) + # find the ( after the if + pos = line.find('else if') + pos = line.find('(', pos) + if pos > 0: + (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) + brace_on_right = endline[endpos:].find('{') != -1 + if brace_on_left != brace_on_right: # must be brace after if + error(filename, linenum, 'readability/braces', 5, + 'If an else has a brace on one side, it should have it on both') + elif Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): + error(filename, linenum, 'readability/braces', 5, + 'If an else has a brace on one side, it should have it on both') # Likewise, an else should never have the else clause on the same line if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line): @@ -1944,56 +3693,326 @@ def CheckBraces(filename, clean_lines, linenum, error): error(filename, linenum, 'whitespace/newline', 4, 'do/while clauses should not be on a single line') - # Braces shouldn't be followed by a ; unless they're defining a struct - # or initializing an array. - # We can't tell in general, but we can for some common cases. - prevlinenum = linenum - while True: - (prevline, prevlinenum) = GetPreviousNonBlankLine(clean_lines, prevlinenum) - if Match(r'\s+{.*}\s*;', line) and not prevline.count(';'): - line = prevline + line - else: - break - if (Search(r'{.*}\s*;', line) and - line.count('{') == line.count('}') and - not Search(r'struct|class|enum|\s*=\s*{', line)): - error(filename, linenum, 'readability/braces', 4, - "You don't need a ; after a }") + # Check single-line if/else bodies. The style guide says 'curly braces are not + # required for single-line statements'. We additionally allow multi-line, + # single statements, but we reject anything with more than one semicolon in + # it. This means that the first semicolon after the if should be at the end of + # its line, and the line after that should have an indent level equal to or + # lower than the if. We also check for ambiguous if/else nesting without + # braces. + if_else_match = Search(r'\b(if\s*\(|else\b)', line) + if if_else_match and not Match(r'\s*#', line): + if_indent = GetIndentLevel(line) + endline, endlinenum, endpos = line, linenum, if_else_match.end() + if_match = Search(r'\bif\s*\(', line) + if if_match: + # This could be a multiline if condition, so find the end first. + pos = if_match.end() - 1 + (endline, endlinenum, endpos) = CloseExpression(clean_lines, linenum, pos) + # Check for an opening brace, either directly after the if or on the next + # line. If found, this isn't a single-statement conditional. + if (not Match(r'\s*{', endline[endpos:]) + and not (Match(r'\s*$', endline[endpos:]) + and endlinenum < (len(clean_lines.elided) - 1) + and Match(r'\s*{', clean_lines.elided[endlinenum + 1]))): + while (endlinenum < len(clean_lines.elided) + and ';' not in clean_lines.elided[endlinenum][endpos:]): + endlinenum += 1 + endpos = 0 + if endlinenum < len(clean_lines.elided): + endline = clean_lines.elided[endlinenum] + # We allow a mix of whitespace and closing braces (e.g. for one-liner + # methods) and a single \ after the semicolon (for macros) + endpos = endline.find(';') + if not Match(r';[\s}]*(\\?)$', endline[endpos:]): + # Semicolon isn't the last character, there's something trailing. + # Output a warning if the semicolon is not contained inside + # a lambda expression. + if not Match(r'^[^{};]*\[[^\[\]]*\][^{}]*\{[^{}]*\}\s*\)*[;,]\s*$', + endline): + error(filename, linenum, 'readability/braces', 4, + 'If/else bodies with multiple statements require braces') + elif endlinenum < len(clean_lines.elided) - 1: + # Make sure the next line is dedented + next_line = clean_lines.elided[endlinenum + 1] + next_indent = GetIndentLevel(next_line) + # With ambiguous nested if statements, this will error out on the + # if that *doesn't* match the else, regardless of whether it's the + # inner one or outer one. + if (if_match and Match(r'\s*else\b', next_line) + and next_indent != if_indent): + error(filename, linenum, 'readability/braces', 4, + 'Else clause should be indented at the same level as if. ' + 'Ambiguous nested if/else chains require braces.') + elif next_indent > if_indent: + error(filename, linenum, 'readability/braces', 4, + 'If/else bodies with multiple statements require braces') + + +def CheckTrailingSemicolon(filename, clean_lines, linenum, error): + """Looks for redundant trailing semicolon. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + + line = clean_lines.elided[linenum] + + # Block bodies should not be followed by a semicolon. Due to C++11 + # brace initialization, there are more places where semicolons are + # required than not, so we use a whitelist approach to check these + # rather than a blacklist. These are the places where "};" should + # be replaced by just "}": + # 1. Some flavor of block following closing parenthesis: + # for (;;) {}; + # while (...) {}; + # switch (...) {}; + # Function(...) {}; + # if (...) {}; + # if (...) else if (...) {}; + # + # 2. else block: + # if (...) else {}; + # + # 3. const member function: + # Function(...) const {}; + # + # 4. Block following some statement: + # x = 42; + # {}; + # + # 5. Block at the beginning of a function: + # Function(...) { + # {}; + # } + # + # Note that naively checking for the preceding "{" will also match + # braces inside multi-dimensional arrays, but this is fine since + # that expression will not contain semicolons. + # + # 6. Block following another block: + # while (true) {} + # {}; + # + # 7. End of namespaces: + # namespace {}; + # + # These semicolons seems far more common than other kinds of + # redundant semicolons, possibly due to people converting classes + # to namespaces. For now we do not warn for this case. + # + # Try matching case 1 first. + match = Match(r'^(.*\)\s*)\{', line) + if match: + # Matched closing parenthesis (case 1). Check the token before the + # matching opening parenthesis, and don't warn if it looks like a + # macro. This avoids these false positives: + # - macro that defines a base class + # - multi-line macro that defines a base class + # - macro that defines the whole class-head + # + # But we still issue warnings for macros that we know are safe to + # warn, specifically: + # - TEST, TEST_F, TEST_P, MATCHER, MATCHER_P + # - TYPED_TEST + # - INTERFACE_DEF + # - EXCLUSIVE_LOCKS_REQUIRED, SHARED_LOCKS_REQUIRED, LOCKS_EXCLUDED: + # + # We implement a whitelist of safe macros instead of a blacklist of + # unsafe macros, even though the latter appears less frequently in + # google code and would have been easier to implement. This is because + # the downside for getting the whitelist wrong means some extra + # semicolons, while the downside for getting the blacklist wrong + # would result in compile errors. + # + # In addition to macros, we also don't want to warn on + # - Compound literals + # - Lambdas + # - alignas specifier with anonymous structs + # - decltype + closing_brace_pos = match.group(1).rfind(')') + opening_parenthesis = ReverseCloseExpression( + clean_lines, linenum, closing_brace_pos) + if opening_parenthesis[2] > -1: + line_prefix = opening_parenthesis[0][0:opening_parenthesis[2]] + macro = Search(r'\b([A-Z_][A-Z0-9_]*)\s*$', line_prefix) + func = Match(r'^(.*\])\s*$', line_prefix) + if ((macro and + macro.group(1) not in ( + 'TEST', 'TEST_F', 'MATCHER', 'MATCHER_P', 'TYPED_TEST', + 'EXCLUSIVE_LOCKS_REQUIRED', 'SHARED_LOCKS_REQUIRED', + 'LOCKS_EXCLUDED', 'INTERFACE_DEF')) or + (func and not Search(r'\boperator\s*\[\s*\]', func.group(1))) or + Search(r'\b(?:struct|union)\s+alignas\s*$', line_prefix) or + Search(r'\bdecltype$', line_prefix) or + Search(r'\s+=\s*$', line_prefix)): + match = None + if (match and + opening_parenthesis[1] > 1 and + Search(r'\]\s*$', clean_lines.elided[opening_parenthesis[1] - 1])): + # Multi-line lambda-expression + match = None + else: + # Try matching cases 2-3. + match = Match(r'^(.*(?:else|\)\s*const)\s*)\{', line) + if not match: + # Try matching cases 4-6. These are always matched on separate lines. + # + # Note that we can't simply concatenate the previous line to the + # current line and do a single match, otherwise we may output + # duplicate warnings for the blank line case: + # if (cond) { + # // blank line + # } + prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] + if prevline and Search(r'[;{}]\s*$', prevline): + match = Match(r'^(\s*)\{', line) + + # Check matching closing brace + if match: + (endline, endlinenum, endpos) = CloseExpression( + clean_lines, linenum, len(match.group(1))) + if endpos > -1 and Match(r'^\s*;', endline[endpos:]): + # Current {} pair is eligible for semicolon check, and we have found + # the redundant semicolon, output warning here. + # + # Note: because we are scanning forward for opening braces, and + # outputting warnings for the matching closing brace, if there are + # nested blocks with trailing semicolons, we will get the error + # messages in reversed order. + error(filename, endlinenum, 'readability/braces', 4, + "You don't need a ; after a }") -def ReplaceableCheck(operator, macro, line): - """Determine whether a basic CHECK can be replaced with a more specific one. - For example suggest using CHECK_EQ instead of CHECK(a == b) and - similarly for CHECK_GE, CHECK_GT, CHECK_LE, CHECK_LT, CHECK_NE. +def CheckEmptyBlockBody(filename, clean_lines, linenum, error): + """Look for empty loop/conditional body with only a single semicolon. Args: - operator: The C++ operator used in the CHECK. - macro: The CHECK or EXPECT macro being called. - line: The current source line. - - Returns: - True if the CHECK can be replaced with a more specific one. + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. """ - # This matches decimal and hex integers, strings, and chars (in that order). - match_constant = r'([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')' - - # Expression to match two sides of the operator with something that - # looks like a literal, since CHECK(x == iterator) won't compile. - # This means we can't catch all the cases where a more specific - # CHECK is possible, but it's less annoying than dealing with - # extraneous warnings. - match_this = (r'\s*' + macro + r'\((\s*' + - match_constant + r'\s*' + operator + r'[^<>].*|' - r'.*[^<>]' + operator + r'\s*' + match_constant + - r'\s*\))') + # Search for loop keywords at the beginning of the line. Because only + # whitespaces are allowed before the keywords, this will also ignore most + # do-while-loops, since those lines should start with closing brace. + # + # We also check "if" blocks here, since an empty conditional block + # is likely an error. + line = clean_lines.elided[linenum] + matched = Match(r'\s*(for|while|if)\s*\(', line) + if matched: + # Find the end of the conditional expression. + (end_line, end_linenum, end_pos) = CloseExpression( + clean_lines, linenum, line.find('(')) + + # Output warning if what follows the condition expression is a semicolon. + # No warning for all other cases, including whitespace or newline, since we + # have a separate check for semicolons preceded by whitespace. + if end_pos >= 0 and Match(r';', end_line[end_pos:]): + if matched.group(1) == 'if': + error(filename, end_linenum, 'whitespace/empty_conditional_body', 5, + 'Empty conditional bodies should use {}') + else: + error(filename, end_linenum, 'whitespace/empty_loop_body', 5, + 'Empty loop bodies should use {} or continue') + + # Check for if statements that have completely empty bodies (no comments) + # and no else clauses. + if end_pos >= 0 and matched.group(1) == 'if': + # Find the position of the opening { for the if statement. + # Return without logging an error if it has no brackets. + opening_linenum = end_linenum + opening_line_fragment = end_line[end_pos:] + # Loop until EOF or find anything that's not whitespace or opening {. + while not Search(r'^\s*\{', opening_line_fragment): + if Search(r'^(?!\s*$)', opening_line_fragment): + # Conditional has no brackets. + return + opening_linenum += 1 + if opening_linenum == len(clean_lines.elided): + # Couldn't find conditional's opening { or any code before EOF. + return + opening_line_fragment = clean_lines.elided[opening_linenum] + # Set opening_line (opening_line_fragment may not be entire opening line). + opening_line = clean_lines.elided[opening_linenum] + + # Find the position of the closing }. + opening_pos = opening_line_fragment.find('{') + if opening_linenum == end_linenum: + # We need to make opening_pos relative to the start of the entire line. + opening_pos += end_pos + (closing_line, closing_linenum, closing_pos) = CloseExpression( + clean_lines, opening_linenum, opening_pos) + if closing_pos < 0: + return + + # Now construct the body of the conditional. This consists of the portion + # of the opening line after the {, all lines until the closing line, + # and the portion of the closing line before the }. + if (clean_lines.raw_lines[opening_linenum] != + CleanseComments(clean_lines.raw_lines[opening_linenum])): + # Opening line ends with a comment, so conditional isn't empty. + return + if closing_linenum > opening_linenum: + # Opening line after the {. Ignore comments here since we checked above. + body = list(opening_line[opening_pos+1:]) + # All lines until closing line, excluding closing line, with comments. + body.extend(clean_lines.raw_lines[opening_linenum+1:closing_linenum]) + # Closing line before the }. Won't (and can't) have comments. + body.append(clean_lines.elided[closing_linenum][:closing_pos-1]) + body = '\n'.join(body) + else: + # If statement has brackets and fits on a single line. + body = opening_line[opening_pos+1:closing_pos-1] + + # Check if the body is empty + if not _EMPTY_CONDITIONAL_BODY_PATTERN.search(body): + return + # The body is empty. Now make sure there's not an else clause. + current_linenum = closing_linenum + current_line_fragment = closing_line[closing_pos:] + # Loop until EOF or find anything that's not whitespace or else clause. + while Search(r'^\s*$|^(?=\s*else)', current_line_fragment): + if Search(r'^(?=\s*else)', current_line_fragment): + # Found an else clause, so don't log an error. + return + current_linenum += 1 + if current_linenum == len(clean_lines.elided): + break + current_line_fragment = clean_lines.elided[current_linenum] + + # The body is empty and there's no else clause until EOF or other code. + error(filename, end_linenum, 'whitespace/empty_if_body', 4, + ('If statement had no body and no else clause')) + + +def FindCheckMacro(line): + """Find a replaceable CHECK-like macro. - # Don't complain about CHECK(x == NULL) or similar because - # CHECK_EQ(x, NULL) won't compile (requires a cast). - # Also, don't complain about more complex boolean expressions - # involving && or || such as CHECK(a == b || c == d). - return Match(match_this, line) and not Search(r'NULL|&&|\|\|', line) + Args: + line: line to search on. + Returns: + (macro name, start position), or (None, -1) if no replaceable + macro is found. + """ + for macro in _CHECK_MACROS: + i = line.find(macro) + if i >= 0: + # Find opening parenthesis. Do a regular expression match here + # to make sure that we are matching the expected CHECK macro, as + # opposed to some other macro that happens to contain the CHECK + # substring. + matched = Match(r'^(.*\b' + macro + r'\s*)\(', line) + if not matched: + continue + return (macro, len(matched.group(1))) + return (None, -1) def CheckCheck(filename, clean_lines, linenum, error): @@ -2007,26 +4026,143 @@ def CheckCheck(filename, clean_lines, linenum, error): """ # Decide the set of replacement macros that should be suggested - raw_lines = clean_lines.raw_lines - current_macro = '' - for macro in _CHECK_MACROS: - if raw_lines[linenum].find(macro) >= 0: - current_macro = macro - break - if not current_macro: - # Don't waste time here if line doesn't contain 'CHECK' or 'EXPECT' + lines = clean_lines.elided + (check_macro, start_pos) = FindCheckMacro(lines[linenum]) + if not check_macro: return - line = clean_lines.elided[linenum] # get rid of comments and strings + # Find end of the boolean expression by matching parentheses + (last_line, end_line, end_pos) = CloseExpression( + clean_lines, linenum, start_pos) + if end_pos < 0: + return - # Encourage replacing plain CHECKs with CHECK_EQ/CHECK_NE/etc. - for operator in ['==', '!=', '>=', '>', '<=', '<']: - if ReplaceableCheck(operator, current_macro, line): - error(filename, linenum, 'readability/check', 2, - 'Consider using %s instead of %s(a %s b)' % ( - _CHECK_REPLACEMENT[current_macro][operator], - current_macro, operator)) - break + # If the check macro is followed by something other than a + # semicolon, assume users will log their own custom error messages + # and don't suggest any replacements. + if not Match(r'\s*;', last_line[end_pos:]): + return + + if linenum == end_line: + expression = lines[linenum][start_pos + 1:end_pos - 1] + else: + expression = lines[linenum][start_pos + 1:] + for i in xrange(linenum + 1, end_line): + expression += lines[i] + expression += last_line[0:end_pos - 1] + + # Parse expression so that we can take parentheses into account. + # This avoids false positives for inputs like "CHECK((a < 4) == b)", + # which is not replaceable by CHECK_LE. + lhs = '' + rhs = '' + operator = None + while expression: + matched = Match(r'^\s*(<<|<<=|>>|>>=|->\*|->|&&|\|\||' + r'==|!=|>=|>|<=|<|\()(.*)$', expression) + if matched: + token = matched.group(1) + if token == '(': + # Parenthesized operand + expression = matched.group(2) + (end, _) = FindEndOfExpressionInLine(expression, 0, ['(']) + if end < 0: + return # Unmatched parenthesis + lhs += '(' + expression[0:end] + expression = expression[end:] + elif token in ('&&', '||'): + # Logical and/or operators. This means the expression + # contains more than one term, for example: + # CHECK(42 < a && a < b); + # + # These are not replaceable with CHECK_LE, so bail out early. + return + elif token in ('<<', '<<=', '>>', '>>=', '->*', '->'): + # Non-relational operator + lhs += token + expression = matched.group(2) + else: + # Relational operator + operator = token + rhs = matched.group(2) + break + else: + # Unparenthesized operand. Instead of appending to lhs one character + # at a time, we do another regular expression match to consume several + # characters at once if possible. Trivial benchmark shows that this + # is more efficient when the operands are longer than a single + # character, which is generally the case. + matched = Match(r'^([^-=!<>()&|]+)(.*)$', expression) + if not matched: + matched = Match(r'^(\s*\S)(.*)$', expression) + if not matched: + break + lhs += matched.group(1) + expression = matched.group(2) + + # Only apply checks if we got all parts of the boolean expression + if not (lhs and operator and rhs): + return + + # Check that rhs do not contain logical operators. We already know + # that lhs is fine since the loop above parses out && and ||. + if rhs.find('&&') > -1 or rhs.find('||') > -1: + return + + # At least one of the operands must be a constant literal. This is + # to avoid suggesting replacements for unprintable things like + # CHECK(variable != iterator) + # + # The following pattern matches decimal, hex integers, strings, and + # characters (in that order). + lhs = lhs.strip() + rhs = rhs.strip() + match_constant = r'^([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')$' + if Match(match_constant, lhs) or Match(match_constant, rhs): + # Note: since we know both lhs and rhs, we can provide a more + # descriptive error message like: + # Consider using CHECK_EQ(x, 42) instead of CHECK(x == 42) + # Instead of: + # Consider using CHECK_EQ instead of CHECK(a == b) + # + # We are still keeping the less descriptive message because if lhs + # or rhs gets long, the error message might become unreadable. + error(filename, linenum, 'readability/check', 2, + 'Consider using %s instead of %s(a %s b)' % ( + _CHECK_REPLACEMENT[check_macro][operator], + check_macro, operator)) + + +def CheckAltTokens(filename, clean_lines, linenum, error): + """Check alternative keywords being used in boolean expressions. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # Avoid preprocessor lines + if Match(r'^\s*#', line): + return + + # Last ditch effort to avoid multi-line comments. This will not help + # if the comment started before the current line or ended after the + # current line, but it catches most of the false positives. At least, + # it provides a way to workaround this warning for people who use + # multi-line comments in preprocessor macros. + # + # TODO(unknown): remove this once cpplint has better support for + # multi-line comments. + if line.find('/*') >= 0 or line.find('*/') >= 0: + return + + for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): + error(filename, linenum, 'readability/alt_tokens', 2, + 'Use operator %s instead of %s' % ( + _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) def GetLineWidth(line): @@ -2041,17 +4177,18 @@ def GetLineWidth(line): """ if isinstance(line, unicode): width = 0 - for c in unicodedata.normalize('NFC', line): - if unicodedata.east_asian_width(c) in ('W', 'F'): + for uc in unicodedata.normalize('NFC', line): + if unicodedata.east_asian_width(uc) in ('W', 'F'): width += 2 - elif not unicodedata.combining(c): + elif not unicodedata.combining(uc): width += 1 return width else: return len(line) -def CheckStyle(filename, clean_lines, linenum, file_extension, error): +def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, + error): """Checks rules from the 'C++ style rules' section of cppguide.html. Most of these rules are hard to test (naming, comment style), but we @@ -2063,11 +4200,17 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: The function to call with any errors found. """ - raw_lines = clean_lines.raw_lines + # Don't use "elided" lines here, otherwise we can't check commented lines. + # Don't want to use "raw" either, because we don't want to check inside C++11 + # raw strings, + raw_lines = clean_lines.lines_without_raw_strings line = raw_lines[linenum] + prev = raw_lines[linenum - 1] if linenum > 0 else '' if line.find('\t') != -1: error(filename, linenum, 'whitespace/tab', 1, @@ -2085,31 +4228,29 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): # if(match($0, " <<")) complain = 0; # if(match(prev, " +for \\(")) complain = 0; # if(prevodd && match(prevprev, " +for \\(")) complain = 0; + scope_or_label_pattern = r'\s*\w+\s*:\s*\\?$' + classinfo = nesting_state.InnermostClass() initial_spaces = 0 cleansed_line = clean_lines.elided[linenum] while initial_spaces < len(line) and line[initial_spaces] == ' ': initial_spaces += 1 - if line and line[-1].isspace(): - error(filename, linenum, 'whitespace/end_of_line', 4, - 'Line ends in whitespace. Consider deleting these extra spaces.') - # There are certain situations we allow one space, notably for labels - elif ((initial_spaces == 1 or initial_spaces == 3) and - not Match(r'\s*\w+\s*:\s*$', cleansed_line)): + # There are certain situations we allow one space, notably for + # section labels, and also lines containing multi-line raw strings. + # We also don't check for lines that look like continuation lines + # (of lines ending in double quotes, commas, equals, or angle brackets) + # because the rules for how to indent those are non-trivial. + if (not Search(r'[",=><] *$', prev) and + (initial_spaces == 1 or initial_spaces == 3) and + not Match(scope_or_label_pattern, cleansed_line) and + not (clean_lines.raw_lines[linenum] != line and + Match(r'^\s*""', line))): error(filename, linenum, 'whitespace/indent', 3, 'Weird number of spaces at line-start. ' 'Are you using a 2-space indent?') - # Labels should always be indented at least one space. - elif not initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$', - line): - error(filename, linenum, 'whitespace/labels', 4, - 'Labels should always be indented at least one space. ' - 'If this is a member-initializer list in a constructor or ' - 'the base class list in a class definition, the colon should ' - 'be on the following line.') - - if len(line) > initial_spaces and line[initial_spaces] == ',': - error(filename, linenum, 'whitespace/commafirst', 4, - 'Comma-first style is not allowed') + + if line and line[-1].isspace(): + error(filename, linenum, 'whitespace/end_of_line', 4, + 'Line ends in whitespace. Consider deleting these extra spaces.') # Check if the line is a header guard. is_header_guard = False @@ -2117,23 +4258,24 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): cppvar = GetHeaderGuardCPPVariable(filename) if (line.startswith('#ifndef %s' % cppvar) or line.startswith('#define %s' % cppvar) or - line.startswith('#endif // %s' % cppvar) or - line.startswith('#endif /* %s */' % cppvar)): + line.startswith('#endif // %s' % cppvar)): is_header_guard = True # #include lines and header guards can be long, since there's no clean way to # split them. # # URLs can be long too. It's possible to split these, but it makes them # harder to cut&paste. + # + # The "$Id:...$" comment may also get very long without it being the + # developers fault. if (not line.startswith('#include') and not is_header_guard and - not Match(r'^\s*//.*http(s?)://\S*$', line)): + not Match(r'^\s*//.*http(s?)://\S*$', line) and + not Match(r'^\s*//\s*[^\s]*$', line) and + not Match(r'^// \$Id:.*#[0-9]+ \$$', line)): line_width = GetLineWidth(line) - if line_width > 100: - error(filename, linenum, 'whitespace/line_length', 4, - 'Lines should very rarely be longer than 100 characters') - elif line_width > 80: + if line_width > _line_length: error(filename, linenum, 'whitespace/line_length', 2, - 'Lines should be <= 80 characters long') + 'Lines should be <= %i characters long' % _line_length) if (cleansed_line.count(';') > 1 and # for loops are allowed two ;'s (and may run over two lines). @@ -2144,16 +4286,27 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): not ((cleansed_line.find('case ') != -1 or cleansed_line.find('default:') != -1) and cleansed_line.find('break;') != -1)): - error(filename, linenum, 'whitespace/newline', 4, + error(filename, linenum, 'whitespace/newline', 0, 'More than one command on the same line') # Some more style checks CheckBraces(filename, clean_lines, linenum, error) - CheckSpacing(filename, clean_lines, linenum, error) + CheckTrailingSemicolon(filename, clean_lines, linenum, error) + CheckEmptyBlockBody(filename, clean_lines, linenum, error) + CheckAccess(filename, clean_lines, linenum, nesting_state, error) + CheckSpacing(filename, clean_lines, linenum, nesting_state, error) + CheckOperatorSpacing(filename, clean_lines, linenum, error) + CheckParenthesisSpacing(filename, clean_lines, linenum, error) + CheckCommaSpacing(filename, clean_lines, linenum, error) + CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error) + CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) CheckCheck(filename, clean_lines, linenum, error) + CheckAltTokens(filename, clean_lines, linenum, error) + classinfo = nesting_state.InnermostClass() + if classinfo: + CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) -_RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#include +"[^/]+\.h"') _RE_PATTERN_INCLUDE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]*)[>"].*$') # Matches the first component of a filename delimited by -s and _s. That is: # _RE_FIRST_COMPONENT.match('foo').group(0) == 'foo' @@ -2190,23 +4343,6 @@ def _DropCommonSuffixes(filename): return os.path.splitext(filename)[0] -def _IsTestFilename(filename): - """Determines if the given filename has a suffix that identifies it as a test. - - Args: - filename: The input filename. - - Returns: - True if 'filename' looks like a test, False otherwise. - """ - if (filename.endswith('_test.cc') or - filename.endswith('_unittest.cc') or - filename.endswith('_regtest.cc')): - return True - else: - return False - - def _ClassifyInclude(fileinfo, include, is_system): """Figures out what kind of header 'include' is. @@ -2233,8 +4369,7 @@ def _ClassifyInclude(fileinfo, include, is_system): """ # This is a list of all standard c++ header files, except # those already checked for above. - is_stl_h = include in _STL_HEADERS - is_cpp_h = is_stl_h or include in _CPP_HEADERS + is_cpp_h = include in _CPP_HEADERS if is_system: if is_cpp_h: @@ -2283,9 +4418,19 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): error: The function to call with any errors found. """ fileinfo = FileInfo(filename) - line = clean_lines.lines[linenum] - ParseNolintSuppressions(filename, line, linenum, error) + + # "include" should use the new style "foo/bar.h" instead of just "bar.h" + # Only do this check if the included header follows google naming + # conventions. If not, assume that it's a 3rd party API that + # requires special include conventions. + # + # We also make an exception for Lua headers, which follow google + # naming convention but not the include convention. + match = Match(r'#include\s*"([^/]+\.h)"', line) + if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)): + error(filename, linenum, 'build/include', 4, + 'Include the directory when naming .h files') # we shouldn't include a file more than once. actually, there are a # handful of instances where doing so is okay, but in general it's @@ -2294,13 +4439,17 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): if match: include = match.group(2) is_system = (match.group(1) == '<') - if include in include_state: - if not IsErrorSuppressedByNolint('build/include', linenum): - error(filename, linenum, 'build/include', 4, - '"%s" already included at %s:%s' % - (include, filename, include_state[include])) - else: - include_state[include] = linenum + duplicate_line = include_state.FindHeader(include) + if duplicate_line >= 0: + error(filename, linenum, 'build/include', 4, + '"%s" already included at %s:%s' % + (include, filename, duplicate_line)) + elif (include.endswith('.cc') and + os.path.dirname(fileinfo.RepositoryName()) != os.path.dirname(include)): + error(filename, linenum, 'build/include', 4, + 'Do not include .cc files from other packages') + elif not _THIRD_PARTY_HEADERS_PATTERN.match(include): + include_state.include_list[-1].append((include, linenum)) # We want to ensure that headers appear in the right order: # 1) for foo.cc, foo.h (preferred location) @@ -2313,31 +4462,108 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): # using a number of techniques. The include_state object keeps # track of the highest type seen, and complains if we see a # lower type after that. - if not IsErrorSuppressedByNolint('build/include_order', linenum): - error_message = include_state.CheckNextIncludeOrder( - _ClassifyInclude(fileinfo, include, is_system)) - if error_message: - error(filename, linenum, 'build/include_order', 4, - '%s. Should be: %s.h, c system, c++ system, other.' % - (error_message, fileinfo.BaseName())) - if not include_state.IsInAlphabeticalOrder(include): - if not IsErrorSuppressedByNolint('build/include_alpha', linenum): - error(filename, linenum, 'build/include_alpha', 4, - 'Include "%s" not in alphabetical order' % include) - - # Look for any of the stream classes that are part of standard C++. - match = _RE_PATTERN_INCLUDE.match(line) - if match: - include = match.group(2) - if Match(r'(f|ind|io|i|o|parse|pf|stdio|str|)?stream$', include): - # Many unit tests use cout, so we exempt them. - if not _IsTestFilename(filename): - if not IsErrorSuppressedByNolint('readability/streams', linenum): - error(filename, linenum, 'readability/streams', 3, - 'Streams are highly discouraged.') - -def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, - error): + error_message = include_state.CheckNextIncludeOrder( + _ClassifyInclude(fileinfo, include, is_system)) + if error_message: + error(filename, linenum, 'build/include_order', 4, + '%s. Should be: %s.h, c system, c++ system, other.' % + (error_message, fileinfo.BaseName())) + canonical_include = include_state.CanonicalizeAlphabeticalOrder(include) + if not include_state.IsInAlphabeticalOrder( + clean_lines, linenum, canonical_include): + error(filename, linenum, 'build/include_alpha', 4, + 'Include "%s" not in alphabetical order' % include) + include_state.SetLastHeader(canonical_include) + + + +def _GetTextInside(text, start_pattern): + r"""Retrieves all the text between matching open and close parentheses. + + Given a string of lines and a regular expression string, retrieve all the text + following the expression and between opening punctuation symbols like + (, [, or {, and the matching close-punctuation symbol. This properly nested + occurrences of the punctuations, so for the text like + printf(a(), b(c())); + a call to _GetTextInside(text, r'printf\(') will return 'a(), b(c())'. + start_pattern must match string having an open punctuation symbol at the end. + + Args: + text: The lines to extract text. Its comments and strings must be elided. + It can be single line and can span multiple lines. + start_pattern: The regexp string indicating where to start extracting + the text. + Returns: + The extracted text. + None if either the opening string or ending punctuation could not be found. + """ + # TODO(unknown): Audit cpplint.py to see what places could be profitably + # rewritten to use _GetTextInside (and use inferior regexp matching today). + + # Give opening punctuations to get the matching close-punctuations. + matching_punctuation = {'(': ')', '{': '}', '[': ']'} + closing_punctuation = set(matching_punctuation.itervalues()) + + # Find the position to start extracting text. + match = re.search(start_pattern, text, re.M) + if not match: # start_pattern not found in text. + return None + start_position = match.end(0) + + assert start_position > 0, ( + 'start_pattern must ends with an opening punctuation.') + assert text[start_position - 1] in matching_punctuation, ( + 'start_pattern must ends with an opening punctuation.') + # Stack of closing punctuations we expect to have in text after position. + punctuation_stack = [matching_punctuation[text[start_position - 1]]] + position = start_position + while punctuation_stack and position < len(text): + if text[position] == punctuation_stack[-1]: + punctuation_stack.pop() + elif text[position] in closing_punctuation: + # A closing punctuation without matching opening punctuations. + return None + elif text[position] in matching_punctuation: + punctuation_stack.append(matching_punctuation[text[position]]) + position += 1 + if punctuation_stack: + # Opening punctuations left without matching close-punctuations. + return None + # punctuations match. + return text[start_position:position - 1] + + +# Patterns for matching call-by-reference parameters. +# +# Supports nested templates up to 2 levels deep using this messy pattern: +# < (?: < (?: < [^<>]* +# > +# | [^<>] )* +# > +# | [^<>] )* +# > +_RE_PATTERN_IDENT = r'[_a-zA-Z]\w*' # =~ [[:alpha:]][[:alnum:]]* +_RE_PATTERN_TYPE = ( + r'(?:const\s+)?(?:typename\s+|class\s+|struct\s+|union\s+|enum\s+)?' + r'(?:\w|' + r'\s*<(?:<(?:<[^<>]*>|[^<>])*>|[^<>])*>|' + r'::)+') +# A call-by-reference parameter ends with '& identifier'. +_RE_PATTERN_REF_PARAM = re.compile( + r'(' + _RE_PATTERN_TYPE + r'(?:\s*(?:\bconst\b|[*]))*\s*' + r'&\s*' + _RE_PATTERN_IDENT + r')\s*(?:=[^,()]+)?[,)]') +# A call-by-const-reference parameter either ends with 'const& identifier' +# or looks like 'const type& identifier' when 'type' is atomic. +_RE_PATTERN_CONST_REF_PARAM = ( + r'(?:.*\s*\bconst\s*&\s*' + _RE_PATTERN_IDENT + + r'|const\s+' + _RE_PATTERN_TYPE + r'\s*&\s*' + _RE_PATTERN_IDENT + r')') +# Stream types. +_RE_PATTERN_REF_STREAM_PARAM = ( + r'(?:.*stream\s*&\s*' + _RE_PATTERN_IDENT + r')') + + +def CheckLanguage(filename, clean_lines, linenum, file_extension, + include_state, nesting_state, error): """Checks rules from the 'C++ language rules' section of cppguide.html. Some of these rules are hard to test (function overloading, using @@ -2349,6 +4575,8 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. include_state: An _IncludeState instance in which the headers are inserted. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: The function to call with any errors found. """ # If the line is empty or consists of entirely a comment, no need to @@ -2362,110 +4590,25 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, CheckIncludeLine(filename, clean_lines, linenum, include_state, error) return - # Create an extended_line, which is the concatenation of the current and - # next lines, for more effective checking of code that may span more than one - # line. - if linenum + 1 < clean_lines.NumLines(): - extended_line = line + clean_lines.elided[linenum + 1] - else: - extended_line = line + # Reset include state across preprocessor directives. This is meant + # to silence warnings for conditional includes. + match = Match(r'^\s*#\s*(if|ifdef|ifndef|elif|else|endif)\b', line) + if match: + include_state.ResetSection(match.group(1)) # Make Windows paths like Unix. fullname = os.path.abspath(filename).replace('\\', '/') - # TODO(unknown): figure out if they're using default arguments in fn proto. - - # Check for non-const references in functions. This is tricky because & - # is also used to take the address of something. We allow <> for templates, - # (ignoring whatever is between the braces) and : for classes. - # These are complicated re's. They try to capture the following: - # paren (for fn-prototype start), typename, &, varname. For the const - # version, we're willing for const to be before typename or after - # Don't check the implemention on same line. - fnline = line.split('{', 1)[0] - if (len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) > - len(re.findall(r'\([^()]*\bconst\s+(?:typename\s+)?(?:struct\s+)?' - r'(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) + - len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+\s+const(\s?&|&\s?)[\w]+', - fnline))): - - # We allow non-const references in a few standard places, like functions - # called "swap()" or iostream operators like "<<" or ">>". - if not Search( - r'(swap|Swap|operator[<>][<>])\s*\(\s*(?:[\w:]|<.*>)+\s*&', - fnline): - error(filename, linenum, 'runtime/references', 2, - 'Is this a non-const reference? ' - 'If so, make const or use a pointer.') - - # Check to see if they're using an conversion function cast. - # I just try to capture the most common basic types, though there are more. - # Parameterless conversion functions, such as bool(), are allowed as they are - # probably a member operator declaration or default constructor. - match = Search( - r'(\bnew\s+)?\b' # Grab 'new' operator, if it's there - r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line) - if match: - # gMock methods are defined using some variant of MOCK_METHODx(name, type) - # where type may be float(), int(string), etc. Without context they are - # virtually indistinguishable from int(x) casts. - if (match.group(1) is None and # If new operator, then this isn't a cast - not Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line)): - error(filename, linenum, 'readability/casting', 4, - 'Using deprecated casting style. ' - 'Use static_cast<%s>(...) instead' % - match.group(2)) - - CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'static_cast', - r'\((int|float|double|bool|char|u?int(16|32|64))\)', - error) - # This doesn't catch all cases. Consider (const char * const)"hello". - CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) - - # In addition, we look for people taking the address of a cast. This - # is dangerous -- casts can assign to temporaries, so the pointer doesn't - # point where you think. - if Search( - r'(&\([^)]+\)[\w(])|(&(static|dynamic|reinterpret)_cast\b)', line): - error(filename, linenum, 'runtime/casting', 4, - ('Are you taking an address of a cast? ' - 'This is dangerous: could be a temp var. ' - 'Take the address before doing the cast, rather than after')) - - # Check for people declaring static/global STL strings at the top level. - # This is dangerous because the C++ language does not guarantee that - # globals with constructors are initialized before the first access. - match = Match( - r'((?:|static +)(?:|const +))string +([a-zA-Z0-9_:]+)\b(.*)', - line) - # Make sure it's not a function. - # Function template specialization looks like: "string foo(...". - # Class template definitions look like: "string Foo::Method(...". - if match and not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)?\s*\(([^"]|$)', - match.group(3)): - error(filename, linenum, 'runtime/string', 4, - 'For a static/global string constant, use a C style string instead: ' - '"%schar %s[]".' % - (match.group(1), match.group(2))) - - # Check that we're not using RTTI outside of testing code. - if Search(r'\bdynamic_cast<', line) and not _IsTestFilename(filename): - error(filename, linenum, 'runtime/rtti', 5, - 'Do not use dynamic_cast<>. If you need to cast within a class ' - "hierarchy, use static_cast<> to upcast. Google doesn't support " - 'RTTI.') - - if Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line): - error(filename, linenum, 'runtime/init', 4, - 'You seem to be initializing a member variable with itself.') + # Perform other checks now that we are sure that this is not an include line + CheckCasts(filename, clean_lines, linenum, error) + CheckGlobalStatic(filename, clean_lines, linenum, error) + CheckPrintf(filename, clean_lines, linenum, error) if file_extension == 'h': # TODO(unknown): check that 1-arg constructors are explicit. # How to tell it's a constructor? # (handled in CheckForNonStandardConstructs for now) - # TODO(unknown): check that classes have DISALLOW_EVIL_CONSTRUCTORS + # TODO(unknown): check that classes declare or disable copy/assign # (level 1 error) pass @@ -2475,11 +4618,179 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, if not Search(r'\bunsigned short port\b', line): error(filename, linenum, 'runtime/int', 4, 'Use "unsigned short" for ports, not "short"') -# else: -# match = Search(r'\b(short|long(?! +double)|long long)\b', line) -# if match: -# error(filename, linenum, 'runtime/int', 4, -# 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) + else: + match = Search(r'\b(short|long(?! +double)|long long)\b', line) + if match: + error(filename, linenum, 'runtime/int', 4, + 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) + + # Check if some verboten operator overloading is going on + # TODO(unknown): catch out-of-line unary operator&: + # class X {}; + # int operator&(const X& x) { return 42; } // unary operator& + # The trick is it's hard to tell apart from binary operator&: + # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& + if Search(r'\boperator\s*&\s*\(\s*\)', line): + error(filename, linenum, 'runtime/operator', 4, + 'Unary operator& is dangerous. Do not use it.') + + # Check for suspicious usage of "if" like + # } if (a == b) { + if Search(r'\}\s*if\s*\(', line): + error(filename, linenum, 'readability/braces', 4, + 'Did you mean "else if"? If not, start a new line for "if".') + + # Check for potential format string bugs like printf(foo). + # We constrain the pattern not to pick things like DocidForPrintf(foo). + # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) + # TODO(unknown): Catch the following case. Need to change the calling + # convention of the whole function to process multiple line to handle it. + # printf( + # boy_this_is_a_really_long_variable_that_cannot_fit_on_the_prev_line); + printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') + if printf_args: + match = Match(r'([\w.\->()]+)$', printf_args) + if match and match.group(1) != '__VA_ARGS__': + function_name = re.search(r'\b((?:string)?printf)\s*\(', + line, re.I).group(1) + error(filename, linenum, 'runtime/printf', 4, + 'Potential format string bug. Do %s("%%s", %s) instead.' + % (function_name, match.group(1))) + + # Check for potential memset bugs like memset(buf, sizeof(buf), 0). + match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) + if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): + error(filename, linenum, 'runtime/memset', 4, + 'Did you mean "memset(%s, 0, %s)"?' + % (match.group(1), match.group(2))) + + if Search(r'\busing namespace\b', line): + error(filename, linenum, 'build/namespaces', 5, + 'Do not use namespace using-directives. ' + 'Use using-declarations instead.') + + # Detect variable-length arrays. + match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) + if (match and match.group(2) != 'return' and match.group(2) != 'delete' and + match.group(3).find(']') == -1): + # Split the size using space and arithmetic operators as delimiters. + # If any of the resulting tokens are not compile time constants then + # report the error. + tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) + is_const = True + skip_next = False + for tok in tokens: + if skip_next: + skip_next = False + continue + + if Search(r'sizeof\(.+\)', tok): continue + if Search(r'arraysize\(\w+\)', tok): continue + + tok = tok.lstrip('(') + tok = tok.rstrip(')') + if not tok: continue + if Match(r'\d+', tok): continue + if Match(r'0[xX][0-9a-fA-F]+', tok): continue + if Match(r'k[A-Z0-9]\w*', tok): continue + if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue + if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue + # A catch all for tricky sizeof cases, including 'sizeof expression', + # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' + # requires skipping the next token because we split on ' ' and '*'. + if tok.startswith('sizeof'): + skip_next = True + continue + is_const = False + break + if not is_const: + error(filename, linenum, 'runtime/arrays', 1, + 'Do not use variable-length arrays. Use an appropriately named ' + "('k' followed by CamelCase) compile-time constant for the size.") + + # Check for use of unnamed namespaces in header files. Registration + # macros are typically OK, so we allow use of "namespace {" on lines + # that end with backslashes. + if (file_extension == 'h' + and Search(r'\bnamespace\s*{', line) + and line[-1] != '\\'): + error(filename, linenum, 'build/namespaces', 4, + 'Do not use unnamed namespaces in header files. See ' + 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' + ' for more information.') + + +def CheckGlobalStatic(filename, clean_lines, linenum, error): + """Check for unsafe global or static objects. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + # Match two lines at a time to support multiline declarations + if linenum + 1 < clean_lines.NumLines() and not Search(r'[;({]', line): + line += clean_lines.elided[linenum + 1].strip() + + # Check for people declaring static/global STL strings at the top level. + # This is dangerous because the C++ language does not guarantee that + # globals with constructors are initialized before the first access, and + # also because globals can be destroyed when some threads are still running. + # TODO(unknown): Generalize this to also find static unique_ptr instances. + # TODO(unknown): File bugs for clang-tidy to find these. + match = Match( + r'((?:|static +)(?:|const +))(?::*std::)?string( +const)? +' + r'([a-zA-Z0-9_:]+)\b(.*)', + line) + + # Remove false positives: + # - String pointers (as opposed to values). + # string *pointer + # const string *pointer + # string const *pointer + # string *const pointer + # + # - Functions and template specializations. + # string Function(... + # string Class::Method(... + # + # - Operators. These are matched separately because operator names + # cross non-word boundaries, and trying to match both operators + # and functions at the same time would decrease accuracy of + # matching identifiers. + # string Class::operator*() + if (match and + not Search(r'\bstring\b(\s+const)?\s*[\*\&]\s*(const\s+)?\w', line) and + not Search(r'\boperator\W', line) and + not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)*\s*\(([^"]|$)', match.group(4))): + if Search(r'\bconst\b', line): + error(filename, linenum, 'runtime/string', 4, + 'For a static/global string constant, use a C style string ' + 'instead: "%schar%s %s[]".' % + (match.group(1), match.group(2) or '', match.group(3))) + else: + error(filename, linenum, 'runtime/string', 4, + 'Static/global string variables are not permitted.') + + if (Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line) or + Search(r'\b([A-Za-z0-9_]*_)\(CHECK_NOTNULL\(\1\)\)', line)): + error(filename, linenum, 'runtime/init', 4, + 'You seem to be initializing a member variable with itself.') + + +def CheckPrintf(filename, clean_lines, linenum, error): + """Check for printf related issues. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] # When snprintf is used, the second argument shouldn't be a literal. match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line) @@ -2490,174 +4801,427 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, 'to snprintf.' % (match.group(1), match.group(2))) # Check if some verboten C functions are being used. - if Search(r'\bsprintf\b', line): + if Search(r'\bsprintf\s*\(', line): error(filename, linenum, 'runtime/printf', 5, - 'Never use sprintf. Use snprintf instead.') - match = Search(r'\b(strcpy|strcat)\b', line) + 'Never use sprintf. Use snprintf instead.') + match = Search(r'\b(strcpy|strcat)\s*\(', line) if match: error(filename, linenum, 'runtime/printf', 4, 'Almost always, snprintf is better than %s' % match.group(1)) - if Search(r'\bsscanf\b', line): - error(filename, linenum, 'runtime/printf', 1, - 'sscanf can be ok, but is slow and can overflow buffers.') - # Check if some verboten operator overloading is going on - # TODO(unknown): catch out-of-line unary operator&: - # class X {}; - # int operator&(const X& x) { return 42; } // unary operator& - # The trick is it's hard to tell apart from binary operator&: - # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& - if Search(r'\boperator\s*&\s*\(\s*\)', line): - error(filename, linenum, 'runtime/operator', 4, - 'Unary operator& is dangerous. Do not use it.') +def IsDerivedFunction(clean_lines, linenum): + """Check if current line contains an inherited function. - # Check for suspicious usage of "if" like - # } if (a == b) { - if Search(r'\}\s*if\s*\(', line): - error(filename, linenum, 'readability/braces', 4, - 'Did you mean "else if"? If not, start a new line for "if".') + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + Returns: + True if current line contains a function with "override" + virt-specifier. + """ + # Scan back a few lines for start of current function + for i in xrange(linenum, max(-1, linenum - 10), -1): + match = Match(r'^([^()]*\w+)\(', clean_lines.elided[i]) + if match: + # Look for "override" after the matching closing parenthesis + line, _, closing_paren = CloseExpression( + clean_lines, i, len(match.group(1))) + return (closing_paren >= 0 and + Search(r'\boverride\b', line[closing_paren:])) + return False + + +def IsOutOfLineMethodDefinition(clean_lines, linenum): + """Check if current line contains an out-of-line method definition. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + Returns: + True if current line contains an out-of-line method definition. + """ + # Scan back a few lines for start of current function + for i in xrange(linenum, max(-1, linenum - 10), -1): + if Match(r'^([^()]*\w+)\(', clean_lines.elided[i]): + return Match(r'^[^()]*\w+::\w+\(', clean_lines.elided[i]) is not None + return False + + +def IsInitializerList(clean_lines, linenum): + """Check if current line is inside constructor initializer list. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + Returns: + True if current line appears to be inside constructor initializer + list, False otherwise. + """ + for i in xrange(linenum, 1, -1): + line = clean_lines.elided[i] + if i == linenum: + remove_function_body = Match(r'^(.*)\{\s*$', line) + if remove_function_body: + line = remove_function_body.group(1) + + if Search(r'\s:\s*\w+[({]', line): + # A lone colon tend to indicate the start of a constructor + # initializer list. It could also be a ternary operator, which + # also tend to appear in constructor initializer lists as + # opposed to parameter lists. + return True + if Search(r'\}\s*,\s*$', line): + # A closing brace followed by a comma is probably the end of a + # brace-initialized member in constructor initializer list. + return True + if Search(r'[{};]\s*$', line): + # Found one of the following: + # - A closing brace or semicolon, probably the end of the previous + # function. + # - An opening brace, probably the start of current class or namespace. + # + # Current line is probably not inside an initializer list since + # we saw one of those things without seeing the starting colon. + return False + + # Got to the beginning of the file without seeing the start of + # constructor initializer list. + return False + + +def CheckForNonConstReference(filename, clean_lines, linenum, + nesting_state, error): + """Check for non-const references. + + Separate from CheckLanguage since it scans backwards from current + line, instead of scanning forward. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. + error: The function to call with any errors found. + """ + # Do nothing if there is no '&' on current line. + line = clean_lines.elided[linenum] + if '&' not in line: + return + + # If a function is inherited, current function doesn't have much of + # a choice, so any non-const references should not be blamed on + # derived function. + if IsDerivedFunction(clean_lines, linenum): + return + + # Don't warn on out-of-line method definitions, as we would warn on the + # in-line declaration, if it isn't marked with 'override'. + if IsOutOfLineMethodDefinition(clean_lines, linenum): + return + + # Long type names may be broken across multiple lines, usually in one + # of these forms: + # LongType + # ::LongTypeContinued &identifier + # LongType:: + # LongTypeContinued &identifier + # LongType< + # ...>::LongTypeContinued &identifier + # + # If we detected a type split across two lines, join the previous + # line to current line so that we can match const references + # accordingly. + # + # Note that this only scans back one line, since scanning back + # arbitrary number of lines would be expensive. If you have a type + # that spans more than 2 lines, please use a typedef. + if linenum > 1: + previous = None + if Match(r'\s*::(?:[\w<>]|::)+\s*&\s*\S', line): + # previous_line\n + ::current_line + previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+[\w<>])\s*$', + clean_lines.elided[linenum - 1]) + elif Match(r'\s*[a-zA-Z_]([\w<>]|::)+\s*&\s*\S', line): + # previous_line::\n + current_line + previous = Search(r'\b((?:const\s*)?(?:[\w<>]|::)+::)\s*$', + clean_lines.elided[linenum - 1]) + if previous: + line = previous.group(1) + line.lstrip() + else: + # Check for templated parameter that is split across multiple lines + endpos = line.rfind('>') + if endpos > -1: + (_, startline, startpos) = ReverseCloseExpression( + clean_lines, linenum, endpos) + if startpos > -1 and startline < linenum: + # Found the matching < on an earlier line, collect all + # pieces up to current line. + line = '' + for i in xrange(startline, linenum + 1): + line += clean_lines.elided[i].strip() + + # Check for non-const references in function parameters. A single '&' may + # found in the following places: + # inside expression: binary & for bitwise AND + # inside expression: unary & for taking the address of something + # inside declarators: reference parameter + # We will exclude the first two cases by checking that we are not inside a + # function body, including one that was just introduced by a trailing '{'. + # TODO(unknown): Doesn't account for 'catch(Exception& e)' [rare]. + if (nesting_state.previous_stack_top and + not (isinstance(nesting_state.previous_stack_top, _ClassInfo) or + isinstance(nesting_state.previous_stack_top, _NamespaceInfo))): + # Not at toplevel, not within a class, and not within a namespace + return + + # Avoid initializer lists. We only need to scan back from the + # current line for something that starts with ':'. + # + # We don't need to check the current line, since the '&' would + # appear inside the second set of parentheses on the current line as + # opposed to the first set. + if linenum > 0: + for i in xrange(linenum - 1, max(0, linenum - 10), -1): + previous_line = clean_lines.elided[i] + if not Search(r'[),]\s*$', previous_line): + break + if Match(r'^\s*:\s+\S', previous_line): + return + + # Avoid preprocessors + if Search(r'\\\s*$', line): + return + + # Avoid constructor initializer lists + if IsInitializerList(clean_lines, linenum): + return + + # We allow non-const references in a few standard places, like functions + # called "swap()" or iostream operators like "<<" or ">>". Do not check + # those function parameters. + # + # We also accept & in static_assert, which looks like a function but + # it's actually a declaration expression. + whitelisted_functions = (r'(?:[sS]wap(?:<\w:+>)?|' + r'operator\s*[<>][<>]|' + r'static_assert|COMPILE_ASSERT' + r')\s*\(') + if Search(whitelisted_functions, line): + return + elif not Search(r'\S+\([^)]*$', line): + # Don't see a whitelisted function on this line. Actually we + # didn't see any function name on this line, so this is likely a + # multi-line parameter list. Try a bit harder to catch this case. + for i in xrange(2): + if (linenum > i and + Search(whitelisted_functions, clean_lines.elided[linenum - i - 1])): + return + + decls = ReplaceAll(r'{[^}]*}', ' ', line) # exclude function body + for parameter in re.findall(_RE_PATTERN_REF_PARAM, decls): + if (not Match(_RE_PATTERN_CONST_REF_PARAM, parameter) and + not Match(_RE_PATTERN_REF_STREAM_PARAM, parameter)): + error(filename, linenum, 'runtime/references', 2, + 'Is this a non-const reference? ' + 'If so, make const or use a pointer: ' + + ReplaceAll(' *<', '<', parameter)) - # Check for potential format string bugs like printf(foo). - # We constrain the pattern not to pick things like DocidForPrintf(foo). - # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) - match = re.search(r'\b((?:string)?printf)\s*\(([\w.\->()]+)\)', line, re.I) - if match: - error(filename, linenum, 'runtime/printf', 4, - 'Potential format string bug. Do %s("%%s", %s) instead.' - % (match.group(1), match.group(2))) - # Check for potential memset bugs like memset(buf, sizeof(buf), 0). - match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) - if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): - error(filename, linenum, 'runtime/memset', 4, - 'Did you mean "memset(%s, 0, %s)"?' - % (match.group(1), match.group(2))) +def CheckCasts(filename, clean_lines, linenum, error): + """Various cast related checks. - if Search(r'\busing namespace\b', line): - error(filename, linenum, 'build/namespaces', 5, - 'Do not use namespace using-directives. ' - 'Use using-declarations instead.') + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] - # Detect variable-length arrays. - match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) - if (match and match.group(2) != 'return' and match.group(2) != 'delete' and - match.group(3).find(']') == -1): - # Split the size using space and arithmetic operators as delimiters. - # If any of the resulting tokens are not compile time constants then - # report the error. - tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) - is_const = True - skip_next = False - for tok in tokens: - if skip_next: - skip_next = False - continue + # Check to see if they're using an conversion function cast. + # I just try to capture the most common basic types, though there are more. + # Parameterless conversion functions, such as bool(), are allowed as they are + # probably a member operator declaration or default constructor. + match = Search( + r'(\bnew\s+(?:const\s+)?|\S<\s*(?:const\s+)?)?\b' + r'(int|float|double|bool|char|int32|uint32|int64|uint64)' + r'(\([^)].*)', line) + expecting_function = ExpectingFunctionArgs(clean_lines, linenum) + if match and not expecting_function: + matched_type = match.group(2) + + # matched_new_or_template is used to silence two false positives: + # - New operators + # - Template arguments with function types + # + # For template arguments, we match on types immediately following + # an opening bracket without any spaces. This is a fast way to + # silence the common case where the function type is the first + # template argument. False negative with less-than comparison is + # avoided because those operators are usually followed by a space. + # + # function // bracket + no space = false positive + # value < double(42) // bracket + space = true positive + matched_new_or_template = match.group(1) - if Search(r'sizeof\(.+\)', tok): continue - if Search(r'arraysize\(\w+\)', tok): continue + # Avoid arrays by looking for brackets that come after the closing + # parenthesis. + if Match(r'\([^()]+\)\s*\[', match.group(3)): + return - tok = tok.lstrip('(') - tok = tok.rstrip(')') - if not tok: continue - if Match(r'\d+', tok): continue - if Match(r'0[xX][0-9a-fA-F]+', tok): continue - if Match(r'k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue - if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue - # A catch all for tricky sizeof cases, including 'sizeof expression', - # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' - # requires skipping the next token becasue we split on ' ' and '*'. - if tok.startswith('sizeof'): - skip_next = True - continue - is_const = False - break - if not is_const: - error(filename, linenum, 'runtime/arrays', 1, - 'Do not use variable-length arrays. Use an appropriately named ' - "('k' followed by CamelCase) compile-time constant for the size.") + # Other things to ignore: + # - Function pointers + # - Casts to pointer types + # - Placement new + # - Alias declarations + matched_funcptr = match.group(3) + if (matched_new_or_template is None and + not (matched_funcptr and + (Match(r'\((?:[^() ]+::\s*\*\s*)?[^() ]+\)\s*\(', + matched_funcptr) or + matched_funcptr.startswith('(*)'))) and + not Match(r'\s*using\s+\S+\s*=\s*' + matched_type, line) and + not Search(r'new\(\S+\)\s*' + matched_type, line)): + error(filename, linenum, 'readability/casting', 4, + 'Using deprecated casting style. ' + 'Use static_cast<%s>(...) instead' % + matched_type) - # If DISALLOW_EVIL_CONSTRUCTORS, DISALLOW_COPY_AND_ASSIGN, or - # DISALLOW_IMPLICIT_CONSTRUCTORS is present, then it should be the last thing - # in the class declaration. - match = Match( - (r'\s*' - r'(DISALLOW_(EVIL_CONSTRUCTORS|COPY_AND_ASSIGN|IMPLICIT_CONSTRUCTORS))' - r'\(.*\);$'), - line) - if match and linenum + 1 < clean_lines.NumLines(): - next_line = clean_lines.elided[linenum + 1] - if not Search(r'^\s*};', next_line): - error(filename, linenum, 'readability/constructors', 3, - match.group(1) + ' should be the last thing in the class') + if not expecting_function: + CheckCStyleCast(filename, clean_lines, linenum, 'static_cast', + r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) - # Check for use of unnamed namespaces in header files. Registration - # macros are typically OK, so we allow use of "namespace {" on lines - # that end with backslashes. - if (file_extension == 'h' - and Search(r'\bnamespace\s*{', line) - and line[-1] != '\\'): - error(filename, linenum, 'build/namespaces', 4, - 'Do not use unnamed namespaces in header files. See ' - 'http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' - ' for more information.') + # This doesn't catch all cases. Consider (const char * const)"hello". + # + # (char *) "foo" should always be a const_cast (reinterpret_cast won't + # compile). + if CheckCStyleCast(filename, clean_lines, linenum, 'const_cast', + r'\((char\s?\*+\s?)\)\s*"', error): + pass + else: + # Check pointer casts for other than string constants + CheckCStyleCast(filename, clean_lines, linenum, 'reinterpret_cast', + r'\((\w+\s?\*+\s?)\)', error) + + # In addition, we look for people taking the address of a cast. This + # is dangerous -- casts can assign to temporaries, so the pointer doesn't + # point where you think. + # + # Some non-identifier character is required before the '&' for the + # expression to be recognized as a cast. These are casts: + # expression = &static_cast(temporary()); + # function(&(int*)(temporary())); + # + # This is not a cast: + # reference_type&(int* function_param); + match = Search( + r'(?:[^\w]&\(([^)*][^)]*)\)[\w(])|' + r'(?:[^\w]&(static|dynamic|down|reinterpret)_cast\b)', line) + if match: + # Try a better error message when the & is bound to something + # dereferenced by the casted pointer, as opposed to the casted + # pointer itself. + parenthesis_error = False + match = Match(r'^(.*&(?:static|dynamic|down|reinterpret)_cast\b)<', line) + if match: + _, y1, x1 = CloseExpression(clean_lines, linenum, len(match.group(1))) + if x1 >= 0 and clean_lines.elided[y1][x1] == '(': + _, y2, x2 = CloseExpression(clean_lines, y1, x1) + if x2 >= 0: + extended_line = clean_lines.elided[y2][x2:] + if y2 < clean_lines.NumLines() - 1: + extended_line += clean_lines.elided[y2 + 1] + if Match(r'\s*(?:->|\[)', extended_line): + parenthesis_error = True + + if parenthesis_error: + error(filename, linenum, 'readability/casting', 4, + ('Are you taking an address of something dereferenced ' + 'from a cast? Wrapping the dereferenced expression in ' + 'parentheses will make the binding more obvious')) + else: + error(filename, linenum, 'runtime/casting', 4, + ('Are you taking an address of a cast? ' + 'This is dangerous: could be a temp var. ' + 'Take the address before doing the cast, rather than after')) -def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, - error): +def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): """Checks for a C-style cast by looking for the pattern. - This also handles sizeof(type) warnings, due to similarity of content. - Args: filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. - line: The line of code to check. - raw_line: The raw line of code to check, with comments. cast_type: The string for the C++ cast to recommend. This is either - reinterpret_cast or static_cast, depending. + reinterpret_cast, static_cast, or const_cast, depending. pattern: The regular expression used to find C-style casts. error: The function to call with any errors found. + + Returns: + True if an error was emitted. + False otherwise. """ + line = clean_lines.elided[linenum] match = Search(pattern, line) if not match: - return + return False - # e.g., sizeof(int) - sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1]) - if sizeof_match: - error(filename, linenum, 'runtime/sizeof', 1, - 'Using sizeof(type). Use sizeof(varname) instead if possible') - return + # Exclude lines with keywords that tend to look like casts + context = line[0:match.start(1) - 1] + if Match(r'.*\b(?:sizeof|alignof|alignas|[_A-Z][_A-Z0-9]*)\s*$', context): + return False - remainder = line[match.end(0):] + # Try expanding current context to see if we one level of + # parentheses inside a macro. + if linenum > 0: + for i in xrange(linenum - 1, max(0, linenum - 5), -1): + context = clean_lines.elided[i] + context + if Match(r'.*\b[_A-Z][_A-Z0-9]*\s*\((?:\([^()]*\)|[^()])*$', context): + return False - # The close paren is for function pointers as arguments to a function. - # eg, void foo(void (*bar)(int)); - # The semicolon check is a more basic function check; also possibly a - # function pointer typedef. - # eg, void foo(int); or void foo(int) const; - # The equals check is for function pointer assignment. - # eg, void *(*foo)(int) = ... - # - # Right now, this will only catch cases where there's a single argument, and - # it's unnamed. It should probably be expanded to check for multiple - # arguments with some unnamed. - function_match = Match(r'\s*(\)|=|(const)?\s*(;|\{|throw\(\)))', remainder) - if function_match: - if (not function_match.group(3) or - function_match.group(3) == ';' or - raw_line.find('/*') < 0): - error(filename, linenum, 'readability/function', 3, - 'All parameters should be named in a function') - return + # operator++(int) and operator--(int) + if context.endswith(' operator++') or context.endswith(' operator--'): + return False + + # A single unnamed argument for a function tends to look like old style cast. + # If we see those, don't issue warnings for deprecated casts. + remainder = line[match.end(0):] + if Match(r'^\s*(?:;|const\b|throw\b|final\b|override\b|[=>{),]|->)', + remainder): + return False # At this point, all that should be left is actual casts. error(filename, linenum, 'readability/casting', 4, 'Using C-style cast. Use %s<%s>(...) instead' % (cast_type, match.group(1))) + return True + + +def ExpectingFunctionArgs(clean_lines, linenum): + """Checks whether where function type arguments are expected. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + + Returns: + True if the line at 'linenum' is inside something that expects arguments + of function types. + """ + line = clean_lines.elided[linenum] + return (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or + (linenum >= 2 and + (Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\((?:\S+,)?\s*$', + clean_lines.elided[linenum - 1]) or + Match(r'^\s*MOCK_(?:CONST_)?METHOD\d+(?:_T)?\(\s*$', + clean_lines.elided[linenum - 2]) or + Search(r'\bstd::m?function\s*\<\s*$', + clean_lines.elided[linenum - 1])))) + _HEADERS_CONTAINING_TEMPLATES = ( ('', ('deque',)), @@ -2686,6 +5250,7 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, ('', ('set', 'multiset',)), ('', ('stack',)), ('', ('char_traits', 'basic_string',)), + ('', ('tuple',)), ('', ('pair',)), ('', ('vector',)), @@ -2696,23 +5261,26 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, ('', ('slist',)), ) -_HEADERS_ACCEPTED_BUT_NOT_PROMOTED = { - # We can trust with reasonable confidence that map gives us pair<>, too. - 'pair<>': ('map', 'multimap', 'hash_map', 'hash_multimap') -} +_HEADERS_MAYBE_TEMPLATES = ( + ('', ('copy', 'max', 'min', 'min_element', 'sort', + 'transform', + )), + ('', ('swap',)), + ) _RE_PATTERN_STRING = re.compile(r'\bstring\b') -_re_pattern_algorithm_header = [] -for _template in ('copy', 'max', 'min', 'min_element', 'sort', 'swap', - 'transform'): - # Match max(..., ...), max(..., ...), but not foo->max, foo.max or - # type::max(). - _re_pattern_algorithm_header.append( - (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), - _template, - '')) - +_re_pattern_headers_maybe_templates = [] +for _header, _templates in _HEADERS_MAYBE_TEMPLATES: + for _template in _templates: + # Match max(..., ...), max(..., ...), but not foo->max, foo.max or + # type::max(). + _re_pattern_headers_maybe_templates.append( + (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), + _template, + _header)) + +# Other scripts may reach in and modify this pattern. _re_pattern_templates = [] for _header, _templates in _HEADERS_CONTAINING_TEMPLATES: for _template in _templates: @@ -2752,13 +5320,13 @@ def FilesBelongToSameModule(filename_cc, filename_h): string: the additional prefix needed to open the header file. """ - if not filename_cc.endswith('.cc'): + fileinfo = FileInfo(filename_cc) + if not fileinfo.IsSource(): return (False, '') - filename_cc = filename_cc[:-len('.cc')] - if filename_cc.endswith('_unittest'): - filename_cc = filename_cc[:-len('_unittest')] - elif filename_cc.endswith('_test'): - filename_cc = filename_cc[:-len('_test')] + filename_cc = filename_cc[:-len(fileinfo.Extension())] + matched_test_suffix = Search(_TEST_FILE_SUFFIX, fileinfo.BaseName()) + if matched_test_suffix: + filename_cc = filename_cc[:-len(matched_test_suffix.group(1))] filename_cc = filename_cc.replace('/public/', '/') filename_cc = filename_cc.replace('/internal/', '/') @@ -2777,16 +5345,16 @@ def FilesBelongToSameModule(filename_cc, filename_h): return files_belong_to_same_module, common_path -def UpdateIncludeState(filename, include_state, io=codecs): - """Fill up the include_state with new includes found from the file. +def UpdateIncludeState(filename, include_dict, io=codecs): + """Fill up the include_dict with new includes found from the file. Args: filename: the name of the header to read. - include_state: an _IncludeState instance in which the headers are inserted. + include_dict: a dictionary in which the headers are inserted. io: The io factory to use to read the file. Provided for testability. Returns: - True if a header was succesfully added. False otherwise. + True if a header was successfully added. False otherwise. """ headerfile = None try: @@ -2800,9 +5368,7 @@ def UpdateIncludeState(filename, include_state, io=codecs): match = _RE_PATTERN_INCLUDE.search(clean_line) if match: include = match.group(2) - # The value formatting is cute, but not really used right now. - # What matters here is that the key is in include_state. - include_state.setdefault(include, '%s:%d' % (filename, linenum)) + include_dict.setdefault(include, linenum) return True @@ -2832,7 +5398,16 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, if not line or line[0] == '#': continue - for pattern, template, header in _re_pattern_algorithm_header: + # String is special -- it is a non-templatized type in STL. + matched = _RE_PATTERN_STRING.search(line) + if matched: + # Don't warn about strings in non-STL namespaces: + # (We check only the first match per line; good enough.) + prefix = line[:matched.start()] + if prefix.endswith('std::') or not prefix.endswith('::'): + required[''] = (linenum, 'string') + + for pattern, template, header in _re_pattern_headers_maybe_templates: if pattern.search(line): required[header] = (linenum, template) @@ -2846,14 +5421,15 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # The policy is that if you #include something in foo.h you don't need to # include it again in foo.cc. Here, we will look at possible includes. - # Let's copy the include_state so it is only messed up within this function. - include_state = include_state.copy() + # Let's flatten the include_state include_list and copy it into a dictionary. + include_dict = dict([item for sublist in include_state.include_list + for item in sublist]) - # Did we find the header for this file (if any) and succesfully load it? + # Did we find the header for this file (if any) and successfully load it? header_found = False # Use the absolute path so that matching works properly. - abs_filename = os.path.abspath(filename) + abs_filename = FileInfo(filename).FullName() # For Emacs's flymake. # If cpplint is invoked from Emacs's flymake, a temporary file is generated @@ -2864,12 +5440,13 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # instead of 'foo_flymake.h' abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename) - # include_state is modified during iteration, so we iterate over a copy of + # include_dict is modified during iteration, so we iterate over a copy of # the keys. - for header in include_state.keys(): #NOLINT + header_keys = include_dict.keys() + for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header - if same_module and UpdateIncludeState(fullpath, include_state, io): + if same_module and UpdateIncludeState(fullpath, include_dict, io): header_found = True # If we can't find the header file for a .cc, assume it's because we don't @@ -2883,19 +5460,198 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # All the lines have been processed, report the errors found. for required_header_unstripped in required: template = required[required_header_unstripped][1] - if template in _HEADERS_ACCEPTED_BUT_NOT_PROMOTED: - headers = _HEADERS_ACCEPTED_BUT_NOT_PROMOTED[template] - if [True for header in headers if header in include_state]: - continue - if required_header_unstripped.strip('<>"') not in include_state: + if required_header_unstripped.strip('<>"') not in include_dict: error(filename, required[required_header_unstripped][0], 'build/include_what_you_use', 4, 'Add #include ' + required_header_unstripped + ' for ' + template) -def ProcessLine(filename, file_extension, - clean_lines, line, include_state, function_state, - class_state, error): +_RE_PATTERN_EXPLICIT_MAKEPAIR = re.compile(r'\bmake_pair\s*<') + + +def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): + """Check that make_pair's template arguments are deduced. + + G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are + specified explicitly, and such use isn't intended in any case. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line) + if match: + error(filename, linenum, 'build/explicit_make_pair', + 4, # 4 = high confidence + 'For C++11-compatibility, omit template arguments from make_pair' + ' OR use pair directly OR if appropriate, construct a pair directly') + + +def CheckRedundantVirtual(filename, clean_lines, linenum, error): + """Check if line contains a redundant "virtual" function-specifier. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + # Look for "virtual" on current line. + line = clean_lines.elided[linenum] + virtual = Match(r'^(.*)(\bvirtual\b)(.*)$', line) + if not virtual: return + + # Ignore "virtual" keywords that are near access-specifiers. These + # are only used in class base-specifier and do not apply to member + # functions. + if (Search(r'\b(public|protected|private)\s+$', virtual.group(1)) or + Match(r'^\s+(public|protected|private)\b', virtual.group(3))): + return + + # Ignore the "virtual" keyword from virtual base classes. Usually + # there is a column on the same line in these cases (virtual base + # classes are rare in google3 because multiple inheritance is rare). + if Match(r'^.*[^:]:[^:].*$', line): return + + # Look for the next opening parenthesis. This is the start of the + # parameter list (possibly on the next line shortly after virtual). + # TODO(unknown): doesn't work if there are virtual functions with + # decltype() or other things that use parentheses, but csearch suggests + # that this is rare. + end_col = -1 + end_line = -1 + start_col = len(virtual.group(2)) + for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())): + line = clean_lines.elided[start_line][start_col:] + parameter_list = Match(r'^([^(]*)\(', line) + if parameter_list: + # Match parentheses to find the end of the parameter list + (_, end_line, end_col) = CloseExpression( + clean_lines, start_line, start_col + len(parameter_list.group(1))) + break + start_col = 0 + + if end_col < 0: + return # Couldn't find end of parameter list, give up + + # Look for "override" or "final" after the parameter list + # (possibly on the next few lines). + for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())): + line = clean_lines.elided[i][end_col:] + match = Search(r'\b(override|final)\b', line) + if match: + error(filename, linenum, 'readability/inheritance', 4, + ('"virtual" is redundant since function is ' + 'already declared as "%s"' % match.group(1))) + + # Set end_col to check whole lines after we are done with the + # first line. + end_col = 0 + if Search(r'[^\w]\s*$', line): + break + + +def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): + """Check if line contains a redundant "override" or "final" virt-specifier. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + # Look for closing parenthesis nearby. We need one to confirm where + # the declarator ends and where the virt-specifier starts to avoid + # false positives. + line = clean_lines.elided[linenum] + declarator_end = line.rfind(')') + if declarator_end >= 0: + fragment = line[declarator_end:] + else: + if linenum > 1 and clean_lines.elided[linenum - 1].rfind(')') >= 0: + fragment = line + else: + return + + # Check that at most one of "override" or "final" is present, not both + if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): + error(filename, linenum, 'readability/inheritance', 4, + ('"override" is redundant since function is ' + 'already declared as "final"')) + + + + +# Returns true if we are at a new block, and it is directly +# inside of a namespace. +def IsBlockInNameSpace(nesting_state, is_forward_declaration): + """Checks that the new block is directly in a namespace. + + Args: + nesting_state: The _NestingState object that contains info about our state. + is_forward_declaration: If the class is a forward declared class. + Returns: + Whether or not the new block is directly in a namespace. + """ + if is_forward_declaration: + if len(nesting_state.stack) >= 1 and ( + isinstance(nesting_state.stack[-1], _NamespaceInfo)): + return True + else: + return False + + return (len(nesting_state.stack) > 1 and + nesting_state.stack[-1].check_namespace_indentation and + isinstance(nesting_state.stack[-2], _NamespaceInfo)) + + +def ShouldCheckNamespaceIndentation(nesting_state, is_namespace_indent_item, + raw_lines_no_comments, linenum): + """This method determines if we should apply our namespace indentation check. + + Args: + nesting_state: The current nesting state. + is_namespace_indent_item: If we just put a new class on the stack, True. + If the top of the stack is not a class, or we did not recently + add the class, False. + raw_lines_no_comments: The lines without the comments. + linenum: The current line number we are processing. + + Returns: + True if we should apply our namespace indentation check. Currently, it + only works for classes and namespaces inside of a namespace. + """ + + is_forward_declaration = IsForwardClassDeclaration(raw_lines_no_comments, + linenum) + + if not (is_namespace_indent_item or is_forward_declaration): + return False + + # If we are in a macro, we do not want to check the namespace indentation. + if IsMacroDefinition(raw_lines_no_comments, linenum): + return False + + return IsBlockInNameSpace(nesting_state, is_forward_declaration) + + +# Call this method if the line is directly inside of a namespace. +# If the line above is blank (excluding comments) or the start of +# an inner namespace, it cannot be indented. +def CheckItemIndentationInNamespace(filename, raw_lines_no_comments, linenum, + error): + line = raw_lines_no_comments[linenum] + if Match(r'^\s+', line): + error(filename, linenum, 'runtime/indentation_namespace', 4, + 'Do not indent within a namespace') + + +def ProcessLine(filename, file_extension, clean_lines, line, + include_state, function_state, nesting_state, error, + extra_check_functions=[]): """Processes a single line in the file. Args: @@ -2906,65 +5662,236 @@ def ProcessLine(filename, file_extension, line: Number of line being processed. include_state: An _IncludeState instance in which the headers are inserted. function_state: A _FunctionState instance which counts function lines, etc. - class_state: A _ClassState instance which maintains information about - the current stack of nested class declarations being parsed. + nesting_state: A NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message - + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ raw_lines = clean_lines.raw_lines ParseNolintSuppressions(filename, raw_lines[line], line, error) + nesting_state.Update(filename, clean_lines, line, error) + CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line, + error) + if nesting_state.InAsmBlock(): return CheckForFunctionLengths(filename, clean_lines, line, function_state, error) CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) - CheckStyle(filename, clean_lines, line, file_extension, error) + CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error) CheckLanguage(filename, clean_lines, line, file_extension, include_state, - error) + nesting_state, error) + CheckForNonConstReference(filename, clean_lines, line, nesting_state, error) CheckForNonStandardConstructs(filename, clean_lines, line, - class_state, error) + nesting_state, error) + CheckVlogArguments(filename, clean_lines, line, error) CheckPosixThreading(filename, clean_lines, line, error) CheckInvalidIncrement(filename, clean_lines, line, error) + CheckMakePairUsesDeduction(filename, clean_lines, line, error) + CheckRedundantVirtual(filename, clean_lines, line, error) + CheckRedundantOverrideOrFinal(filename, clean_lines, line, error) + for check_fn in extra_check_functions: + check_fn(filename, clean_lines, line, error) + +def FlagCxx11Features(filename, clean_lines, linenum, error): + """Flag those c++11 features that we only allow in certain places. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) + + # Flag unapproved C++ TR1 headers. + if include and include.group(1).startswith('tr1/'): + error(filename, linenum, 'build/c++tr1', 5, + ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) + + # Flag unapproved C++11 headers. + if include and include.group(1) in ('cfenv', + 'condition_variable', + 'fenv.h', + 'future', + 'mutex', + 'thread', + 'chrono', + 'ratio', + 'regex', + 'system_error', + ): + error(filename, linenum, 'build/c++11', 5, + ('<%s> is an unapproved C++11 header.') % include.group(1)) + + # The only place where we need to worry about C++11 keywords and library + # features in preprocessor directives is in macro definitions. + if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return + + # These are classes and free functions. The classes are always + # mentioned as std::*, but we only catch the free functions if + # they're not found by ADL. They're alphabetical by header. + for top_name in ( + # type_traits + 'alignment_of', + 'aligned_union', + ): + if Search(r'\bstd::%s\b' % top_name, line): + error(filename, linenum, 'build/c++11', 5, + ('std::%s is an unapproved C++11 class or function. Send c-style ' + 'an example of where it would make your code more readable, and ' + 'they may let you use it.') % top_name) + + +def FlagCxx14Features(filename, clean_lines, linenum, error): + """Flag those C++14 features that we restrict. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] + + include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) + # Flag unapproved C++14 headers. + if include and include.group(1) in ('scoped_allocator', 'shared_mutex'): + error(filename, linenum, 'build/c++14', 5, + ('<%s> is an unapproved C++14 header.') % include.group(1)) -def ProcessFileData(filename, file_extension, lines, error): + +def ProcessFileData(filename, file_extension, lines, error, + extra_check_functions=[]): """Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. lines: An array of strings, each representing a line of the file, with the - last element being empty if the file is termined with a newline. + last element being empty if the file is terminated with a newline. error: A callable to which errors are reported, which takes 4 arguments: + filename, line number, error level, and message + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ lines = (['// marker so line numbers and indices both start at 1'] + lines + ['// marker so line numbers end in a known way']) include_state = _IncludeState() function_state = _FunctionState() - class_state = _ClassState() + nesting_state = NestingState() ResetNolintSuppressions() CheckForCopyright(filename, lines, error) + ProcessGlobalSuppresions(lines) + RemoveMultiLineComments(filename, lines, error) + clean_lines = CleansedLines(lines) if file_extension == 'h': - CheckForHeaderGuard(filename, lines, error) + CheckForHeaderGuard(filename, clean_lines, error) - RemoveMultiLineComments(filename, lines, error) - clean_lines = CleansedLines(lines) for line in xrange(clean_lines.NumLines()): ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, class_state, error) - class_state.CheckFinished(filename, error) + include_state, function_state, nesting_state, error, + extra_check_functions) + FlagCxx11Features(filename, clean_lines, line, error) + nesting_state.CheckCompletedBlocks(filename, error) CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) + # Check that the .cc file has included its header if it exists. + if _IsSourceExtension(file_extension): + CheckHeaderFileIncluded(filename, include_state, error) + # We check here rather than inside ProcessLine so that we see raw # lines rather than "cleaned" lines. - CheckForUnicodeReplacementCharacters(filename, lines, error) + CheckForBadCharacters(filename, lines, error) CheckForNewlineAtEOF(filename, lines, error) -def ProcessFile(filename, vlevel): +def ProcessConfigOverrides(filename): + """ Loads the configuration files and processes the config overrides. + + Args: + filename: The name of the file being processed by the linter. + + Returns: + False if the current |filename| should not be processed further. + """ + + abs_filename = os.path.abspath(filename) + cfg_filters = [] + keep_looking = True + while keep_looking: + abs_path, base_name = os.path.split(abs_filename) + if not base_name: + break # Reached the root directory. + + cfg_file = os.path.join(abs_path, "CPPLINT.cfg") + abs_filename = abs_path + if not os.path.isfile(cfg_file): + continue + + try: + with open(cfg_file) as file_handle: + for line in file_handle: + line, _, _ = line.partition('#') # Remove comments. + if not line.strip(): + continue + + name, _, val = line.partition('=') + name = name.strip() + val = val.strip() + if name == 'set noparent': + keep_looking = False + elif name == 'filter': + cfg_filters.append(val) + elif name == 'exclude_files': + # When matching exclude_files pattern, use the base_name of + # the current file name or the directory name we are processing. + # For example, if we are checking for lint errors in /foo/bar/baz.cc + # and we found the .cfg file at /foo/CPPLINT.cfg, then the config + # file's "exclude_files" filter is meant to be checked against "bar" + # and not "baz" nor "bar/baz.cc". + if base_name: + pattern = re.compile(val) + if pattern.match(base_name): + sys.stderr.write('Ignoring "%s": file excluded by "%s". ' + 'File path component "%s" matches ' + 'pattern "%s"\n' % + (filename, cfg_file, base_name, val)) + return False + elif name == 'linelength': + global _line_length + try: + _line_length = int(val) + except ValueError: + sys.stderr.write('Line length must be numeric.') + else: + sys.stderr.write( + 'Invalid configuration option (%s) in file %s\n' % + (name, cfg_file)) + + except IOError: + sys.stderr.write( + "Skipping config file '%s': Can't open for reading\n" % cfg_file) + keep_looking = False + + # Apply all the accumulated filters in reverse order (top-level directory + # config options having the least priority). + for filter in reversed(cfg_filters): + _AddFilters(filter) + + return True + + +def ProcessFile(filename, vlevel, extra_check_functions=[]): """Does google-lint on a single file. Args: @@ -2972,10 +5899,21 @@ def ProcessFile(filename, vlevel): vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. + + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ _SetVerboseLevel(vlevel) + _BackupFilters() + + if not ProcessConfigOverrides(filename): + _RestoreFilters() + return + lf_lines = [] + crlf_lines = [] try: # Support the UNIX convention of using "-" for stdin. Note that # we are not opening the file with universal newline support @@ -2983,10 +5921,7 @@ def ProcessFile(filename, vlevel): # contain trailing '\r' characters if we are reading a file that # has CRLF endings. # If after the split a trailing '\r' is present, it is removed - # below. If it is not expected to be present (i.e. os.linesep != - # '\r\n' as in Windows), a warning is issued below if this file - # is processed. - + # below. if filename == '-': lines = codecs.StreamReaderWriter(sys.stdin, codecs.getreader('utf8'), @@ -2995,16 +5930,19 @@ def ProcessFile(filename, vlevel): else: lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') - carriage_return_found = False # Remove trailing '\r'. - for linenum in range(len(lines)): + # The -1 accounts for the extra trailing blank line we get from split() + for linenum in range(len(lines) - 1): if lines[linenum].endswith('\r'): lines[linenum] = lines[linenum].rstrip('\r') - carriage_return_found = True + crlf_lines.append(linenum + 1) + else: + lf_lines.append(linenum + 1) except IOError: sys.stderr.write( "Skipping input '%s': Can't open for reading\n" % filename) + _RestoreFilters() return # Note, if no dot is found, this will give the entire filename as the ext. @@ -3012,17 +5950,33 @@ def ProcessFile(filename, vlevel): # When reading from stdin, the extension is unknown, so no cpplint tests # should rely on the extension. - if (filename != '-' and file_extension != 'cc' and file_extension != 'h' - and file_extension != 'cpp'): - sys.stderr.write('Ignoring %s; not a .cc or .h file\n' % filename) + if filename != '-' and file_extension not in _valid_extensions: + sys.stderr.write('Ignoring %s; not a valid file name ' + '(%s)\n' % (filename, ', '.join(_valid_extensions))) else: - ProcessFileData(filename, file_extension, lines, Error) - if carriage_return_found and os.linesep != '\r\n': - # Use 0 for linenum since outputing only one error for potentially - # several lines. - Error(filename, 0, 'whitespace/newline', 1, - 'One or more unexpected \\r (^M) found;' - 'better to use only a \\n') + ProcessFileData(filename, file_extension, lines, Error, + extra_check_functions) + + # If end-of-line sequences are a mix of LF and CR-LF, issue + # warnings on the lines with CR. + # + # Don't issue any warnings if all lines are uniformly LF or CR-LF, + # since critique can handle these just fine, and the style guide + # doesn't dictate a particular end of line sequence. + # + # We can't depend on os.linesep to determine what the desired + # end-of-line sequence should be, since that will return the + # server-side end-of-line sequence. + if lf_lines and crlf_lines: + # Warn on every line with CR. An alternative approach might be to + # check whether the file is mostly CRLF or just LF, and warn on the + # minority, we bias toward LF here since most tools prefer LF. + for linenum in crlf_lines: + Error(filename, linenum, 'whitespace/newline', 1, + 'Unexpected \\r (^M) found; better to use only \\n') + + sys.stderr.write('Done processing %s\n' % filename) + _RestoreFilters() def PrintUsage(message): @@ -3062,7 +6016,9 @@ def ParseArguments(args): (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', 'counting=', 'filter=', - 'logfile=']) + 'root=', + 'linelength=', + 'extensions=']) except getopt.GetoptError: PrintUsage('Invalid arguments.') @@ -3070,14 +6026,13 @@ def ParseArguments(args): output_format = _OutputFormat() filters = '' counting_style = '' - output_filename = '' for (opt, val) in opts: if opt == '--help': PrintUsage(None) elif opt == '--output': - if not val in ('emacs', 'vs7', 'tap'): - PrintUsage('The only allowed output formats are emacs, vs7 and tap.') + if val not in ('emacs', 'vs7', 'eclipse'): + PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') output_format = val elif opt == '--verbose': verbosity = int(val) @@ -3089,8 +6044,21 @@ def ParseArguments(args): if val not in ('total', 'toplevel', 'detailed'): PrintUsage('Valid counting options are total, toplevel, and detailed') counting_style = val - elif opt == '--logfile': - output_filename = val + elif opt == '--root': + global _root + _root = val + elif opt == '--linelength': + global _line_length + try: + _line_length = int(val) + except ValueError: + PrintUsage('Line length must be digits.') + elif opt == '--extensions': + global _valid_extensions + try: + _valid_extensions = set(val.split(',')) + except ValueError: + PrintUsage('Extensions must be comma seperated list.') if not filenames: PrintUsage('No files were specified.') @@ -3099,8 +6067,6 @@ def ParseArguments(args): _SetVerboseLevel(verbosity) _SetFilters(filters) _SetCountingStyle(counting_style) - if output_filename: - _setOutputFile(output_filename) return filenames @@ -3115,14 +6081,6 @@ def main(): codecs.getwriter('utf8'), 'replace') - - ch = logging.StreamHandler(sys.stdout) - logger.addHandler(ch) - logger.setLevel(logging.INFO) - - if _cpplint_state.output_format == 'tap': - logger.info('TAP version 13') - _cpplint_state.ResetErrorCounts() for filename in filenames: ProcessFile(filename, _cpplint_state.verbose_level) From e74f199fe2ed9461be858843964338330e0c5756 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 182/261] tools: disable unwanted cpplint rules again This commit disables the build/include, build/include_alpha, build/include_order and legal/copyright warnings again. PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- tools/cpplint.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/cpplint.py b/tools/cpplint.py index 94913206f9bf2b..0b79864f1a0882 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -254,7 +254,12 @@ # flag. By default all errors are on, so only add here categories that should be # off by default (i.e., categories that must be enabled by the --filter= flags). # All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = ['-build/include_alpha'] +_DEFAULT_FILTERS = [ + '-build/include', + '-build/include_alpha', + '-build/include_order', + '-legal/copyright', + ] # The default list of categories suppressed for C (not C++) files. _DEFAULT_C_SUPPRESSED_CATEGORIES = [ From 09e98a445749f2de3b9eb53030ed62283a6d278b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 183/261] tools: add back --mode=tap to cpplint This commit reimplements commit 7b45163 ("tools: add tap output to cpplint") on top of the upgraded copy of cpplint. PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- tools/cpplint.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/cpplint.py b/tools/cpplint.py index 0b79864f1a0882..88bb8ef6a66b99 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -44,6 +44,7 @@ import codecs import copy import getopt +import logging import math # for log import os import re @@ -53,10 +54,13 @@ import unicodedata +logger = logging.getLogger('testrunner') + + _USAGE = """ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] [--counting=total|toplevel|detailed] [--root=subdir] - [--linelength=digits] + [--linelength=digits] [--logfile=filename] [file] ... The style guidelines this tries to follow are those in @@ -134,6 +138,9 @@ Examples: --extensions=hpp,cpp + logfile=filename + Write TAP output to a logfile. + cpplint.py supports per-directory configurations specified in CPPLINT.cfg files. CPPLINT.cfg file can contain a number of key=value pairs. Currently the following options are supported: @@ -1190,6 +1197,15 @@ def Error(filename, linenum, category, confidence, message): elif _cpplint_state.output_format == 'eclipse': sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) + elif _cpplint_state.output_format == 'tap': + template = ('not ok %(filename)s\n' + ' ---\n' + ' message: %(message)s\n' + ' data:\n' + ' line: %(linenum)d\n' + ' ruleId: %(category)s\n' + ' ...') + logger.info(template % locals()) else: sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) @@ -5980,7 +5996,6 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): Error(filename, linenum, 'whitespace/newline', 1, 'Unexpected \\r (^M) found; better to use only \\n') - sys.stderr.write('Done processing %s\n' % filename) _RestoreFilters() @@ -6021,6 +6036,7 @@ def ParseArguments(args): (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', 'counting=', 'filter=', + 'logfile=', 'root=', 'linelength=', 'extensions=']) @@ -6036,8 +6052,9 @@ def ParseArguments(args): if opt == '--help': PrintUsage(None) elif opt == '--output': - if val not in ('emacs', 'vs7', 'eclipse'): - PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') + if val not in ('emacs', 'vs7', 'eclipse', 'tap'): + PrintUsage( + 'The only allowed output formats are emacs, vs7, eclipse and tap.') output_format = val elif opt == '--verbose': verbosity = int(val) @@ -6064,6 +6081,8 @@ def ParseArguments(args): _valid_extensions = set(val.split(',')) except ValueError: PrintUsage('Extensions must be comma seperated list.') + elif opt == '--logfile': + logger.addHandler(logging.FileHandler(val, mode='wb')) if not filenames: PrintUsage('No files were specified.') @@ -6086,6 +6105,12 @@ def main(): codecs.getwriter('utf8'), 'replace') + logger.addHandler(logging.StreamHandler(sys.stdout)) + logger.setLevel(logging.INFO) + + if _cpplint_state.output_format == 'tap': + logger.info('TAP version 13') + _cpplint_state.ResetErrorCounts() for filename in filenames: ProcessFile(filename, _cpplint_state.verbose_level) From 4a2bd2d515af1557735eeba1fa29565d9d71cfcd Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 184/261] tools: allow cpplint to run outside git repo This reapplies commit a493dab ("cpplint: make it possible to run outside git repo") from September 2015, this time with a proper status line. PR-URL: https://github.com/nodejs/node/pull/7462 Refs: https://github.com/nodejs/node/issues/2693 Reviewed-By: Trevor Norris --- tools/cpplint.py | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/tools/cpplint.py b/tools/cpplint.py index 88bb8ef6a66b99..b5a05f0af39ba7 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -1073,40 +1073,10 @@ def RepositoryName(self): locations won't see bogus errors. """ fullname = self.FullName() - - if os.path.exists(fullname): - project_dir = os.path.dirname(fullname) - - if os.path.exists(os.path.join(project_dir, ".svn")): - # If there's a .svn file in the current directory, we recursively look - # up the directory tree for the top of the SVN checkout - root_dir = project_dir - one_up_dir = os.path.dirname(root_dir) - while os.path.exists(os.path.join(one_up_dir, ".svn")): - root_dir = os.path.dirname(root_dir) - one_up_dir = os.path.dirname(one_up_dir) - - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by - # searching up from the current path. - root_dir = current_dir = os.path.dirname(fullname) - while current_dir != os.path.dirname(current_dir): - if (os.path.exists(os.path.join(current_dir, ".git")) or - os.path.exists(os.path.join(current_dir, ".hg")) or - os.path.exists(os.path.join(current_dir, ".svn"))): - root_dir = current_dir - current_dir = os.path.dirname(current_dir) - - if (os.path.exists(os.path.join(root_dir, ".git")) or - os.path.exists(os.path.join(root_dir, ".hg")) or - os.path.exists(os.path.join(root_dir, ".svn"))): - prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] - - # Don't know what to do; header guard warnings may be wrong... - return fullname + # XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory. + toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + prefix = os.path.commonprefix([fullname, toplevel]) + return fullname[len(prefix) + 1:] def Split(self): """Splits the file into the directory, basename, and extension. From ccc701e1d5f58c144b4fcbe86ecc6f89e6193d1a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 185/261] src: fix build/c++tr1 cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/util.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util.h b/src/util.h index dce6c343b1b443..c71d115e0d0618 100644 --- a/src/util.h +++ b/src/util.h @@ -8,6 +8,12 @@ #include #include +#ifdef __APPLE__ +#include // NOLINT(build/c++tr1) +#else +#include // std::remove_reference +#endif + namespace node { #define FIXED_ONE_BYTE_STRING(isolate, string) \ From c8f78a26829c0f42c02f931d88634f3155d4cd1c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 186/261] src: fix build/header_guard cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_version.h b/src/node_version.h index 297b76c7cad748..01436c9cc55278 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -54,4 +54,4 @@ */ #define NODE_MODULE_VERSION 46 /* Node.js v4.0.0 */ -#endif /* SRC_NODE_VERSION_H_ */ +#endif // SRC_NODE_VERSION_H_ From 16f2497994d39c0913a5196f271dd622b71e709f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 187/261] src: fix readability/braces cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/cares_wrap.cc | 4 ++-- src/node_http_parser.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 41b545468f55a8..ddb215715cb2c4 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -369,11 +369,11 @@ class QueryWrap : public AsyncWrap { // Subclasses should implement the appropriate Parse method. virtual void Parse(unsigned char* buf, int len) { UNREACHABLE(); - }; + } virtual void Parse(struct hostent* host) { UNREACHABLE(); - }; + } }; diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index b094ce5f2fbac7..b12dd47706fe41 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -108,9 +108,9 @@ struct StringPtr { void Update(const char* str, size_t size) { - if (str_ == nullptr) + if (str_ == nullptr) { str_ = str; - else if (on_heap_ || str_ + size_ != str) { + } else if (on_heap_ || str_ + size_ != str) { // Non-consecutive input, make a copy on the heap. // TODO(bnoordhuis) Use slab allocation, O(n) allocs is bad. char* s = new char[size_ + size]; From c90ae7fb72f4a450cb0b6a0acc85daaa5631f37f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 188/261] src: fix readability/constructors cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_file.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index b31435ecc0a77c..59b40f94380bdb 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -251,10 +251,13 @@ static void After(uv_fs_t *req) { // This struct is only used on sync fs calls. // For async calls FSReqWrap is used. -struct fs_req_wrap { +class fs_req_wrap { + public: fs_req_wrap() {} ~fs_req_wrap() { uv_fs_req_cleanup(&req); } uv_fs_t req; + + private: DISALLOW_COPY_AND_ASSIGN(fs_req_wrap); }; From 785211702a5ab72d61cd94d4f18b2807999390bf Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 189/261] src: fix readability/inheritance cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/async-wrap.cc | 10 +++++----- src/cares_wrap.cc | 2 +- src/fs_event_wrap.cc | 2 +- src/handle_wrap.h | 2 +- src/node_stat_watcher.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 2b6839c05ee461..1a4ef67b6896d6 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -39,11 +39,11 @@ class RetainedAsyncInfo: public RetainedObjectInfo { public: explicit RetainedAsyncInfo(uint16_t class_id, AsyncWrap* wrap); - virtual void Dispose() override; - virtual bool IsEquivalent(RetainedObjectInfo* other) override; - virtual intptr_t GetHash() override; - virtual const char* GetLabel() override; - virtual intptr_t GetSizeInBytes() override; + void Dispose() override; + bool IsEquivalent(RetainedObjectInfo* other) override; + intptr_t GetHash() override; + const char* GetLabel() override; + intptr_t GetSizeInBytes() override; private: const char* label_; diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index ddb215715cb2c4..7f2a18e1d5f463 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -256,7 +256,7 @@ class QueryWrap : public AsyncWrap { req_wrap_obj->Set(env->domain_string(), env->domain_array()->Get(0)); } - virtual ~QueryWrap() override { + ~QueryWrap() override { CHECK_EQ(false, persistent().IsEmpty()); persistent().Reset(); } diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index cd6dc417ba2460..9d96cd51a24cee 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -34,7 +34,7 @@ class FSEventWrap: public HandleWrap { private: FSEventWrap(Environment* env, Local object); - virtual ~FSEventWrap() override; + ~FSEventWrap() override; static void OnEvent(uv_fs_event_t* handle, const char* filename, int events, int status); diff --git a/src/handle_wrap.h b/src/handle_wrap.h index da712b33befbcc..2ed5957c50a8c0 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -48,7 +48,7 @@ class HandleWrap : public AsyncWrap { uv_handle_t* handle, AsyncWrap::ProviderType provider, AsyncWrap* parent = nullptr); - virtual ~HandleWrap() override; + ~HandleWrap() override; private: friend class Environment; diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index bc7929880b26f7..ea96c0247f6ab0 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -11,7 +11,7 @@ namespace node { class StatWatcher : public AsyncWrap { public: - virtual ~StatWatcher() override; + ~StatWatcher() override; static void Initialize(Environment* env, v8::Local target); From 4748bed7365817bea2cc1208fe85ed6b963d1889 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 190/261] src: fix readability/namespace cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_win32_etw_provider.cc | 3 ++- src/spawn_sync.h | 3 ++- src/string_search.cc | 5 +++-- src/string_search.h | 4 ++-- test/addons/make-callback-recurse/binding.cc | 2 +- test/addons/make-callback/binding.cc | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/node_win32_etw_provider.cc b/src/node_win32_etw_provider.cc index f2650af93a51d6..7b766bd2bb99b8 100644 --- a/src/node_win32_etw_provider.cc +++ b/src/node_win32_etw_provider.cc @@ -187,4 +187,5 @@ void shutdown_etw() { advapi = nullptr; } } -} + +} // namespace node diff --git a/src/spawn_sync.h b/src/spawn_sync.h index 1f9fc68809a9dc..bdcd96fca0028d 100644 --- a/src/spawn_sync.h +++ b/src/spawn_sync.h @@ -219,6 +219,7 @@ class SyncProcessRunner { Environment* env_; }; -} + +} // namespace node #endif // SRC_SPAWN_SYNC_H_ diff --git a/src/string_search.cc b/src/string_search.cc index 530a0e54684db8..326fba7c4abf05 100644 --- a/src/string_search.cc +++ b/src/string_search.cc @@ -6,5 +6,6 @@ namespace stringsearch { int StringSearchBase::kBadCharShiftTable[kUC16AlphabetSize]; int StringSearchBase::kGoodSuffixShiftTable[kBMMaxShift + 1]; int StringSearchBase::kSuffixTable[kBMMaxShift + 1]; -} -} // namespace node::stringsearch + +} // namespace stringsearch +} // namespace node diff --git a/src/string_search.h b/src/string_search.h index 1fa6262cb7c527..26b15de0d7d60a 100644 --- a/src/string_search.h +++ b/src/string_search.h @@ -650,8 +650,8 @@ size_t SearchString(Vector subject, StringSearch search(pattern); return search.Search(subject, start_index); } -} -} // namespace node::stringsearch +} // namespace stringsearch +} // namespace node namespace node { using node::stringsearch::Vector; diff --git a/test/addons/make-callback-recurse/binding.cc b/test/addons/make-callback-recurse/binding.cc index 1c575910ef66f5..1195dbe2ff7e4c 100644 --- a/test/addons/make-callback-recurse/binding.cc +++ b/test/addons/make-callback-recurse/binding.cc @@ -26,6 +26,6 @@ void Initialize(Local target) { NODE_SET_METHOD(target, "makeCallback", MakeCallback); } -} // namespace anonymous +} // namespace NODE_MODULE(binding, Initialize) diff --git a/test/addons/make-callback/binding.cc b/test/addons/make-callback/binding.cc index 3012a39ff70a73..a1adb997bbf9b9 100644 --- a/test/addons/make-callback/binding.cc +++ b/test/addons/make-callback/binding.cc @@ -35,6 +35,6 @@ void Initialize(v8::Local target) { NODE_SET_METHOD(target, "makeCallback", MakeCallback); } -} // namespace anonymous +} // namespace NODE_MODULE(binding, Initialize) From 68db091abab240639555d452869765e4f88437ca Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 191/261] src: fix readability/nolint cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_crypto.cc | 2 +- src/spawn_sync.cc | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 96b37fd976ec97..0bf99bd265c0bb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -165,7 +165,7 @@ template void SSLWrap::WaitForCertCb(CertCb cb, void* arg); static void crypto_threadid_cb(CRYPTO_THREADID* tid) { - static_assert(sizeof(uv_thread_t) <= sizeof(void*), // NOLINT(runtime/sizeof) + static_assert(sizeof(uv_thread_t) <= sizeof(void*), "uv_thread_t does not fit in a pointer"); CRYPTO_THREADID_set_pointer(tid, reinterpret_cast(uv_thread_self())); } diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 4ff70b48ca9618..79f10a0ea2594d 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -973,7 +973,7 @@ int SyncProcessRunner::CopyJsStringArray(Local js_value, data_size = 0; for (uint32_t i = 0; i < length; i++) { data_size += StringBytes::StorageSize(isolate, js_array->Get(i), UTF8) + 1; - data_size = ROUND_UP(data_size, sizeof(void*)); // NOLINT(runtime/sizeof) + data_size = ROUND_UP(data_size, sizeof(void*)); } buffer = new char[list_size + data_size]; @@ -989,8 +989,7 @@ int SyncProcessRunner::CopyJsStringArray(Local js_value, js_array->Get(i), UTF8); buffer[data_offset++] = '\0'; - data_offset = ROUND_UP(data_offset, - sizeof(void*)); // NOLINT(runtime/sizeof) + data_offset = ROUND_UP(data_offset, sizeof(void*)); } list[length] = nullptr; From d6595adcdb81d871db3db5c723a26bad1aca25fc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 192/261] src: fix runtime/indentation_namespace warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/tls_wrap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 8346613b199253..ba5eecbf0030e5 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -18,7 +18,7 @@ namespace node { class NodeBIO; class WriteWrap; namespace crypto { - class SecureContext; +class SecureContext; } class TLSWrap : public AsyncWrap, From f530a36c65ed462aae5da71d8cdb189da1266e93 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 193/261] src: fix runtime/int cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_crypto.cc | 39 +++++++++++++++++++++------------------ src/node_crypto_bio.cc | 5 +++-- src/node_crypto_bio.h | 3 ++- src/tls_wrap.cc | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 0bf99bd265c0bb..9f1d034645ca34 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -208,7 +208,7 @@ static int CryptoPemCallback(char *buf, int size, int rwflag, void *u) { void ThrowCryptoError(Environment* env, - unsigned long err, + unsigned long err, // NOLINT(runtime/int) const char* default_message = nullptr) { HandleScope scope(env->isolate()); if (err != 0 || default_message == nullptr) { @@ -467,7 +467,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { if (!key) { BIO_free_all(bio); - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) if (!err) { return env->ThrowError("PEM_read_bio_PrivateKey"); } @@ -479,7 +479,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo& args) { BIO_free_all(bio); if (!rv) { - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) if (!err) return env->ThrowError("SSL_CTX_use_PrivateKey"); return ThrowCryptoError(env, err); @@ -597,7 +597,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX* ctx, X509* extra = nullptr; int ret = 0; - unsigned long err = 0; + unsigned long err = 0; // NOLINT(runtime/int) // Read extra certs STACK_OF(X509)* extra_certs = sk_X509_new_null(); @@ -672,7 +672,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo& args) { BIO_free_all(bio); if (!rv) { - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) if (!err) { return env->ThrowError("SSL_CTX_use_certificate_chain"); } @@ -866,7 +866,9 @@ void SecureContext::SetOptions(const FunctionCallbackInfo& args) { return sc->env()->ThrowTypeError("Bad parameter"); } - SSL_CTX_set_options(sc->ctx_, static_cast(args[0]->IntegerValue())); + SSL_CTX_set_options( + sc->ctx_, + static_cast(args[0]->IntegerValue())); // NOLINT(runtime/int) } @@ -1001,7 +1003,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { delete[] pass; if (!ret) { - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) const char* str = ERR_reason_error_string(err); return env->ThrowError(str); } @@ -1427,7 +1429,7 @@ static Local X509ToObject(Environment* env, X509* cert) { String::kNormalString, mem->length)); (void) BIO_reset(bio); - unsigned long exponent_word = BN_get_word(rsa->e); + BN_ULONG exponent_word = BN_get_word(rsa->e); BIO_printf(bio, "0x%lx", exponent_word); BIO_get_mem_ptr(bio, &mem); @@ -1834,7 +1836,8 @@ void SSLWrap::VerifyError(const FunctionCallbackInfo& args) { // XXX(bnoordhuis) The UNABLE_TO_GET_ISSUER_CERT error when there is no // peer certificate is questionable but it's compatible with what was // here before. - long x509_verify_error = X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT; + long x509_verify_error = // NOLINT(runtime/int) + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT; if (X509* peer_cert = SSL_get_peer_certificate(w->ssl_)) { X509_free(peer_cert); x509_verify_error = SSL_get_verify_result(w->ssl_); @@ -2171,7 +2174,7 @@ void SSLWrap::CertCbDone(const FunctionCallbackInfo& args) { if (rv) rv = w->SetCACerts(sc); if (!rv) { - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) if (!err) return env->ThrowError("CertCbDone"); return ThrowCryptoError(env, err); @@ -2605,7 +2608,7 @@ void Connection::New(const FunctionCallbackInfo& args) { SSL_set_bio(conn->ssl_, conn->bio_read_, conn->bio_write_); #ifdef SSL_MODE_RELEASE_BUFFERS - long mode = SSL_get_mode(conn->ssl_); + long mode = SSL_get_mode(conn->ssl_); // NOLINT(runtime/int) SSL_set_mode(conn->ssl_, mode | SSL_MODE_RELEASE_BUFFERS); #endif @@ -3551,7 +3554,7 @@ void SignBase::CheckThrow(SignBase::Error error) { case kSignPrivateKey: case kSignPublicKey: { - unsigned long err = ERR_get_error(); + unsigned long err = ERR_get_error(); // NOLINT(runtime/int) if (err) return ThrowCryptoError(env(), err); switch (error) { @@ -5049,11 +5052,11 @@ class RandomBytesRequest : public AsyncWrap { size_ = 0; } - inline unsigned long error() const { + inline unsigned long error() const { // NOLINT(runtime/int) return error_; } - inline void set_error(unsigned long err) { + inline void set_error(unsigned long err) { // NOLINT(runtime/int) error_ = err; } @@ -5062,7 +5065,7 @@ class RandomBytesRequest : public AsyncWrap { uv_work_t work_req_; private: - unsigned long error_; + unsigned long error_; // NOLINT(runtime/int) size_t size_; char* data_; }; @@ -5080,9 +5083,9 @@ void RandomBytesWork(uv_work_t* work_req) { // RAND_bytes() returns 0 on error. if (r == 0) { - req->set_error(ERR_get_error()); + req->set_error(ERR_get_error()); // NOLINT(runtime/int) } else if (r == -1) { - req->set_error(static_cast(-1)); + req->set_error(static_cast(-1)); // NOLINT(runtime/int) } } @@ -5092,7 +5095,7 @@ void RandomBytesCheck(RandomBytesRequest* req, Local argv[2]) { if (req->error()) { char errmsg[256] = "Operation not supported"; - if (req->error() != static_cast(-1)) + if (req->error() != static_cast(-1)) // NOLINT(runtime/int) ERR_error_string_n(req->error(), errmsg, sizeof errmsg); argv[0] = Exception::Error(OneByteString(req->env()->isolate(), errmsg)); diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc index d155eaf79a6f9c..ec4aa69b073cec 100644 --- a/src/node_crypto_bio.cc +++ b/src/node_crypto_bio.cc @@ -164,9 +164,10 @@ int NodeBIO::Gets(BIO* bio, char* out, int size) { } -long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) { +long NodeBIO::Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int) + void* ptr) { NodeBIO* nbio; - long ret; + long ret; // NOLINT(runtime/int) nbio = FromBIO(bio); ret = 1; diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h index eb247b7f51ace7..4d2cf54ac1368c 100644 --- a/src/node_crypto_bio.h +++ b/src/node_crypto_bio.h @@ -89,7 +89,8 @@ class NodeBIO { static int Write(BIO* bio, const char* data, int len); static int Puts(BIO* bio, const char* str); static int Gets(BIO* bio, char* out, int size); - static long Ctrl(BIO* bio, int cmd, long num, void* ptr); + static long Ctrl(BIO* bio, int cmd, long num, // NOLINT(runtime/int) + void* ptr); // Enough to handle the most of the client hellos static const size_t kInitialBufferLength = 1024; diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 48ec8a54a98c79..bfc8107331e9c9 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -126,7 +126,7 @@ void TLSWrap::InitSSL() { SSL_set_verify(ssl_, SSL_VERIFY_NONE, crypto::VerifyCallback); #ifdef SSL_MODE_RELEASE_BUFFERS - long mode = SSL_get_mode(ssl_); + long mode = SSL_get_mode(ssl_); // NOLINT(runtime/int) SSL_set_mode(ssl_, mode | SSL_MODE_RELEASE_BUFFERS); #endif // SSL_MODE_RELEASE_BUFFERS From 44cbe0356da7ba2f0d1213eac8723717d4b6f4e0 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 194/261] src: fix runtime/references cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_contextify.cc | 14 +++++------ tools/icu/iculslocs.cc | 53 +++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 7b4d472d94e0cb..7404bbba87ec45 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -516,7 +516,7 @@ class ContextifyScript : public BaseObject { // Do the eval within this context Environment* env = Environment::GetCurrent(args); - EvalMachine(env, timeout, display_errors, args, try_catch); + EvalMachine(env, timeout, display_errors, args, &try_catch); } // args: sandbox, [options] @@ -563,7 +563,7 @@ class ContextifyScript : public BaseObject { timeout, display_errors, args, - try_catch)) { + &try_catch)) { contextify_context->CopyProperties(); } @@ -683,7 +683,7 @@ class ContextifyScript : public BaseObject { const int64_t timeout, const bool display_errors, const FunctionCallbackInfo& args, - TryCatch& try_catch) { + TryCatch* try_catch) { if (!ContextifyScript::InstanceOf(env, args.Holder())) { env->ThrowTypeError( "Script methods can only be called on script instances."); @@ -703,19 +703,19 @@ class ContextifyScript : public BaseObject { result = script->Run(); } - if (try_catch.HasCaught() && try_catch.HasTerminated()) { + if (try_catch->HasCaught() && try_catch->HasTerminated()) { V8::CancelTerminateExecution(env->isolate()); env->ThrowError("Script execution timed out."); - try_catch.ReThrow(); + try_catch->ReThrow(); return false; } if (result.IsEmpty()) { // Error occurred during execution of the script. if (display_errors) { - AppendExceptionLine(env, try_catch.Exception(), try_catch.Message()); + AppendExceptionLine(env, try_catch->Exception(), try_catch->Message()); } - try_catch.ReThrow(); + try_catch->ReThrow(); return false; } diff --git a/tools/icu/iculslocs.cc b/tools/icu/iculslocs.cc index 66becace0a4a27..d71f9b8e5d702c 100644 --- a/tools/icu/iculslocs.cc +++ b/tools/icu/iculslocs.cc @@ -105,13 +105,13 @@ void usage() { PROG); } -#define ASSERT_SUCCESS(what) \ - if (U_FAILURE(status)) { \ +#define ASSERT_SUCCESS(status, what) \ + if (U_FAILURE(*status)) { \ u_printf("%s:%d: %s: ERROR: %s %s\n", \ __FILE__, \ __LINE__, \ PROG, \ - u_errorName(status), \ + u_errorName(*status), \ what); \ return 1; \ } @@ -177,9 +177,9 @@ int localeExists(const char* loc, UBool* exists) { } } -void printIndent(const LocalUFILEPointer& bf, int indent) { +void printIndent(const LocalUFILEPointer* bf, int indent) { for (int i = 0; i < indent + 1; i++) { - u_fprintf(bf.getAlias(), " "); + u_fprintf(bf->getAlias(), " "); } } @@ -189,15 +189,15 @@ void printIndent(const LocalUFILEPointer& bf, int indent) { * @return 0 for OK, 1 for err */ int dumpAllButInstalledLocales(int lev, - LocalUResourceBundlePointer& bund, - LocalUFILEPointer& bf, - UErrorCode& status) { - ures_resetIterator(bund.getAlias()); - const UBool isTable = (UBool)(ures_getType(bund.getAlias()) == URES_TABLE); + LocalUResourceBundlePointer* bund, + LocalUFILEPointer* bf, + UErrorCode* status) { + ures_resetIterator(bund->getAlias()); + const UBool isTable = (UBool)(ures_getType(bund->getAlias()) == URES_TABLE); LocalUResourceBundlePointer t; - while (U_SUCCESS(status) && ures_hasNext(bund.getAlias())) { - t.adoptInstead(ures_getNextResource(bund.getAlias(), t.orphan(), &status)); - ASSERT_SUCCESS("while processing table"); + while (U_SUCCESS(*status) && ures_hasNext(bund->getAlias())) { + t.adoptInstead(ures_getNextResource(bund->getAlias(), t.orphan(), status)); + ASSERT_SUCCESS(status, "while processing table"); const char* key = ures_getKey(t.getAlias()); if (VERBOSE > 1) { u_printf("dump@%d: got key %s\n", lev, key); @@ -208,22 +208,22 @@ int dumpAllButInstalledLocales(int lev, } } else { printIndent(bf, lev); - u_fprintf(bf.getAlias(), "%s", key); + u_fprintf(bf->getAlias(), "%s", key); switch (ures_getType(t.getAlias())) { case URES_STRING: { int32_t len = 0; - const UChar* s = ures_getString(t.getAlias(), &len, &status); - ASSERT_SUCCESS("getting string"); - u_fprintf(bf.getAlias(), ":string {\""); - u_file_write(s, len, bf.getAlias()); - u_fprintf(bf.getAlias(), "\"}"); + const UChar* s = ures_getString(t.getAlias(), &len, status); + ASSERT_SUCCESS(status, "getting string"); + u_fprintf(bf->getAlias(), ":string {\""); + u_file_write(s, len, bf->getAlias()); + u_fprintf(bf->getAlias(), "\"}"); } break; default: { u_printf("ERROR: unhandled type in dumpAllButInstalledLocales().\n"); return 1; } break; } - u_fprintf(bf.getAlias(), "\n"); + u_fprintf(bf->getAlias(), "\n"); } } return 0; @@ -250,7 +250,7 @@ int list(const char* toBundle) { // first, calculate the bundle name. calculatePackageName(&status); - ASSERT_SUCCESS("calculating package name"); + ASSERT_SUCCESS(&status, "calculating package name"); if (VERBOSE) { u_printf("\"locale\": %s\n", locale); @@ -258,10 +258,10 @@ int list(const char* toBundle) { LocalUResourceBundlePointer bund( ures_openDirect(packageName.data(), locale, &status)); - ASSERT_SUCCESS("while opening the bundle"); + ASSERT_SUCCESS(&status, "while opening the bundle"); LocalUResourceBundlePointer installedLocales( ures_getByKey(bund.getAlias(), INSTALLEDLOCALES, NULL, &status)); - ASSERT_SUCCESS("while fetching installed locales"); + ASSERT_SUCCESS(&status, "while fetching installed locales"); int32_t count = ures_getSize(installedLocales.getAlias()); if (VERBOSE) { @@ -280,11 +280,12 @@ int list(const char* toBundle) { "%s:table(nofallback) {\n" " // First, everything besides InstalledLocales:\n", locale); - if (dumpAllButInstalledLocales(0, bund, bf, status)) { + if (dumpAllButInstalledLocales(0, &bund, &bf, &status)) { u_printf("Error dumping prolog for %s\n", toBundle); return 1; } - ASSERT_SUCCESS("while writing prolog"); // in case an error was missed + // in case an error was missed + ASSERT_SUCCESS(&status, "while writing prolog"); u_fprintf(bf.getAlias(), " %s:table { // %d locales in input %s.res\n", @@ -300,7 +301,7 @@ int list(const char* toBundle) { for (int32_t i = 0; i < count; i++) { subkey.adoptInstead(ures_getByIndex( installedLocales.getAlias(), i, subkey.orphan(), &status)); - ASSERT_SUCCESS("while fetching an installed locale's name"); + ASSERT_SUCCESS(&status, "while fetching an installed locale's name"); const char* key = ures_getKey(subkey.getAlias()); if (VERBOSE > 1) { From 066064d65f11d8ced295f8c2f90daf692189445a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 195/261] src: fix whitespace/blank_line cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_crypto.h | 1 - src/node_zlib.cc | 1 - src/util.h | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_crypto.h b/src/node_crypto.h index d9105fd11a5721..4921ed36e30d11 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -565,7 +565,6 @@ class SignBase : public BaseObject { class Sign : public SignBase { public: - static void Initialize(Environment* env, v8::Local target); Error SignInit(const char* sign_type); diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 15f58843983c8f..3bdeee4e63923e 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -50,7 +50,6 @@ void InitZlib(v8::Local target); */ class ZCtx : public AsyncWrap { public: - ZCtx(Environment* env, Local wrap, node_zlib_mode mode) : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_ZLIB), chunk_size_(0), diff --git a/src/util.h b/src/util.h index c71d115e0d0618..8254bbe9713871 100644 --- a/src/util.h +++ b/src/util.h @@ -267,6 +267,7 @@ class MaybeStackBuffer { if (buf_ != buf_st_) free(buf_); } + private: size_t length_; T* buf_; From 4f4d3e77efc3c29673d4f0911e0de603c7b19ee5 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 196/261] src: fix whitespace/indent cpplint warnings PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/node_internals.h | 144 +++++++++++++++++++------------------- src/string_bytes.cc | 108 ++++++++++++++--------------- src/util.h | 162 +++++++++++++++++++++---------------------- 3 files changed, 207 insertions(+), 207 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index 5c94168c916816..ae1256756c31db 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -247,78 +247,78 @@ void ClearFatalExceptionHandlers(Environment* env); enum NodeInstanceType { MAIN, WORKER }; class NodeInstanceData { - public: - NodeInstanceData(NodeInstanceType node_instance_type, - uv_loop_t* event_loop, - int argc, - const char** argv, - int exec_argc, - const char** exec_argv, - bool use_debug_agent_flag) - : node_instance_type_(node_instance_type), - exit_code_(1), - event_loop_(event_loop), - argc_(argc), - argv_(argv), - exec_argc_(exec_argc), - exec_argv_(exec_argv), - use_debug_agent_flag_(use_debug_agent_flag) { - CHECK_NE(event_loop_, nullptr); - } - - uv_loop_t* event_loop() const { - return event_loop_; - } - - int exit_code() { - CHECK(is_main()); - return exit_code_; - } - - void set_exit_code(int exit_code) { - CHECK(is_main()); - exit_code_ = exit_code; - } - - bool is_main() { - return node_instance_type_ == MAIN; - } - - bool is_worker() { - return node_instance_type_ == WORKER; - } - - int argc() { - return argc_; - } - - const char** argv() { - return argv_; - } - - int exec_argc() { - return exec_argc_; - } - - const char** exec_argv() { - return exec_argv_; - } - - bool use_debug_agent() { - return is_main() && use_debug_agent_flag_; - } - - private: - const NodeInstanceType node_instance_type_; - int exit_code_; - uv_loop_t* const event_loop_; - const int argc_; - const char** argv_; - const int exec_argc_; - const char** exec_argv_; - const bool use_debug_agent_flag_; - - DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); + public: + NodeInstanceData(NodeInstanceType node_instance_type, + uv_loop_t* event_loop, + int argc, + const char** argv, + int exec_argc, + const char** exec_argv, + bool use_debug_agent_flag) + : node_instance_type_(node_instance_type), + exit_code_(1), + event_loop_(event_loop), + argc_(argc), + argv_(argv), + exec_argc_(exec_argc), + exec_argv_(exec_argv), + use_debug_agent_flag_(use_debug_agent_flag) { + CHECK_NE(event_loop_, nullptr); + } + + uv_loop_t* event_loop() const { + return event_loop_; + } + + int exit_code() { + CHECK(is_main()); + return exit_code_; + } + + void set_exit_code(int exit_code) { + CHECK(is_main()); + exit_code_ = exit_code; + } + + bool is_main() { + return node_instance_type_ == MAIN; + } + + bool is_worker() { + return node_instance_type_ == WORKER; + } + + int argc() { + return argc_; + } + + const char** argv() { + return argv_; + } + + int exec_argc() { + return exec_argc_; + } + + const char** exec_argv() { + return exec_argv_; + } + + bool use_debug_agent() { + return is_main() && use_debug_agent_flag_; + } + + private: + const NodeInstanceType node_instance_type_; + int exit_code_; + uv_loop_t* const event_loop_; + const int argc_; + const char** argv_; + const int exec_argc_; + const char** exec_argv_; + const bool use_debug_agent_flag_; + + DISALLOW_COPY_AND_ASSIGN(NodeInstanceData); }; namespace Buffer { diff --git a/src/string_bytes.cc b/src/string_bytes.cc index a916caf75e8960..d1c6a573250b7e 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -27,75 +27,75 @@ using v8::MaybeLocal; template class ExternString: public ResourceType { - public: - ~ExternString() override { - free(const_cast(data_)); - isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); - } - - const TypeName* data() const override { - return data_; - } + public: + ~ExternString() override { + free(const_cast(data_)); + isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length()); + } - size_t length() const override { - return length_; - } + const TypeName* data() const override { + return data_; + } - int64_t byte_length() const { - return length() * sizeof(*data()); - } + size_t length() const override { + return length_; + } - static Local NewFromCopy(Isolate* isolate, - const TypeName* data, - size_t length) { - EscapableHandleScope scope(isolate); + int64_t byte_length() const { + return length() * sizeof(*data()); + } - if (length == 0) - return scope.Escape(String::Empty(isolate)); + static Local NewFromCopy(Isolate* isolate, + const TypeName* data, + size_t length) { + EscapableHandleScope scope(isolate); - TypeName* new_data = - static_cast(malloc(length * sizeof(*new_data))); - if (new_data == nullptr) { - return Local(); - } - memcpy(new_data, data, length * sizeof(*new_data)); + if (length == 0) + return scope.Escape(String::Empty(isolate)); - return scope.Escape(ExternString::New(isolate, - new_data, - length)); + TypeName* new_data = + static_cast(malloc(length * sizeof(*new_data))); + if (new_data == nullptr) { + return Local(); } + memcpy(new_data, data, length * sizeof(*new_data)); - // uses "data" for external resource, and will be free'd on gc - static Local New(Isolate* isolate, - const TypeName* data, - size_t length) { - EscapableHandleScope scope(isolate); + return scope.Escape(ExternString::New(isolate, + new_data, + length)); + } - if (length == 0) - return scope.Escape(String::Empty(isolate)); + // uses "data" for external resource, and will be free'd on gc + static Local New(Isolate* isolate, + const TypeName* data, + size_t length) { + EscapableHandleScope scope(isolate); + if (length == 0) + return scope.Escape(String::Empty(isolate)); - ExternString* h_str = new ExternString(isolate, - data, - length); - MaybeLocal str = String::NewExternal(isolate, h_str); - isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); + ExternString* h_str = new ExternString(isolate, + data, + length); + MaybeLocal str = String::NewExternal(isolate, h_str); + isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length()); - if (str.IsEmpty()) { - delete h_str; - return Local(); - } - return scope.Escape(str.ToLocalChecked()); + if (str.IsEmpty()) { + delete h_str; + return Local(); } - inline Isolate* isolate() const { return isolate_; } + return scope.Escape(str.ToLocalChecked()); + } + + inline Isolate* isolate() const { return isolate_; } - private: - ExternString(Isolate* isolate, const TypeName* data, size_t length) - : isolate_(isolate), data_(data), length_(length) { } - Isolate* isolate_; - const TypeName* data_; - size_t length_; + private: + ExternString(Isolate* isolate, const TypeName* data, size_t length) + : isolate_(isolate), data_(data), length_(length) { } + Isolate* isolate_; + const TypeName* data_; + size_t length_; }; diff --git a/src/util.h b/src/util.h index 8254bbe9713871..8c2b0a1be4c47a 100644 --- a/src/util.h +++ b/src/util.h @@ -194,99 +194,99 @@ inline bool StringEqualNoCase(const char* a, const char* b); // the stack is used, otherwise malloc(). template class MaybeStackBuffer { - public: - const T* out() const { - return buf_; - } - - T* out() { - return buf_; - } - - // operator* for compatibility with `v8::String::(Utf8)Value` - T* operator*() { - return buf_; - } - - const T* operator*() const { - return buf_; - } - - size_t length() const { - return length_; - } - - // Call to make sure enough space for `storage` entries is available. - // There can only be 1 call to AllocateSufficientStorage or Invalidate - // per instance. - void AllocateSufficientStorage(size_t storage) { - if (storage <= kStackStorageSize) { - buf_ = buf_st_; - } else { - // Guard against overflow. - CHECK_LE(storage, sizeof(T) * storage); - - buf_ = static_cast(malloc(sizeof(T) * storage)); - CHECK_NE(buf_, nullptr); - } - - // Remember how much was allocated to check against that in SetLength(). - length_ = storage; - } - - void SetLength(size_t length) { - // length_ stores how much memory was allocated. - CHECK_LE(length, length_); - length_ = length; - } - - void SetLengthAndZeroTerminate(size_t length) { - // length_ stores how much memory was allocated. - CHECK_LE(length + 1, length_); - SetLength(length); - - // T() is 0 for integer types, nullptr for pointers, etc. - buf_[length] = T(); - } - - // Make derefencing this object return nullptr. - // Calling this is mutually exclusive with calling - // AllocateSufficientStorage. - void Invalidate() { - CHECK_EQ(buf_, buf_st_); - length_ = 0; - buf_ = nullptr; - } - - MaybeStackBuffer() : length_(0), buf_(buf_st_) { - // Default to a zero-length, null-terminated buffer. - buf_[0] = T(); + public: + const T* out() const { + return buf_; + } + + T* out() { + return buf_; + } + + // operator* for compatibility with `v8::String::(Utf8)Value` + T* operator*() { + return buf_; + } + + const T* operator*() const { + return buf_; + } + + size_t length() const { + return length_; + } + + // Call to make sure enough space for `storage` entries is available. + // There can only be 1 call to AllocateSufficientStorage or Invalidate + // per instance. + void AllocateSufficientStorage(size_t storage) { + if (storage <= kStackStorageSize) { + buf_ = buf_st_; + } else { + // Guard against overflow. + CHECK_LE(storage, sizeof(T) * storage); + + buf_ = static_cast(malloc(sizeof(T) * storage)); + CHECK_NE(buf_, nullptr); } - ~MaybeStackBuffer() { - if (buf_ != buf_st_) - free(buf_); - } + // Remember how much was allocated to check against that in SetLength(). + length_ = storage; + } + + void SetLength(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length, length_); + length_ = length; + } + + void SetLengthAndZeroTerminate(size_t length) { + // length_ stores how much memory was allocated. + CHECK_LE(length + 1, length_); + SetLength(length); + + // T() is 0 for integer types, nullptr for pointers, etc. + buf_[length] = T(); + } + + // Make derefencing this object return nullptr. + // Calling this is mutually exclusive with calling + // AllocateSufficientStorage. + void Invalidate() { + CHECK_EQ(buf_, buf_st_); + length_ = 0; + buf_ = nullptr; + } + + MaybeStackBuffer() : length_(0), buf_(buf_st_) { + // Default to a zero-length, null-terminated buffer. + buf_[0] = T(); + } + + ~MaybeStackBuffer() { + if (buf_ != buf_st_) + free(buf_); + } - private: - size_t length_; - T* buf_; - T buf_st_[kStackStorageSize]; + private: + size_t length_; + T* buf_; + T buf_st_[kStackStorageSize]; }; class Utf8Value : public MaybeStackBuffer { - public: - explicit Utf8Value(v8::Isolate* isolate, v8::Local value); + public: + explicit Utf8Value(v8::Isolate* isolate, v8::Local value); }; class TwoByteValue : public MaybeStackBuffer { - public: - explicit TwoByteValue(v8::Isolate* isolate, v8::Local value); + public: + explicit TwoByteValue(v8::Isolate* isolate, v8::Local value); }; class BufferValue : public MaybeStackBuffer { - public: - explicit BufferValue(v8::Isolate* isolate, v8::Local value); + public: + explicit BufferValue(v8::Isolate* isolate, v8::Local value); }; } // namespace node From 0db3aa9afa9f6c9fa6a03e05e2d87573b9639310 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 197/261] build: remove unused files from CPPLINT_FILES PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index f316b21ec18b8b..5471e57528d69c 100644 --- a/Makefile +++ b/Makefile @@ -645,8 +645,6 @@ CPPLINT_EXCLUDE += src/v8abbr.h CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h) CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ - deps/debugger-agent/include/* \ - deps/debugger-agent/src/* \ src/*.c \ src/*.cc \ src/*.h \ From 27c2d25be607ea120e3f69c02ec6cb12f5b5e9a4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 198/261] src: lint node_win32_perfctr_provider.cc PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- Makefile | 1 - src/node_win32_perfctr_provider.cc | 30 ++++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 5471e57528d69c..f2186ce77d36b7 100644 --- a/Makefile +++ b/Makefile @@ -638,7 +638,6 @@ CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE += src/node_lttng.cc CPPLINT_EXCLUDE += src/node_root_certs.h CPPLINT_EXCLUDE += src/node_lttng_tp.h -CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc CPPLINT_EXCLUDE += src/queue.h CPPLINT_EXCLUDE += src/tree.h CPPLINT_EXCLUDE += src/v8abbr.h diff --git a/src/node_win32_perfctr_provider.cc b/src/node_win32_perfctr_provider.cc index 00491caf50675f..ebb299e4c54758 100644 --- a/src/node_win32_perfctr_provider.cc +++ b/src/node_win32_perfctr_provider.cc @@ -193,7 +193,8 @@ void TermPerfCountersWin32() { void NODE_COUNT_HTTP_SERVER_REQUEST() { - if (NodeCounterProvider != nullptr && perfctr_incrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongValue != nullptr) { perfctr_incrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_HTTP_SERVER_REQUEST, @@ -203,7 +204,8 @@ void NODE_COUNT_HTTP_SERVER_REQUEST() { void NODE_COUNT_HTTP_SERVER_RESPONSE() { - if (NodeCounterProvider != nullptr && perfctr_incrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongValue != nullptr) { perfctr_incrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_HTTP_SERVER_RESPONSE, @@ -213,7 +215,8 @@ void NODE_COUNT_HTTP_SERVER_RESPONSE() { void NODE_COUNT_HTTP_CLIENT_REQUEST() { - if (NodeCounterProvider != nullptr && perfctr_incrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongValue != nullptr) { perfctr_incrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_HTTP_CLIENT_REQUEST, @@ -223,7 +226,8 @@ void NODE_COUNT_HTTP_CLIENT_REQUEST() { void NODE_COUNT_HTTP_CLIENT_RESPONSE() { - if (NodeCounterProvider != nullptr && perfctr_incrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongValue != nullptr) { perfctr_incrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_HTTP_CLIENT_RESPONSE, @@ -233,7 +237,8 @@ void NODE_COUNT_HTTP_CLIENT_RESPONSE() { void NODE_COUNT_SERVER_CONN_OPEN() { - if (NodeCounterProvider != nullptr && perfctr_incrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongValue != nullptr) { perfctr_incrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_SERVER_CONNS, @@ -243,7 +248,8 @@ void NODE_COUNT_SERVER_CONN_OPEN() { void NODE_COUNT_SERVER_CONN_CLOSE() { - if (NodeCounterProvider != nullptr && perfctr_decrementULongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_decrementULongValue != nullptr) { perfctr_decrementULongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_SERVER_CONNS, @@ -253,7 +259,8 @@ void NODE_COUNT_SERVER_CONN_CLOSE() { void NODE_COUNT_NET_BYTES_SENT(int bytes) { - if (NodeCounterProvider != nullptr && perfctr_incrementULongLongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongLongValue != nullptr) { perfctr_incrementULongLongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_NET_BYTES_SENT, @@ -263,7 +270,8 @@ void NODE_COUNT_NET_BYTES_SENT(int bytes) { void NODE_COUNT_NET_BYTES_RECV(int bytes) { - if (NodeCounterProvider != nullptr && perfctr_incrementULongLongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongLongValue != nullptr) { perfctr_incrementULongLongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_NET_BYTES_RECV, @@ -293,7 +301,8 @@ void NODE_COUNT_GC_PERCENTTIME(unsigned int percent) { void NODE_COUNT_PIPE_BYTES_SENT(int bytes) { - if (NodeCounterProvider != nullptr && perfctr_incrementULongLongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongLongValue != nullptr) { perfctr_incrementULongLongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_PIPE_BYTES_SENT, @@ -303,7 +312,8 @@ void NODE_COUNT_PIPE_BYTES_SENT(int bytes) { void NODE_COUNT_PIPE_BYTES_RECV(int bytes) { - if (NodeCounterProvider != nullptr && perfctr_incrementULongLongValue != nullptr) { + if (NodeCounterProvider != nullptr && + perfctr_incrementULongLongValue != nullptr) { perfctr_incrementULongLongValue(NodeCounterProvider, perfctr_instance, NODE_COUNTER_PIPE_BYTES_RECV, From 42e7c9d266571c0992cdc72667b12d0aa452e86a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 199/261] src: lint node_lttng_tp.h PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- Makefile | 2 -- src/node_lttng_tp.h | 64 ++++++++++++++++++--------------------------- 2 files changed, 25 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index f2186ce77d36b7..2a671b43b0af54 100644 --- a/Makefile +++ b/Makefile @@ -635,9 +635,7 @@ jslint: tools/eslint-rules --rulesdir tools/eslint-rules CPPLINT_EXCLUDE ?= -CPPLINT_EXCLUDE += src/node_lttng.cc CPPLINT_EXCLUDE += src/node_root_certs.h -CPPLINT_EXCLUDE += src/node_lttng_tp.h CPPLINT_EXCLUDE += src/queue.h CPPLINT_EXCLUDE += src/tree.h CPPLINT_EXCLUDE += src/v8abbr.h diff --git a/src/node_lttng_tp.h b/src/node_lttng_tp.h index 53d04f47a80e5a..b529bfad5e4b58 100644 --- a/src/node_lttng_tp.h +++ b/src/node_lttng_tp.h @@ -1,3 +1,8 @@ +#ifndef SRC_NODE_LTTNG_TP_H_ +#define SRC_NODE_LTTNG_TP_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + #undef TRACEPOINT_PROVIDER #define TRACEPOINT_PROVIDER node @@ -15,14 +20,11 @@ TRACEPOINT_EVENT( TP_ARGS( const char*, url, const char*, method, - const char*, forwardedFor - ), + const char*, forwardedFor), TP_FIELDS( ctf_string(url, url) ctf_string(method, method) - ctf_string(forwardedFor, forwardedFor) - ) -) + ctf_string(forwardedFor, forwardedFor)) TRACEPOINT_EVENT( node, @@ -30,27 +32,21 @@ TRACEPOINT_EVENT( TP_ARGS( int, port, const char*, remote, - int, fd - ), + int, fd), TP_FIELDS( ctf_integer(int, port, port) ctf_string(remote, remote) - ctf_integer(int, fd, fd) - ) -) + ctf_integer(int, fd, fd)) TRACEPOINT_EVENT( node, http_client_request, TP_ARGS( const char*, url, - const char*, method - ), + const char*, method), TP_FIELDS( ctf_string(url, url) - ctf_string(method, method) - ) -) + ctf_string(method, method)) TRACEPOINT_EVENT( node, @@ -58,14 +54,11 @@ TRACEPOINT_EVENT( TP_ARGS( int, port, const char*, remote, - int, fd - ), + int, fd), TP_FIELDS( ctf_integer(int, port, port) ctf_string(remote, remote) - ctf_integer(int, fd, fd) - ) -) + ctf_integer(int, fd, fd)) TRACEPOINT_EVENT( node, @@ -74,15 +67,12 @@ TRACEPOINT_EVENT( const char*, remote, int, port, int, fd, - int, buffered - ), + int, buffered), TP_FIELDS( ctf_string(remote, remote) ctf_integer(int, port, port) ctf_integer(int, fd, fd) - ctf_integer(int, buffered, buffered) - ) -) + ctf_integer(int, buffered, buffered)) TRACEPOINT_EVENT( node, @@ -90,26 +80,21 @@ TRACEPOINT_EVENT( TP_ARGS( const char*, remote, int, port, - int, fd - ), + int, fd), TP_FIELDS( ctf_string(remote, remote) ctf_integer(int, port, port) - ctf_integer(int, fd, fd) - ) -) + ctf_integer(int, fd, fd)) TRACEPOINT_EVENT( node, gc_start, TP_ARGS( const char*, gctype, - const char*, gcflags - ), + const char*, gcflags), TP_FIELDS( ctf_string(gctype, gctype) - ctf_string(gcflags, gcflags) - ) + ctf_string(gcflags, gcflags)) ) TRACEPOINT_EVENT( @@ -117,14 +102,15 @@ TRACEPOINT_EVENT( gc_done, TP_ARGS( const char*, gctype, - const char*, gcflags - ), + const char*, gcflags), TP_FIELDS( ctf_string(gctype, gctype) - ctf_string(gcflags, gcflags) - ) -) + ctf_string(gcflags, gcflags)) #endif /* __NODE_LTTNG_TP_H */ #include + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_LTTNG_TP_H_ From 5aff60e832a3b0531f860fa53b6e8a826792d0cc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 200/261] src: lint v8abbr.h PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- Makefile | 1 - src/v8abbr.h | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2a671b43b0af54..091dca717b5757 100644 --- a/Makefile +++ b/Makefile @@ -638,7 +638,6 @@ CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE += src/node_root_certs.h CPPLINT_EXCLUDE += src/queue.h CPPLINT_EXCLUDE += src/tree.h -CPPLINT_EXCLUDE += src/v8abbr.h CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h) CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ diff --git a/src/v8abbr.h b/src/v8abbr.h index 95a04b40887771..365825e6cf1472 100644 --- a/src/v8abbr.h +++ b/src/v8abbr.h @@ -76,7 +76,8 @@ * SeqTwoByteString class, but it's the same as the one for SeqOneByteString. */ #ifndef V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR -#define V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR V8DBG_CLASS_SEQONEBYTESTRING__CHARS__CHAR +#define V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR \ + V8DBG_CLASS_SEQONEBYTESTRING__CHARS__CHAR #endif /* Heap class->field offsets */ From 68e9fd47c638972819609a97df07a9bd0339983a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 201/261] tools: fix -Wunused-variable warning PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- tools/icu/iculslocs.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/icu/iculslocs.cc b/tools/icu/iculslocs.cc index d71f9b8e5d702c..2471e3f8583011 100644 --- a/tools/icu/iculslocs.cc +++ b/tools/icu/iculslocs.cc @@ -193,7 +193,6 @@ int dumpAllButInstalledLocales(int lev, LocalUFILEPointer* bf, UErrorCode* status) { ures_resetIterator(bund->getAlias()); - const UBool isTable = (UBool)(ures_getType(bund->getAlias()) == URES_TABLE); LocalUResourceBundlePointer t; while (U_SUCCESS(*status) && ures_hasNext(bund->getAlias())) { t.adoptInstead(ures_getNextResource(bund->getAlias(), t.orphan(), status)); From 23797eb0370fad9eb3fcdd314959c399d5d5dc85 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 28 Jun 2016 21:21:21 +0200 Subject: [PATCH 202/261] src: remove obsolete NOLINT comments Obsoleted by the recent cpplint upgrade. PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris --- src/stream_base.h | 2 +- src/string_search.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stream_base.h b/src/stream_base.h index e722a208a8af68..cdce46abc8dcd2 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -259,7 +259,7 @@ class StreamBase : public StreamResource { const v8::PropertyCallbackInfo& args); template & args)> static void JSMethod(const v8::FunctionCallbackInfo& args); diff --git a/src/string_search.h b/src/string_search.h index 26b15de0d7d60a..01dbf9156e97df 100644 --- a/src/string_search.h +++ b/src/string_search.h @@ -171,7 +171,7 @@ class StringSearch : private StringSearchBase { } private: - typedef size_t (*SearchFunction)( // NOLINT - it's not a cast! + typedef size_t (*SearchFunction)( StringSearch*, Vector, size_t); From 3eea55167d5706e9c71a35adf23ee784e8c6075d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Jun 2016 14:56:18 +0200 Subject: [PATCH 203/261] src: fix memory leak in WriteBuffers() error path Pointed out by Coverity. Introduced in commit 05d30d53 from July 2015 ("fs: implemented WriteStream#writev"). WriteBuffers() leaked memory in the synchronous uv_fs_write() error path when trying to write > 1024 buffers. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- src/node_file.cc | 25 +++++-------------------- src/util.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 59b40f94380bdb..fadf4cef93cd61 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -930,38 +930,23 @@ static void WriteBuffers(const FunctionCallbackInfo& args) { int64_t pos = GET_OFFSET(args[2]); Local req = args[3]; - uint32_t chunkCount = chunks->Length(); + MaybeStackBuffer iovs(chunks->Length()); - uv_buf_t s_iovs[1024]; // use stack allocation when possible - uv_buf_t* iovs; - - if (chunkCount > arraysize(s_iovs)) - iovs = new uv_buf_t[chunkCount]; - else - iovs = s_iovs; - - for (uint32_t i = 0; i < chunkCount; i++) { + for (uint32_t i = 0; i < iovs.length(); i++) { Local chunk = chunks->Get(i); - if (!Buffer::HasInstance(chunk)) { - if (iovs != s_iovs) - delete[] iovs; + if (!Buffer::HasInstance(chunk)) return env->ThrowTypeError("Array elements all need to be buffers"); - } iovs[i] = uv_buf_init(Buffer::Data(chunk), Buffer::Length(chunk)); } if (req->IsObject()) { - ASYNC_CALL(write, req, fd, iovs, chunkCount, pos) - if (iovs != s_iovs) - delete[] iovs; + ASYNC_CALL(write, req, fd, *iovs, iovs.length(), pos) return; } - SYNC_CALL(write, nullptr, fd, iovs, chunkCount, pos) - if (iovs != s_iovs) - delete[] iovs; + SYNC_CALL(write, nullptr, fd, *iovs, iovs.length(), pos) args.GetReturnValue().Set(SYNC_RESULT); } diff --git a/src/util.h b/src/util.h index 8c2b0a1be4c47a..1973f268e4ecac 100644 --- a/src/util.h +++ b/src/util.h @@ -212,6 +212,16 @@ class MaybeStackBuffer { return buf_; } + T& operator[](size_t index) { + CHECK_LT(index, length()); + return buf_[index]; + } + + const T& operator[](size_t index) const { + CHECK_LT(index, length()); + return buf_[index]; + } + size_t length() const { return length_; } @@ -263,6 +273,10 @@ class MaybeStackBuffer { buf_[0] = T(); } + explicit MaybeStackBuffer(size_t storage) : MaybeStackBuffer() { + AllocateSufficientStorage(storage); + } + ~MaybeStackBuffer() { if (buf_ != buf_st_) free(buf_); From eab9ced2ee0aa05ecc8e783871bf97a81b946403 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 22 Jun 2016 23:39:21 +0200 Subject: [PATCH 204/261] test: fix flaky test-vm-timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Likely fix the flaky parallel/test-vm-timeout. Increase the outer timeout in the test checking for nested timeouts with `vm` scripts so that its firing won’t interfere with the inner timeout. Fixes: https://github.com/nodejs/node/issues/6727 PR-URL: https://github.com/nodejs/node/pull/7373 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- test/parallel/test-vm-timeout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-vm-timeout.js b/test/parallel/test-vm-timeout.js index b4dd57bb54d234..d595bac4c32324 100644 --- a/test/parallel/test-vm-timeout.js +++ b/test/parallel/test-vm-timeout.js @@ -29,6 +29,6 @@ assert.throws(function() { vm.runInNewContext('while(true) {}', context, { timeout: timeout }); } }; - vm.runInNewContext('runInVM(10)', context, { timeout: 100 }); + vm.runInNewContext('runInVM(10)', context, { timeout: 10000 }); throw new Error('Test 5 failed'); }, /Script execution timed out./); From 8404e346652965a57f578dec9437ed9cd11b3016 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 23 Jun 2016 00:26:47 +0200 Subject: [PATCH 205/261] Revert "test: mark test-vm-timeout flaky on windows" This reverts commit f34caa96d1c6374aa44999f41aa538d1171abd0c. PR-URL: https://github.com/nodejs/node/pull/7373 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- test/parallel/parallel.status | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 16556cb20c3fcf..2cdc5b7b07cb64 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -7,8 +7,7 @@ prefix parallel [true] # This section applies to all platforms [$system==win32] -test-tick-processor : PASS,FLAKY -test-vm-timeout : PASS,FLAKY +test-tick-processor : PASS,FLAKY [$system==linux] test-tick-processor : PASS,FLAKY From e52b2b07d7f73ef33b7a25f40016bddfb9d5bd83 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 10 May 2016 23:08:33 -0700 Subject: [PATCH 206/261] doc: add `added:` information for assert PR-URL: https://github.com/nodejs/node/pull/6688 Ref: https://github.com/nodejs/node/issues/6578 Reviewed-By: Claudio Rodriguez Reviewed-By: James M Snell Reviewed-By: Roman Klauke Reviewed-By: Anna Henningsen --- doc/api/assert.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/api/assert.md b/doc/api/assert.md index 35dbc3d2192209..e54e81d22e384e 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -13,6 +13,9 @@ additions or changes to any of the methods implemented and exposed by the module. ## assert(value[, message]) + An alias of [`assert.ok()`][] . @@ -30,6 +33,9 @@ assert(false, 'it\'s false'); ``` ## assert.deepEqual(actual, expected[, message]) + Tests for deep equality between the `actual` and `expected` parameters. Primitive values are compared with the equal comparison operator ( `==` ). @@ -88,6 +94,9 @@ property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.deepStrictEqual(actual, expected[, message]) + Generally identical to `assert.deepEqual()` with two exceptions. First, primitive values are compared using the strict equality operator ( `===` ). @@ -109,6 +118,9 @@ property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.doesNotThrow(block[, error][, message]) + Asserts that the function `block` does not throw an error. See [`assert.throws()`][] for more details. @@ -161,6 +173,9 @@ assert.doesNotThrow( ``` ## assert.equal(actual, expected[, message]) + Tests shallow, coercive equality between the `actual` and `expected` parameters using the equal comparison operator ( `==` ). @@ -184,6 +199,9 @@ property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.fail(actual, expected, message, operator) + Throws an `AssertionError`. If `message` is falsy, the error message is set as the values of `actual` and `expected` separated by the provided `operator`. @@ -200,6 +218,9 @@ assert.fail(1, 2, 'whoops', '>'); ``` ## assert.ifError(value) + Throws `value` if `value` is truthy. This is useful when testing the `error` argument in callbacks. @@ -214,6 +235,9 @@ assert.ifError(new Error()); // Throws Error ``` ## assert.notDeepEqual(actual, expected[, message]) + Tests for any deep inequality. Opposite of [`assert.deepEqual()`][]. @@ -255,6 +279,9 @@ property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.notDeepStrictEqual(actual, expected[, message]) + Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][]. @@ -273,6 +300,9 @@ with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.notEqual(actual, expected[, message]) + Tests shallow, coercive inequality with the not equal comparison operator ( `!=` ). @@ -295,6 +325,9 @@ property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error message is assigned. ## assert.notStrictEqual(actual, expected[, message]) + Tests strict inequality as determined by the strict not equal operator ( `!==` ). @@ -317,6 +350,9 @@ If the values are strictly equal, an `AssertionError` is thrown with a `message` parameter is undefined, a default error message is assigned. ## assert.ok(value[, message]) + Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`. @@ -339,6 +375,9 @@ assert.ok(false, 'it\'s false'); ``` ## assert.strictEqual(actual, expected[, message]) + Tests strict equality as determined by the strict equality operator ( `===` ). @@ -360,6 +399,9 @@ If the values are not strictly equal, an `AssertionError` is thrown with a `message` parameter is undefined, a default error message is assigned. ## assert.throws(block[, error][, message]) + Expects the function `block` to throw an error. From ec9038478f27abc3305cda777a5090d475257a6c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 23 May 2016 16:21:54 +0200 Subject: [PATCH 207/261] doc: add `added:` information for child_process Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6927 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis --- doc/api/child_process.md | 73 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index db70d06644e500..e4799fece771f8 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -112,6 +112,9 @@ exec('my.bat', (err, stdout, stderr) => { ``` ### child_process.exec(command[, options][, callback]) + * `command` {String} The command to run, with space-separated arguments * `options` {Object} @@ -189,6 +192,9 @@ terminated. replace the existing process and uses a shell to execute the command.* ### child_process.execFile(file[, args][, options][, callback]) + * `file` {String} The name or path of the executable file to run * `args` {Array} List of string arguments @@ -234,6 +240,9 @@ stderr output. If `encoding` is `'buffer'`, or an unrecognized character encoding, `Buffer` objects will be passed to the callback instead. ### child_process.fork(modulePath[, args][, options]) + * `modulePath` {String} The module to run in the child * `args` {Array} List of string arguments @@ -278,6 +287,9 @@ output on this fd is expected to be line delimited JSON objects. not clone the current process.* ### child_process.spawn(command[, args][, options]) + * `command` {String} The command to run * `args` {Array} List of string arguments @@ -383,6 +395,9 @@ child.on('error', (err) => { ``` #### options.detached + On Windows, setting `options.detached` to `true` makes it possible for the child process to continue running after the parent exits. The child will have @@ -437,6 +452,9 @@ child.unref(); ``` #### options.stdio + The `options.stdio` option is used to configure the pipes that are established between the parent and child process. By default, the child's stdin, stdout, @@ -523,6 +541,9 @@ scripting tasks and for simplifying the loading/processing of application configuration at startup. ### child_process.execFileSync(file[, args][, options]) + * `file` {String} The name or path of the executable file to run * `args` {Array} List of string arguments @@ -556,6 +577,9 @@ throw. The [`Error`][] object will contain the entire result from [`child_process.spawnSync()`][] ### child_process.execSync(command[, options]) + * `command` {String} The command to run * `options` {Object} @@ -592,6 +616,9 @@ throw. The [`Error`][] object will contain the entire result from [`child_process.spawnSync()`][] ### child_process.spawnSync(command[, args][, options]) + * `command` {String} The command to run * `args` {Array} List of string arguments @@ -626,6 +653,9 @@ completely exited. Note that if the process intercepts and handles the process has exited. ## Class: ChildProcess + Instances of the `ChildProcess` class are [`EventEmitters`][] that represent spawned child processes. @@ -636,6 +666,9 @@ use the [`child_process.spawn()`][], [`child_process.exec()`][], instances of `ChildProcess`. ### Event: 'close' + * `code` {Number} the exit code if the child exited on its own. * `signal` {String} the signal by which the child process was terminated. @@ -645,13 +678,16 @@ been closed. This is distinct from the `'exit'` event, since multiple processes might share the same stdio streams. ### Event: 'disconnect' + The `'disconnect'` event is emitted after calling the `ChildProcess.disconnect()` method in the parent or child process. After disconnecting it is no longer possible to send or receive messages, and the `ChildProcess.connected` property is false. -### Event: 'error' +### Event: 'error' * `err` {Error} the error. @@ -667,7 +703,10 @@ to guard against accidentally invoking handler functions multiple times. See also [`ChildProcess#kill()`][] and [`ChildProcess#send()`][]. -### Event: 'exit' +### Event: 'exit' + * `code` {Number} the exit code if the child exited on its own. * `signal` {String} the signal by which the child process was terminated. @@ -688,6 +727,9 @@ and then will re-raise the handled signal. See `waitpid(2)`. ### Event: 'message' + * `message` {Object} a parsed JSON object or primitive value. * `sendHandle` {Handle} a [`net.Socket`][] or [`net.Server`][] object, or @@ -697,6 +739,9 @@ The `'message'` event is triggered when a child process uses `process.send()` to send messages. ### child.connected + * {Boolean} Set to false after `.disconnect` is called @@ -705,6 +750,9 @@ and receive messages from a child process. When `child.connected` is false, it is no longer possible to send or receive messages. ### child.disconnect() + Closes the IPC channel between parent and child, allowing the child to exit gracefully once there are no other connections keeping it alive. After calling @@ -721,6 +769,9 @@ Note that when the child process is a Node.js instance (e.g. spawned using within the child process to close the IPC channel as well. ### child.kill([signal]) + * `signal` {String} @@ -775,6 +826,9 @@ setTimeout(() => { ``` ### child.pid + * {Number} Integer @@ -791,6 +845,9 @@ grep.stdin.end(); ``` ### child.send(message[, sendHandle][, callback]) + * `message` {Object} * `sendHandle` {Handle} @@ -936,6 +993,9 @@ this occurs. *Note: this function uses [`JSON.stringify()`][] internally to serialize the `message`.* ### child.stderr + * {Stream} @@ -948,6 +1008,9 @@ then this will be `undefined`. the same value. ### child.stdin + * {Stream} @@ -963,6 +1026,9 @@ then this will be `undefined`. the same value. ### child.stdio + * {Array} @@ -1000,6 +1066,9 @@ assert.equal(child.stdio[2], child.stderr); ``` ### child.stdout + * {Stream} From eb08c17a203c7f4db6e1dcf68c979995ff9bd854 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 24 May 2016 17:04:39 -0700 Subject: [PATCH 208/261] doc: add `added: ` data for cli.md PR-URL: https://github.com/nodejs/node/pull/6960 Refs: https://github.com/nodejs/node/issues/6578 Reviewed-By: Jeremiah Senkpiel Reviewed-By: James M Snell Reviewed-By: Myles Borins --- doc/api/cli.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 2910c782d2ad8e..357f3c33a83884 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -2,7 +2,7 @@ -Node.js comes with a wide variety of CLI options. These options expose built-in +Node.js comes with a variety of CLI options. These options expose built-in debugging, multiple ways to execute scripts, and other helpful runtime options. To view this documentation as a manual page in your terminal, run `man node`. @@ -24,37 +24,58 @@ _For more info about `node debug`, please see the [debugger][] documentation._ ## Options ### `-v`, `--version` + Print node's version. ### `-h`, `--help` + Print node command line options. The output of this option is less detailed than this document. ### `-e`, `--eval "script"` + Evaluate the following argument as JavaScript. ### `-p`, `--print "script"` + Identical to `-e` but prints the result. ### `-c`, `--check` + Syntax check the script without executing. ### `-i`, `--interactive` + Opens the REPL even if stdin does not appear to be a terminal. ### `-r`, `--require module` + Preload the specified module at startup. @@ -63,48 +84,75 @@ rules. `module` may be either a path to a file, or a node module name. ### `--no-deprecation` + Silence deprecation warnings. ### `--trace-deprecation` + Print stack traces for deprecations. ### `--throw-deprecation` + Throw errors for deprecations. ### `--trace-sync-io` + Prints a stack trace whenever synchronous I/O is detected after the first turn of the event loop. ### `--zero-fill-buffers` + Automatically zero-fills all newly allocated [Buffer][] and [SlowBuffer][] instances. ### `--track-heap-objects` + Track heap object allocations for heap snapshots. ### `--prof-process` + Process v8 profiler output generated using the v8 option `--prof`. ### `--v8-options` + Print v8 command line options. ### `--tls-cipher-list=list` + Specify an alternative default TLS cipher list. (Requires Node.js to be built with crypto support. (Default)) @@ -123,6 +171,9 @@ Force FIPS-compliant crypto on startup. (Cannot be disabled from script code.) ### `--icu-data-dir=file` + Specify ICU data load path. (overrides `NODE_ICU_DATA`) @@ -130,11 +181,17 @@ Specify ICU data load path. (overrides `NODE_ICU_DATA`) ## Environment Variables ### `NODE_DEBUG=module[,…]` + `','`-separated list of core modules that should print debug information. ### `NODE_PATH=path[:…]` + `':'`-separated list of directories prefixed to the module search path. @@ -142,17 +199,26 @@ _Note: on Windows, this is a `';'`-separated list instead._ ### `NODE_DISABLE_COLORS=1` + When set to `1` colors will not be used in the REPL. ### `NODE_ICU_DATA=file` + Data path for ICU (Intl object) data. Will extend linked-in data when compiled with small-icu support. ### `NODE_REPL_HISTORY=file` + Path to the file used to store the persistent REPL history. The default path is `~/.node_repl_history`, which is overridden by this variable. Setting the value From a0ca24b7983f86b109322504bc96c8aaf8a50864 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Thu, 26 May 2016 11:28:32 -0400 Subject: [PATCH 209/261] doc: add `added:` information for console Information extracted from git history. Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6995 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Julian Duque --- doc/api/console.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/api/console.md b/doc/api/console.md index ead2c3607011a5..f1835b2e1924b1 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -101,6 +101,9 @@ new Console(process.stdout, process.stderr); ``` ### console.assert(value[, message][, ...]) + A simple assertion test that verifies whether `value` is truthy. If it is not, an `AssertionError` is thrown. If provided, the error `message` is formatted @@ -154,6 +157,9 @@ console.log('this will also print'); ``` ### console.dir(obj[, options]) + Uses [`util.inspect()`][] on `obj` and prints the resulting string to `stdout`. This function bypasses any custom `inspect()` function defined on `obj`. An @@ -172,6 +178,9 @@ Defaults to `false`. Colors are customizable; see [customizing `util.inspect()` colors][]. ### console.error([data][, ...]) + Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution @@ -191,10 +200,16 @@ If formatting elements (e.g. `%d`) are not found in the first string then values are concatenated. See [`util.format()`][] for more information. ### console.info([data][, ...]) + The `console.info()` function is an alias for [`console.log()`][]. ### console.log([data][, ...]) + Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution @@ -214,6 +229,9 @@ If formatting elements (e.g. `%d`) are not found in the first string then values are concatenated. See [`util.format()`][] for more information. ### console.time(label) + Used to calculate the duration of a specific operation. To start a timer, call the `console.time()` method, giving it a unique `label` as the only parameter. To stop the @@ -222,6 +240,9 @@ timer, and to get the elapsed time in milliseconds, just call the timer's unique `label` as the parameter. ### console.timeEnd(label) + Stops a timer that was previously started by calling [`console.time()`][] and prints the result to stdout: @@ -236,6 +257,9 @@ console.timeEnd('100-elements'); ``` ### console.trace(message[, ...]) + Prints to `stderr` the string `'Trace :'`, followed by the [`util.format()`][] formatted message and stack trace to the current position in the code. @@ -257,6 +281,9 @@ console.trace('Show me'); ``` ### console.warn([data][, ...]) + The `console.warn()` function is an alias for [`console.error()`][]. From 1d99059bb117c39850851bc8555d00f91023d657 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Fri, 27 May 2016 12:06:23 -0400 Subject: [PATCH 210/261] doc: add `added:` information for dns Got the information from git history and I ignored previous version of dns attached to `node.dns` (pre v0.1.16). There is a case where `dns.resolveNaptr` were intented to be in v0.7.12 and it was reverted and addec back on `v0.9.12`, I left the latest version when module was introduced. Same for `dns.resolvePtr` who was referenced before but it was only added on `v6.0.0` Refs: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/7021 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- doc/api/dns.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/doc/api/dns.md b/doc/api/dns.md index 699198fa3b9967..3ab20ce01f6e91 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -54,11 +54,17 @@ There are subtle consequences in choosing one over the other, please consult the [Implementation considerations section][] for more information. ## dns.getServers() + Returns an array of IP address strings that are being used for name resolution. ## dns.lookup(hostname[, options], callback) + Resolves a hostname (e.g. `'nodejs.org'`) into the first found A (IPv4) or AAAA (IPv6) record. `options` can be an object or integer. If `options` is @@ -122,6 +128,9 @@ found, then return IPv4 mapped IPv6 addresses. Note that it is not supported on some operating systems (e.g FreeBSD 10.1). ## dns.lookupService(address, port, callback) + Resolves the given `address` and `port` into a hostname and service using the operating system's underlying `getnameinfo` implementation. @@ -140,6 +149,9 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { ``` ## dns.resolve(hostname[, rrtype], callback) + Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array of the record types specified by `rrtype`. @@ -168,6 +180,9 @@ On error, `err` is an [`Error`][] object, where `err.code` is one of the error codes listed [here](#dns_error_codes). ## dns.resolve4(hostname, callback) + Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function @@ -175,12 +190,18 @@ will contain an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). ## dns.resolve6(hostname, callback) + Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv6 addresses. ## dns.resolveCname(hostname, callback) + Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function @@ -188,6 +209,9 @@ will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`). ## dns.resolveMx(hostname, callback) + Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -195,6 +219,9 @@ contain an array of objects containing both a `priority` and `exchange` property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). ## dns.resolveNaptr(hostname, callback) + Uses the DNS protocol to resolve regular expression based records (`NAPTR` records) for the `hostname`. The `callback` function has arguments @@ -222,6 +249,9 @@ For example: ``` ## dns.resolveNs(hostname, callback) + Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -229,6 +259,9 @@ contain an array of name server records available for `hostname` (e.g., `['ns1.example.com', 'ns2.example.com']`). ## dns.resolveSoa(hostname, callback) + Uses the DNS protocol to resolve a start of authority record (`SOA` record) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -255,6 +288,9 @@ be an object with the following properties: ``` ## dns.resolveSrv(hostname, callback) + Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -275,6 +311,9 @@ be an array of objects with the following properties: ``` ## dns.resolveTxt(hostname, callback) + Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `addresses` argument passed to the `callback` function is @@ -284,6 +323,9 @@ one record. Depending on the use case, these could be either joined together or treated separately. ## dns.reverse(ip, callback) + Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames. @@ -295,6 +337,9 @@ On error, `err` is an [`Error`][] object, where `err.code` is one of the [DNS error codes][]. ## dns.setServers(servers) + Sets the IP addresses of the servers to be used when resolving. The `servers` argument is an array of IPv4 or IPv6 addresses. From b08ff33c010b01a8d83ac1fbfc9bb774a09cf5e6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 23 Jun 2016 21:51:12 +0200 Subject: [PATCH 211/261] doc: add `added:` information for https Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/7392 Reviewed-By: James M Snell --- doc/api/https.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/api/https.md b/doc/api/https.md index 09c4b5d2b9775f..e7cbc9969c3ccd 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -6,24 +6,39 @@ HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a separate module. ## Class: https.Agent + An Agent object for HTTPS similar to [`http.Agent`][]. See [`https.request()`][] for more information. ## Class: https.Server + This class is a subclass of `tls.Server` and emits events same as [`http.Server`][]. See [`http.Server`][] for more information. ### server.setTimeout(msecs, callback) + See [`http.Server#setTimeout()`][]. ### server.timeout + See [`http.Server#timeout`][]. ## https.createServer(options[, requestListener]) + Returns a new HTTPS web server object. The `options` is similar to [`tls.createServer()`][]. The `requestListener` is a function which is @@ -64,6 +79,9 @@ https.createServer(options, (req, res) => { ``` ### server.close([callback]) + See [`http.close()`][] for details. @@ -74,6 +92,9 @@ See [`http.close()`][] for details. See [`http.listen()`][] for details. ## https.get(options, callback) + Like [`http.get()`][] but for HTTPS. @@ -99,10 +120,16 @@ https.get('https://encrypted.google.com/', (res) => { ``` ## https.globalAgent + Global instance of [`https.Agent`][] for all HTTPS client requests. ## https.request(options, callback) + Makes a request to a secure web server. From 78d361b22bd25431de5e099e457fdece9bf4e88a Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Thu, 2 Jun 2016 20:15:22 -0400 Subject: [PATCH 212/261] doc: add `added` information for net Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/7038 Reviewed-By: Anna Henningsen --- doc/api/net.md | 169 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/doc/api/net.md b/doc/api/net.md index 4cd003daecd53e..cc93231c5eb713 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -7,17 +7,26 @@ functions for creating both servers and clients (called streams). You can includ this module with `require('net');`. ## Class: net.Server + This class is used to create a TCP or local server. `net.Server` is an [`EventEmitter`][] with the following events: ### Event: 'close' + Emitted when the server closes. Note that if connections exist, this event is not emitted until all connections are ended. ### Event: 'connection' + * {net.Socket} The connection object @@ -25,6 +34,9 @@ Emitted when a new connection is made. `socket` is an instance of `net.Socket`. ### Event: 'error' + * {Error} @@ -32,10 +44,16 @@ Emitted when an error occurs. The [`'close'`][] event will be called directly following this event. See example in discussion of `server.listen`. ### Event: 'listening' + Emitted when the server has been bound after calling `server.listen`. ### server.address() + Returns the bound address, the address family name, and port of the server as reported by the operating system. @@ -63,6 +81,9 @@ server.listen(() => { Don't call `server.address()` until the `'listening'` event has been emitted. ### server.close([callback]) + Stops the server from accepting new connections and keeps existing connections. This function is asynchronous, the server is finally @@ -72,6 +93,10 @@ that event, it will be called with an Error as its only argument if the server was not open when it was closed. ### server.connections + Stability: 0 - Deprecated: Use [`server.getConnections()`][] instead. @@ -82,6 +107,9 @@ This becomes `null` when sending a socket to a child with connections use asynchronous `server.getConnections` instead. ### server.getConnections(callback) + Asynchronously get the number of concurrent connections on the server. Works when sockets were sent to forks. @@ -89,6 +117,9 @@ when sockets were sent to forks. Callback should take two arguments `err` and `count`. ### server.listen(handle[, backlog][, callback]) + * `handle` {Object} * `backlog` {Number} @@ -112,6 +143,9 @@ The parameter `backlog` behaves the same as in [`server.listen(port[, hostname][, backlog][, callback])`][`server.listen(port, host, backlog, callback)`]. ### server.listen(options[, callback]) + * `options` {Object} - Required. Supports the following properties: * `port` {Number} - Optional. @@ -141,6 +175,9 @@ server.listen({ ``` ### server.listen(path[, backlog][, callback]) + * `path` {String} * `backlog` {Number} @@ -175,6 +212,9 @@ The parameter `backlog` behaves the same as in [`server.listen(port[, hostname][, backlog][, callback])`][`server.listen(port, host, backlog, callback)`]. ### server.listen(port[, hostname][, backlog][, callback]) + Begin accepting connections on the specified `port` and `hostname`. If the `hostname` is omitted, the server will accept connections on any IPv6 address @@ -209,6 +249,9 @@ server.on('error', (e) => { (Note: All sockets in Node.js are set `SO_REUSEADDR`.) ### server.maxConnections + Set this property to reject connections when the server's connection count gets high. @@ -217,6 +260,9 @@ It is not recommended to use this option once a socket has been sent to a child with [`child_process.fork()`][]. ### server.ref() + Opposite of `unref`, calling `ref` on a previously `unref`d server will *not* let the program exit if it's the only server left (the default behavior). If @@ -225,6 +271,9 @@ the server is `ref`d calling `ref` again will have no effect. Returns `server`. ### server.unref() + Calling `unref` on a server will allow the program to exit if this is the only active server in the event system. If the server is already `unref`d calling @@ -233,6 +282,9 @@ active server in the event system. If the server is already `unref`d calling Returns `server`. ## Class: net.Socket + This object is an abstraction of a TCP or local socket. `net.Socket` instances implement a duplex Stream interface. They can be created by the @@ -240,6 +292,9 @@ user and used as a client (with [`connect()`][]) or they can be created by Node. and passed to the user through the `'connection'` event of a server. ### new net.Socket([options]) + Construct a new socket object. @@ -262,6 +317,9 @@ About `allowHalfOpen`, refer to `createServer()` and `'end'` event. `net.Socket` instances are [`EventEmitter`][] with the following events: ### Event: 'close' + * `had_error` {Boolean} `true` if the socket had a transmission error. @@ -269,11 +327,17 @@ Emitted once the socket is fully closed. The argument `had_error` is a boolean which says if the socket was closed due to a transmission error. ### Event: 'connect' + Emitted when a socket connection is successfully established. See [`connect()`][]. ### Event: 'data' + * {Buffer} @@ -285,12 +349,18 @@ Note that the __data will be lost__ if there is no listener when a `Socket` emits a `'data'` event. ### Event: 'drain' + Emitted when the write buffer becomes empty. Can be used to throttle uploads. See also: the return values of `socket.write()` ### Event: 'end' + Emitted when the other end of the socket sends a FIN packet. @@ -301,6 +371,9 @@ its side allowing the user to write arbitrary amounts of data, with the caveat that the user is required to `end()` their side now. ### Event: 'error' + * {Error} @@ -308,6 +381,9 @@ Emitted when an error occurs. The `'close'` event will be called directly following this event. ### Event: 'lookup' + Emitted after resolving the hostname but before connecting. Not applicable to UNIX sockets. @@ -317,6 +393,9 @@ Not applicable to UNIX sockets. * `family` {String|Null} The address type. See [`dns.lookup()`][]. ### Event: 'timeout' + Emitted if the socket times out from inactivity. This is only to notify that the socket has been idle. The user must manually close the connection. @@ -324,6 +403,9 @@ the socket has been idle. The user must manually close the connection. See also: [`socket.setTimeout()`][] ### socket.address() + Returns the bound address, the address family name and port of the socket as reported by the operating system. Returns an object with @@ -331,6 +413,9 @@ three properties, e.g. `{ port: 12346, family: 'IPv4', address: '127.0.0.1' }` ### socket.bufferSize + `net.Socket` has the property that `socket.write()` always works. This is to help users get up and running quickly. The computer cannot always keep up @@ -349,14 +434,23 @@ Users who experience large or growing `bufferSize` should attempt to "throttle" the data flows in their program with [`pause()`][] and [`resume()`][]. ### socket.bytesRead + The amount of received bytes. ### socket.bytesWritten + The amount of bytes sent. ### socket.connect(options[, connectListener]) + Opens the connection for a given socket. @@ -391,11 +485,17 @@ The `connectListener` parameter will be added as a listener for the ### socket.connect(path[, connectListener]) ### socket.connect(port[, host][, connectListener]) + As [`socket.connect(options\[, connectListener\])`][`socket.connect(options, connectListener)`], with options either as either `{port: port, host: host}` or `{path: path}`. ### socket.destroy() + Ensures that no more I/O activity happens on this socket. Only necessary in case of errors (parse error or so). @@ -406,6 +506,9 @@ A Boolean value that indicates if the connection is destroyed or not. Once a connection is destroyed no further data can be transferred using it. ### socket.end([data][, encoding]) + Half-closes the socket. i.e., it sends a FIN packet. It is possible the server will still send some data. @@ -414,12 +517,18 @@ If `data` is specified, it is equivalent to calling `socket.write(data, encoding)` followed by `socket.end()`. ### socket.localAddress + The string representation of the local IP address the remote client is connecting on. For example, if you are listening on `'0.0.0.0'` and the client connects on `'192.168.1.1'`, the value would be `'192.168.1.1'`. ### socket.localPort + The numeric representation of the local port. For example, `80` or `21`. @@ -430,6 +539,9 @@ Pauses the reading of data. That is, [`'data'`][] events will not be emitted. Useful to throttle back an upload. ### socket.ref() + Opposite of `unref`, calling `ref` on a previously `unref`d socket will *not* let the program exit if it's the only socket left (the default behavior). If @@ -438,16 +550,25 @@ the socket is `ref`d calling `ref` again will have no effect. Returns `socket`. ### socket.remoteAddress + The string representation of the remote IP address. For example, `'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if the socket is destroyed (for example, if the client disconnected). ### socket.remoteFamily + The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. ### socket.remotePort + The numeric representation of the remote port. For example, `80` or `21`. @@ -457,11 +578,17 @@ The numeric representation of the remote port. For example, Resumes reading after a call to [`pause()`][]. ### socket.setEncoding([encoding]) + Set the encoding for the socket as a [Readable Stream][]. See [`stream.setEncoding()`][] for more information. ### socket.setKeepAlive([enable][, initialDelay]) + Enable/disable keep-alive functionality, and optionally set the initial delay before the first keepalive probe is sent on an idle socket. @@ -475,6 +602,9 @@ initialDelay will leave the value unchanged from the default Returns `socket`. ### socket.setNoDelay([noDelay]) + Disables the Nagle algorithm. By default TCP connections use the Nagle algorithm, they buffer data before sending it off. Setting `true` for @@ -484,6 +614,9 @@ algorithm, they buffer data before sending it off. Setting `true` for Returns `socket`. ### socket.setTimeout(timeout[, callback]) + Sets the socket to timeout after `timeout` milliseconds of inactivity on the socket. By default `net.Socket` do not have a timeout. @@ -500,6 +633,9 @@ The optional `callback` parameter will be added as a one time listener for the Returns `socket`. ### socket.unref() + Calling `unref` on a socket will allow the program to exit if this is the only active socket in the event system. If the socket is already `unref`d calling @@ -508,6 +644,9 @@ active socket in the event system. If the socket is already `unref`d calling Returns `socket`. ### socket.write(data[, encoding][, callback]) + Sends data on the socket. The second parameter specifies the encoding in the case of a string--it defaults to UTF8 encoding. @@ -520,6 +659,9 @@ The optional `callback` parameter will be executed when the data is finally written out - this may not be immediately. ## net.connect(options[, connectListener]) + A factory function, which returns a new [`net.Socket`][] and automatically connects with the supplied `options`. @@ -556,6 +698,9 @@ const client = net.connect({path: '/tmp/echo.sock'}); ``` ## net.connect(path[, connectListener]) + A factory function, which returns a new unix [`net.Socket`][] and automatically connects to the supplied `path`. @@ -564,6 +709,9 @@ The `connectListener` parameter will be added as a listener for the [`'connect'`][] event once. ## net.connect(port[, host][, connectListener]) + A factory function, which returns a new [`net.Socket`][] and automatically connects to the supplied `port` and `host`. @@ -574,6 +722,9 @@ The `connectListener` parameter will be added as a listener for the [`'connect'`][] event once. ## net.createConnection(options[, connectListener]) + A factory function, which returns a new [`net.Socket`][] and automatically connects with the supplied `options`. @@ -610,6 +761,9 @@ const client = net.connect({path: '/tmp/echo.sock'}); ``` ## net.createConnection(path[, connectListener]) + A factory function, which returns a new unix [`net.Socket`][] and automatically connects to the supplied `path`. @@ -618,6 +772,9 @@ The `connectListener` parameter will be added as a listener for the [`'connect'`][] event once. ## net.createConnection(port[, host][, connectListener]) + A factory function, which returns a new [`net.Socket`][] and automatically connects to the supplied `port` and `host`. @@ -628,6 +785,9 @@ The `connectListener` parameter will be added as a listener for the [`'connect'`][] event once. ## net.createServer([options][, connectionListener]) + Creates a new server. The `connectionListener` argument is automatically set as a listener for the [`'connection'`][] event. @@ -695,17 +855,26 @@ nc -U /tmp/echo.sock ``` ## net.isIP(input) + Tests if input is an IP address. Returns 0 for invalid strings, returns 4 for IP version 4 addresses, and returns 6 for IP version 6 addresses. ## net.isIPv4(input) + Returns true if input is a version 4 IP address, otherwise returns false. ## net.isIPv6(input) + Returns true if input is a version 6 IP address, otherwise returns false. From 8b53f4b27ceeb3e8865a9dee28caf769a26f3331 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 5 May 2016 18:34:29 -0700 Subject: [PATCH 213/261] doc: add `added:` information for os Via git spelunking, mostly. Some functions have been renamed. Used the version in which they were renamed. Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6609 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Stephen Belanger --- doc/api/os.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/doc/api/os.md b/doc/api/os.md index ea4f40ba79e958..42085356a89b6d 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -7,16 +7,25 @@ Provides a few basic operating-system related utility functions. Use `require('os')` to access this module. ## os.EOL + A constant defining the appropriate End-of-line marker for the operating system. ## os.arch() + Returns the operating system CPU architecture. Possible values are `'x64'`, `'arm'` and `'ia32'`. Returns the value of [`process.arch`][]. ## os.cpus() + Returns an array of objects containing information about each CPU/core installed: model, speed (in MHz), and times (an object containing the number of @@ -95,23 +104,38 @@ Note that since `nice` values are UNIX centric in Windows the `nice` values of all processors are always 0. ## os.endianness() + Returns the endianness of the CPU. Possible values are `'BE'` for big endian or `'LE'` for little endian. ## os.freemem() + Returns the amount of free system memory in bytes. ## os.homedir() + Returns the home directory of the current user. ## os.hostname() + Returns the hostname of the operating system. ## os.loadavg() + Returns an array containing the 1, 5, and 15 minute load averages. @@ -124,6 +148,9 @@ Windows platforms. That is why this function always returns `[0, 0, 0]` on Windows. ## os.networkInterfaces() + Get a list of network interfaces: @@ -156,29 +183,47 @@ Note that due to the underlying implementation this will only return network interfaces that have been assigned an address. ## os.platform() + Returns the operating system platform. Possible values are `'darwin'`, `'freebsd'`, `'linux'`, `'sunos'` or `'win32'`. Returns the value of [`process.platform`][]. ## os.release() + Returns the operating system release. ## os.tmpdir() + Returns the operating system's default directory for temporary files. ## os.totalmem() + Returns the total amount of system memory in bytes. ## os.type() + Returns the operating system name. For example `'Linux'` on Linux, `'Darwin'` on OS X and `'Windows_NT'` on Windows. ## os.uptime() + Returns the system uptime in seconds. From f1a37ad749da7a9cc97e0ead6ade2a4bff996593 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Wed, 25 May 2016 21:48:32 -0400 Subject: [PATCH 214/261] doc: add `added:` information for path Got the information from git history mostly, I ignored previous path methods attached to `node.path` (pre v0.1.16). Refs: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6985 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/path.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/api/path.md b/doc/api/path.md index dfc566444e0f94..7174278ce72127 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -9,6 +9,9 @@ The file system is not consulted to check whether paths are valid. Use `require('path')` to use this module. The following methods are provided: ## path.basename(p[, ext]) + Return the last portion of a path. Similar to the Unix `basename` command. @@ -23,6 +26,9 @@ path.basename('/foo/bar/baz/asdf/quux.html', '.html') ``` ## path.delimiter + The platform-specific path delimiter, `;` or `':'`. @@ -47,6 +53,9 @@ process.env.PATH.split(path.delimiter) ``` ## path.dirname(p) + Return the directory name of a path. Similar to the Unix `dirname` command. @@ -58,6 +67,9 @@ path.dirname('/foo/bar/baz/asdf/quux') ``` ## path.extname(p) + Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion @@ -82,6 +94,9 @@ path.extname('.index') ``` ## path.format(pathObject) + Returns a path string from an object, the opposite of [`path.parse`][]. @@ -106,6 +121,9 @@ path.format({ ``` ## path.isAbsolute(path) + Determines whether `path` is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. @@ -133,6 +151,9 @@ path.isAbsolute('.') // false returned. ## path.join([path1][, path2][, ...]) + Join all arguments together and normalize the resulting path. @@ -156,6 +177,9 @@ TypeError: Arguments to path.join must be strings current working directory. ## path.normalize(p) + Normalize a string path, taking care of `'..'` and `'.'` parts. @@ -174,6 +198,9 @@ path.normalize('/foo/bar//baz/asdf/quux/..') will be returned, which represents the current working directory. ## path.parse(pathString) + Returns an object from a path string. @@ -206,11 +233,17 @@ path.parse('C:\\path\\dir\\index.html') ``` ## path.posix + Provide access to aforementioned `path` methods but always interact in a posix compatible way. ## path.relative(from, to) + Solve the relative path from `from` to `to`. @@ -237,6 +270,9 @@ path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') both the paths are the same then a zero-length string will be returned. ## path.resolve([from ...], to) + Resolves `to` to an absolute path. @@ -283,6 +319,9 @@ path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif') working directory will be used instead of them. ## path.sep + The platform-specific file separator. `'\\'` or `'/'`. @@ -301,6 +340,9 @@ An example on Windows: ``` ## path.win32 + Provide access to aforementioned `path` methods but always interact in a win32 compatible way. From a870cdcd1fc18942545f0edda55337243558136c Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 17 May 2016 18:58:03 +0800 Subject: [PATCH 215/261] doc: add `added:` information for punycode PR-URL: https://github.com/nodejs/node/pull/6805 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/punycode.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/api/punycode.md b/doc/api/punycode.md index 7f3617c12d8efd..f94ecb16bfff46 100644 --- a/doc/api/punycode.md +++ b/doc/api/punycode.md @@ -2,11 +2,14 @@ Stability: 2 - Stable -[Punycode.js][] is bundled with Node.js v0.6.2+. Use `require('punycode')` to +[Punycode.js][] is bundled with Node.js v0.5.1+. Use `require('punycode')` to access it. (To use it with other Node.js versions, use npm to install the `punycode` module first.) ## punycode.decode(string) + Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols. @@ -17,6 +20,9 @@ punycode.decode('--dqo34k'); // '☃-⌘' ``` ## punycode.encode(string) + Converts a string of Unicode symbols to a Punycode string of ASCII-only symbols. @@ -27,6 +33,9 @@ punycode.encode('☃-⌘'); // '--dqo34k' ``` ## punycode.toASCII(domain) + Converts a Unicode string representing a domain name to Punycode. Only the non-ASCII parts of the domain name will be converted, i.e. it doesn't matter if @@ -39,6 +48,9 @@ punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' ``` ## punycode.toUnicode(domain) + Converts a Punycode string representing a domain name to Unicode. Only the Punycoded parts of the domain name will be converted, i.e. it doesn't matter if @@ -51,8 +63,14 @@ punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' ``` ## punycode.ucs2 + ### punycode.ucs2.decode(string) + Creates an array containing the numeric code point values of each Unicode symbol in the string. While [JavaScript uses UCS-2 internally][], this function @@ -66,6 +84,9 @@ punycode.ucs2.decode('\uD834\uDF06'); // [0x1D306] ``` ### punycode.ucs2.encode(codePoints) + Creates a string based on an array of numeric code point values. @@ -75,6 +96,9 @@ punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06' ``` ## punycode.version + A string representing the current Punycode.js version number. From eec0c635ee3350f1e4b2cbc9667a81cc7e1f5d8d Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 4 May 2016 22:50:03 -0700 Subject: [PATCH 216/261] doc: add `added:` information for querystring Module introduced in 7ff04c1f8. Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6593 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Stephen Belanger Reviewed-By: Anna Henningsen --- doc/api/querystring.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/querystring.md b/doc/api/querystring.md index 3a864e2d4fa1fe..263f44e1990b44 100644 --- a/doc/api/querystring.md +++ b/doc/api/querystring.md @@ -8,11 +8,17 @@ This module provides utilities for dealing with query strings. It provides the following methods: ## querystring.escape + The escape function used by `querystring.stringify`, provided so that it could be overridden if necessary. ## querystring.parse(str[, sep][, eq][, options]) + Deserialize a query string to an object. Optionally override the default separator (`'&'`) and assignment (`'='`) @@ -38,6 +44,9 @@ querystring.parse('w=%D6%D0%CE%C4&foo=bar', null, null, ``` ## querystring.stringify(obj[, sep][, eq][, options]) + Serialize an object to a query string. Optionally override the default separator (`'&'`) and assignment (`'='`) @@ -63,6 +72,9 @@ querystring.stringify({ w: '中文', foo: 'bar' }, null, null, ``` ## querystring.unescape + The unescape function used by `querystring.parse`, provided so that it could be overridden if necessary. From e6d7bfcbe78a0a0bf4488ea63cad3a5cca503977 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 26 May 2016 11:39:07 -0400 Subject: [PATCH 217/261] doc: add `added:` information for readline Got the information from git history, I added the version when Interface was exported as class (v0.1.104), it was an internal class on previous versions. Refs: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6996 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/readline.md | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/doc/api/readline.md b/doc/api/readline.md index e48865ac04a40a..eddebccc9d31d1 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -26,16 +26,25 @@ rl.question('What do you think of Node.js? ', (answer) => { ``` ## Class: Interface + The class that represents a readline interface with an input and output stream. ### rl.close() + Closes the `Interface` instance, relinquishing control on the `input` and `output` streams. The `'close'` event will also be emitted. ### rl.pause() + Pauses the readline `input` stream, allowing it to be resumed later if needed. @@ -43,6 +52,9 @@ Note that this doesn't immediately pause the stream of events. Several events ma be emitted after calling `pause`, including `line`. ### rl.prompt([preserveCursor]) + Readies readline for input from the user, putting the current `setPrompt` options on a new line, giving the user a new spot to write. Set `preserveCursor` @@ -55,6 +67,9 @@ If `output` is set to `null` or `undefined` when calling `createInterface`, the prompt is not written. ### rl.question(query, callback) + Prepends the prompt with `query` and invokes `callback` with the user's response. Displays the query to the user, and then invokes `callback` @@ -75,15 +90,24 @@ rl.question('What is your favorite food?', (answer) => { ``` ### rl.resume() + Resumes the readline `input` stream. ### rl.setPrompt(prompt) + Sets the prompt, for example when you run `node` on the command line, you see `> `, which is Node.js's prompt. ### rl.write(data[, key]) + Writes `data` to `output` stream, unless `output` is set to `null` or `undefined` when calling `createInterface`. `key` is an object literal to @@ -102,6 +126,9 @@ rl.write(null, {ctrl: true, name: 'u'}); ## Events ### Event: 'close' + `function () {}` @@ -115,6 +142,9 @@ This event is also called if there is no `SIGINT` event listener present when the `input` stream receives a `^C`, respectively known as `SIGINT`. ### Event: 'line' + `function (line) {}` @@ -131,6 +161,9 @@ rl.on('line', (cmd) => { ``` ### Event: 'pause' + `function () {}` @@ -148,6 +181,9 @@ rl.on('pause', () => { ``` ### Event: 'resume' + `function () {}` @@ -162,6 +198,9 @@ rl.on('resume', () => { ``` ### Event: 'SIGCONT' + `function () {}` @@ -182,6 +221,9 @@ rl.on('SIGCONT', () => { ``` ### Event: 'SIGINT' + `function () {}` @@ -200,6 +242,9 @@ rl.on('SIGINT', () => { ``` ### Event: 'SIGTSTP' + `function () {}` @@ -272,6 +317,9 @@ rl.on('line', (line) => { ``` ## readline.clearLine(stream, dir) + Clears current line of given TTY stream in a specified direction. `dir` should have one of following values: @@ -281,10 +329,16 @@ Clears current line of given TTY stream in a specified direction. * `0` - the entire line ## readline.clearScreenDown(stream) + Clears the screen from the current position of the cursor down. ## readline.createInterface(options) + Creates a readline `Interface` instance. Accepts an `options` Object that takes the following values: @@ -351,10 +405,16 @@ a `'resize'` event on the `output` if/when the columns ever change ([`process.stdout`][] does this automatically when it is a TTY). ## readline.cursorTo(stream, x, y) + Move cursor to the specified position in a given TTY stream. ## readline.emitKeypressEvents(stream[, interface]) + Causes `stream` to begin emitting `'keypress'` events corresponding to its input. @@ -362,6 +422,9 @@ Optionally, `interface` specifies a `readline.Interface` instance for which autocompletion is disabled when copy-pasted input is detected. ## readline.moveCursor(stream, dx, dy) + Move cursor relative to it's current position in a given TTY stream. From 4474e83b781ce9c18f4a9a937f26a576ae8ee1cf Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 10 Jun 2016 09:12:55 +0200 Subject: [PATCH 218/261] doc: add `added:` information for repl Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/7256 Reviewed-By: Julian Duque --- doc/api/repl.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/api/repl.md b/doc/api/repl.md index a6d78b61d446b8..b25dd890f46781 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -153,10 +153,16 @@ and try to print `obj` in REPL, it will invoke the custom `inspect()` function: ``` ## Class: REPLServer + This inherits from [Readline Interface][] with the following events: ### Event: 'exit' + `function () {}` @@ -175,6 +181,9 @@ replServer.on('exit', () => { ### Event: 'reset' + `function (context) {}` @@ -197,6 +206,9 @@ replServer.on('reset', (context) => { ``` ### replServer.defineCommand(keyword, cmd) + * `keyword` {String} * `cmd` {Object|Function} @@ -235,6 +247,9 @@ Hello, Node.js User! ``` ### replServer.displayPrompt([preserveCursor]) + * `preserveCursor` {Boolean} From 5b50b1c255c12dd335d0485cc2f5a30534c09dd6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 13 May 2016 10:01:33 -0700 Subject: [PATCH 219/261] doc: add `added:` info for `string_decoder` PR-URL: https://github.com/nodejs/node/pull/6741 Ref: https://github.com/nodejs/node/issues/6578 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Roman Klauke --- doc/api/string_decoder.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/string_decoder.md b/doc/api/string_decoder.md index d1de27dc4a395a..b24b067602b9ce 100644 --- a/doc/api/string_decoder.md +++ b/doc/api/string_decoder.md @@ -18,13 +18,22 @@ console.log(decoder.write(euro)); ``` ## Class: StringDecoder + Accepts a single argument, `encoding` which defaults to `'utf8'`. ### decoder.end() + Returns any trailing bytes that were left in the buffer. ### decoder.write(buffer) + Returns a decoded string. From 3c8f19fcdf60a7b863aca0d09130e733833ced68 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 15 May 2016 23:15:46 -0700 Subject: [PATCH 220/261] doc: add `added:` in for `tty` Refs: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6783 Reviewed-By: James M Snell --- doc/api/tty.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/api/tty.md b/doc/api/tty.md index 6075702b533895..e7214ce9182c6d 100644 --- a/doc/api/tty.md +++ b/doc/api/tty.md @@ -18,29 +18,44 @@ false ``` ## Class: ReadStream + A `net.Socket` subclass that represents the readable portion of a tty. In normal circumstances, `process.stdin` will be the only `tty.ReadStream` instance in any Node.js program (only when `isatty(0)` is true). ### rs.isRaw + A `Boolean` that is initialized to `false`. It represents the current "raw" state of the `tty.ReadStream` instance. ### rs.setRawMode(mode) + `mode` should be `true` or `false`. This sets the properties of the `tty.ReadStream` to act either as a raw device or default. `isRaw` will be set to the resulting mode. ## Class: WriteStream + A `net.Socket` subclass that represents the writable portion of a tty. In normal circumstances, `process.stdout` will be the only `tty.WriteStream` instance ever created (and only when `isatty(1)` is true). ### Event: 'resize' + `function () {}` @@ -55,16 +70,25 @@ process.stdout.on('resize', () => { ``` ### ws.columns + A `Number` that gives the number of columns the TTY currently has. This property gets updated on `'resize'` events. ### ws.rows + A `Number` that gives the number of rows the TTY currently has. This property gets updated on `'resize'` events. ## tty.isatty(fd) + Returns `true` or `false` depending on if the `fd` is associated with a terminal. From 1758f02ec1209f58384105ef444b80b42669fb0a Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 4 May 2016 22:52:42 -0700 Subject: [PATCH 221/261] doc: add `added:` information for url Module introduced in 7ff04c1f8. Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6593 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Stephen Belanger Reviewed-By: Anna Henningsen --- doc/api/url.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/url.md b/doc/api/url.md index ab29c500d80335..f8c2980bd568bc 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -80,6 +80,9 @@ properties of URL objects: The following methods are provided by the URL module: ## url.format(urlObj) + Take a parsed URL object, and return a formatted URL string. @@ -106,6 +109,9 @@ Here's how the formatting process works: * `hash` is treated the same with or without the leading `#` (pound sign, anchor). ## url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) + Take a URL string, and return an object. @@ -120,6 +126,9 @@ Pass `true` as the third argument to treat `//foo/bar` as `{ pathname: '//foo/bar' }`. Defaults to `false`. ## url.resolve(from, to) + Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. Examples: From 3e3471fb5fb462d1216bb3cd798e0e8ad4291e72 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 10 May 2016 20:21:30 -0700 Subject: [PATCH 222/261] doc: add `added:` information for v8 PR-URL: https://github.com/nodejs/node/pull/6684 Ref: https://github.com/nodejs/node/issues/6578 Reviewed-By: Ben Noorhduis Reviewed-By: Claudio Rodriguez Reviewed-By: Stephen Belanger Reviewed-By: Anna Henningsen --- doc/api/v8.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/v8.md b/doc/api/v8.md index 6753c2a4a37ce0..f0ab08cfeb6d47 100644 --- a/doc/api/v8.md +++ b/doc/api/v8.md @@ -7,6 +7,9 @@ built with Node.js. These interfaces are subject to change by upstream and are therefore not covered under the stability index. ## getHeapStatistics() + Returns an object with the following properties @@ -22,6 +25,9 @@ Returns an object with the following properties ``` ## setFlagsFromString(string) + Set additional V8 command line flags. Use with care; changing settings after the VM has started may result in unpredictable behavior, including From 7abfb6e8dca59cb92be11209a7e4b7a4c47b1980 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 27 May 2016 04:21:30 +0200 Subject: [PATCH 223/261] doc: add `added:` information for vm Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/7011 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Julian Duque --- doc/api/vm.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/doc/api/vm.md b/doc/api/vm.md index d53c8dc8d70850..e014994d75e2a0 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -14,10 +14,16 @@ JavaScript code can be compiled and run immediately or compiled, saved, and run later. ## Class: Script + A class for holding precompiled scripts, and running them in specific sandboxes. ### new vm.Script(code, options) + Creating a new `Script` compiles `code` but does not run it. Instead, the created `vm.Script` object represents this compiled code. This script can be run @@ -40,6 +46,9 @@ The options when creating a script are: execution. If execution is terminated, an [`Error`][] will be thrown. ### script.runInContext(contextifiedSandbox[, options]) + Similar to [`vm.runInContext()`][] but a method of a precompiled `Script` object. `script.runInContext()` runs `script`'s compiled code in @@ -78,6 +87,9 @@ Note that running untrusted code is a tricky business requiring great care. requires a separate process. ### script.runInNewContext([sandbox][, options]) + Similar to [`vm.runInNewContext()`][] but a method of a precompiled `Script` object. `script.runInNewContext()` contextifies `sandbox` if passed or creates a @@ -114,6 +126,9 @@ Note that running untrusted code is a tricky business requiring great care. requires a separate process. ### script.runInThisContext([options]) + Similar to [`vm.runInThisContext()`]() but a method of a precompiled `Script` object. `script.runInThisContext()` runs `script`'s compiled code and returns @@ -155,6 +170,9 @@ The options for running a script are: execution. If execution is terminated, an [`Error`][] will be thrown. ## vm.createContext([sandbox]) + If given a `sandbox` object, will "contextify" that sandbox so that it can be used in calls to [`vm.runInContext()`][] or [`script.runInContext()`][]. Inside @@ -172,6 +190,9 @@ single sandbox representing a window's global object, then run all ` + + +
    + + + +``` -Benchmarks for other engines to come (?). +## marked(markdownString [,options] [,callback]) -## Install +### markdownString + +Type: `string` + +String of markdown source to be compiled. + +### options + +Type: `object` + +Hash of options. Can also be set using the `marked.setOptions` method as seen +above. + +### callback + +Type: `function` + +Function called when the `markdownString` has been fully parsed when using +async highlighting. If the `options` argument is omitted, this can be used as +the second argument. + +## Options + +### highlight + +Type: `function` + +A function to highlight code blocks. The first example below uses async highlighting with +[node-pygmentize-bundled][pygmentize], and the second is a synchronous example using +[highlight.js][highlight]: + +```js +var marked = require('marked'); + +var markdownString = '```js\n console.log("hello"); \n```'; + +// Async highlighting with pygmentize-bundled +marked.setOptions({ + highlight: function (code, lang, callback) { + require('pygmentize-bundled')({ lang: lang, format: 'html' }, code, function (err, result) { + callback(err, result.toString()); + }); + } +}); + +// Using async version of marked +marked(markdownString, function (err, content) { + if (err) throw err; + console.log(content); +}); + +// Synchronous highlighting with highlight.js +marked.setOptions({ + highlight: function (code) { + return require('highlight.js').highlightAuto(code).value; + } +}); + +console.log(marked(markdownString)); +``` + +#### highlight arguments + +`code` + +Type: `string` + +The section of code to pass to the highlighter. + +`lang` + +Type: `string` + +The programming language specified in the code block. + +`callback` + +Type: `function` + +The callback function to call when using an async highlighter. + +### renderer + +Type: `object` +Default: `new Renderer()` + +An object containing functions to render tokens to HTML. + +#### Overriding renderer methods + +The renderer option allows you to render tokens in a custom manner. Here is an +example of overriding the default heading token rendering by adding an embedded anchor tag like on GitHub: + +```javascript +var marked = require('marked'); +var renderer = new marked.Renderer(); + +renderer.heading = function (text, level) { + var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); + + return '' + + text + ''; +}, + +console.log(marked('# heading+', { renderer: renderer })); +``` +This code will output the following HTML: +```html +

    + + + + heading+ +

    +``` + +#### Block level renderer methods + +- code(*string* code, *string* language) +- blockquote(*string* quote) +- html(*string* html) +- heading(*string* text, *number* level) +- hr() +- list(*string* body, *boolean* ordered) +- listitem(*string* text) +- paragraph(*string* text) +- table(*string* header, *string* body) +- tablerow(*string* content) +- tablecell(*string* content, *object* flags) + +`flags` has the following properties: + +```js +{ + header: true || false, + align: 'center' || 'left' || 'right' +} +``` + +#### Inline level renderer methods + +- strong(*string* text) +- em(*string* text) +- codespan(*string* code) +- br() +- del(*string* text) +- link(*string* href, *string* title, *string* text) +- image(*string* href, *string* title, *string* text) + +### gfm + +Type: `boolean` +Default: `true` + +Enable [GitHub flavored markdown][gfm]. + +### tables + +Type: `boolean` +Default: `true` + +Enable GFM [tables][tables]. +This option requires the `gfm` option to be true. + +### breaks + +Type: `boolean` +Default: `false` + +Enable GFM [line breaks][breaks]. +This option requires the `gfm` option to be true. + +### pedantic + +Type: `boolean` +Default: `false` + +Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of +the original markdown bugs or poor behavior. + +### sanitize + +Type: `boolean` +Default: `false` + +Sanitize the output. Ignore any HTML that has been input. + +### smartLists + +Type: `boolean` +Default: `true` + +Use smarter list behavior than the original markdown. May eventually be +default with the old behavior moved into `pedantic`. + +### smartypants + +Type: `boolean` +Default: `false` + +Use "smart" typograhic punctuation for things like quotes and dashes. + +## Access to lexer and parser + +You also have direct access to the lexer and parser if you so desire. + +``` js +var tokens = marked.lexer(text, options); +console.log(marked.parser(tokens)); +``` + +``` js +var lexer = new marked.Lexer(options); +var tokens = lexer.lex(text); +console.log(tokens); +console.log(lexer.rules); +``` + +## CLI ``` bash -$ npm install marked +$ marked -o hello.html +hello world +^D +$ cat hello.html +

    hello world

    ``` -## Another javascript markdown parser +## Philosophy behind marked The point of marked was to create a markdown compiler where it was possible to frequently parse huge chunks of markdown without having to worry about @@ -58,78 +310,97 @@ of performance, but did not in order to be exactly what you expect in terms of a markdown rendering. In fact, this is why marked could be considered at a disadvantage in the benchmarks above. -Along with implementing every markdown feature, marked also implements -[GFM features](http://github.github.com/github-flavored-markdown/). +Along with implementing every markdown feature, marked also implements [GFM +features][gfmf]. -## Usage +## Benchmarks -``` js -var marked = require('marked'); -console.log(marked('i am using __markdown__.')); +node v0.8.x + +``` bash +$ node test --bench +marked completed in 3411ms. +marked (gfm) completed in 3727ms. +marked (pedantic) completed in 3201ms. +robotskirt completed in 808ms. +showdown (reuse converter) completed in 11954ms. +showdown (new converter) completed in 17774ms. +markdown-js completed in 17191ms. ``` +__Marked is now faster than Discount, which is written in C.__ + +For those feeling skeptical: These benchmarks run the entire markdown test suite 1000 times. The test suite tests every feature. It doesn't cater to specific aspects. + +### Pro level + You also have direct access to the lexer and parser if you so desire. ``` js -var tokens = marked.lexer(str); +var tokens = marked.lexer(text, options); console.log(marked.parser(tokens)); ``` +``` js +var lexer = new marked.Lexer(options); +var tokens = lexer.lex(text); +console.log(tokens); +console.log(lexer.rules); +``` + ``` bash $ node > require('marked').lexer('> i am using marked.') [ { type: 'blockquote_start' }, - { type: 'text', text: ' i am using marked.' }, + { type: 'paragraph', + text: 'i am using marked.' }, { type: 'blockquote_end' }, links: {} ] ``` -## CLI +## Running Tests & Contributing -``` bash -$ marked -o hello.html -hello world -^D -$ cat hello.html -

    hello world

    -``` +If you want to submit a pull request, make sure your changes pass the test +suite. If you're adding a new feature, be sure to add your own test. -## Syntax Highlighting +The marked test suite is set up slightly strangely: `test/new` is for all tests +that are not part of the original markdown.pl test suite (this is where your +test should go if you make one). `test/original` is only for the original +markdown.pl tests. `test/tests` houses both types of tests after they have been +combined and moved/generated by running `node test --fix` or `marked --test +--fix`. -Marked has an interface that allows for a syntax highlighter to highlight code -blocks before they're output. +In other words, if you have a test to add, add it to `test/new/` and then +regenerate the tests with `node test --fix`. Commit the result. If your test +uses a certain feature, for example, maybe it assumes GFM is *not* enabled, you +can add `.nogfm` to the filename. So, `my-test.text` becomes +`my-test.nogfm.text`. You can do this with any marked option. Say you want +line breaks and smartypants enabled, your filename should be: +`my-test.breaks.smartypants.text`. -Example implementation: +To run the tests: -``` js -var highlight = require('my-syntax-highlighter') - , marked_ = require('marked'); - -var marked = function(text) { - var tokens = marked_.lexer(text) - , l = tokens.length - , i = 0 - , token; - - for (; i < l; i++) { - token = tokens[i]; - if (token.type === 'code') { - token.text = highlight(token.text, token.lang); - // marked should not escape this - token.escaped = true; - } - } - - text = marked_.parser(tokens); +``` bash +cd marked/ +node test +``` - return text; -}; +### Contribution and License Agreement -module.exports = marked; -``` +If you contribute code to this project, you are implicitly allowing your code +to be distributed under the MIT license. You are also implicitly verifying that +all code is your original work. `` ## License -Copyright (c) 2011-2012, Christopher Jeffrey. (MIT License) +Copyright (c) 2011-2014, Christopher Jeffrey. (MIT License) See LICENSE for more info. + +[gfm]: https://help.github.com/articles/github-flavored-markdown +[gfmf]: http://github.github.com/github-flavored-markdown/ +[pygmentize]: https://github.com/rvagg/node-pygmentize-bundled +[highlight]: https://github.com/isagalaev/highlight.js +[badge]: http://badge.fury.io/js/marked +[tables]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-tables +[breaks]: https://help.github.com/articles/github-flavored-markdown#newlines diff --git a/tools/doc/node_modules/marked/bin/marked b/tools/doc/node_modules/marked/bin/marked index 7d00504ed16803..64254fc3eb2e08 100755 --- a/tools/doc/node_modules/marked/bin/marked +++ b/tools/doc/node_modules/marked/bin/marked @@ -2,7 +2,7 @@ /** * Marked CLI - * Copyright (c) 2011-2012, Christopher Jeffrey (MIT License) + * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License) */ var fs = require('fs') @@ -13,7 +13,7 @@ var fs = require('fs') * Man Page */ -var help = function() { +function help() { var spawn = require('child_process').spawn; var options = { @@ -26,32 +26,54 @@ var help = function() { spawn('man', [__dirname + '/../man/marked.1'], options); -}; +} /** * Main */ -var main = function(argv) { +function main(argv, callback) { var files = [] - , data = '' + , options = {} , input , output , arg - , tokens; + , tokens + , opt; - var getarg = function() { + function getarg() { var arg = argv.shift(); - arg = arg.split('='); - if (arg.length > 1) { - argv.unshift(arg.slice(1).join('=')); + + if (arg.indexOf('--') === 0) { + // e.g. --opt + arg = arg.split('='); + if (arg.length > 1) { + // e.g. --opt=val + argv.unshift(arg.slice(1).join('=')); + } + arg = arg[0]; + } else if (arg[0] === '-') { + if (arg.length > 2) { + // e.g. -abc + argv = arg.substring(1).split('').map(function(ch) { + return '-' + ch; + }).concat(argv); + arg = argv.shift(); + } else { + // e.g. -a + } + } else { + // e.g. foo } - return arg[0]; - }; + + return arg; + } while (argv.length) { arg = getarg(); switch (arg) { + case '--test': + return require('../test').main(process.argv.slice()); case '-o': case '--output': output = argv.shift(); @@ -68,48 +90,98 @@ var main = function(argv) { case '--help': return help(); default: - files.push(arg); + if (arg.indexOf('--') === 0) { + opt = camelize(arg.replace(/^--(no-)?/, '')); + if (!marked.defaults.hasOwnProperty(opt)) { + continue; + } + if (arg.indexOf('--no-') === 0) { + options[opt] = typeof marked.defaults[opt] !== 'boolean' + ? null + : false; + } else { + options[opt] = typeof marked.defaults[opt] !== 'boolean' + ? argv.shift() + : true; + } + } else { + files.push(arg); + } break; } } - if (!input) { - if (files.length <= 2) { - var stdin = process.stdin; - - stdin.setEncoding('utf8'); - stdin.resume(); - - stdin.on('data', function(text) { - data += text; - }); - - stdin.on('end', write); - - return; + function getData(callback) { + if (!input) { + if (files.length <= 2) { + return getStdin(callback); + } + input = files.pop(); } - input = files.pop(); + return fs.readFile(input, 'utf8', callback); } - data = fs.readFileSync(input, 'utf8'); - write(); + return getData(function(err, data) { + if (err) return callback(err); - function write() { data = tokens - ? JSON.stringify(marked.lexer(data), null, 2) - : marked(data); + ? JSON.stringify(marked.lexer(data, options), null, 2) + : marked(data, options); if (!output) { process.stdout.write(data + '\n'); - } else { - fs.writeFileSync(output, data); + return callback(); } + + return fs.writeFile(output, data, callback); + }); +} + +/** + * Helpers + */ + +function getStdin(callback) { + var stdin = process.stdin + , buff = ''; + + stdin.setEncoding('utf8'); + + stdin.on('data', function(data) { + buff += data; + }); + + stdin.on('error', function(err) { + return callback(err); + }); + + stdin.on('end', function() { + return callback(null, buff); + }); + + try { + stdin.resume(); + } catch (e) { + callback(e); } -}; +} + +function camelize(text) { + return text.replace(/(\w)-(\w)/g, function(_, a, b) { + return a + b.toUpperCase(); + }); +} + +/** + * Expose / Entry Point + */ if (!module.parent) { process.title = 'marked'; - main(process.argv.slice()); + main(process.argv.slice(), function(err, code) { + if (err) throw err; + return process.exit(code || 0); + }); } else { module.exports = main; } diff --git a/tools/doc/node_modules/marked/bower.json b/tools/doc/node_modules/marked/bower.json new file mode 100644 index 00000000000000..a2a8187759f7c9 --- /dev/null +++ b/tools/doc/node_modules/marked/bower.json @@ -0,0 +1,24 @@ +{ + "name": "marked", + "version": "0.3.4", + "homepage": "https://github.com/chjj/marked", + "authors": [ + "Christopher Jeffrey " + ], + "description": "A markdown parser built for speed", + "keywords": [ + "markdown", + "markup", + "html" + ], + "main": "lib/marked.js", + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "app/bower_components", + "test", + "tests" + ] +} diff --git a/tools/doc/node_modules/marked/component.json b/tools/doc/node_modules/marked/component.json new file mode 100644 index 00000000000000..1d672877f6e712 --- /dev/null +++ b/tools/doc/node_modules/marked/component.json @@ -0,0 +1,10 @@ +{ + "name": "marked", + "version": "0.3.4", + "repo": "chjj/marked", + "description": "A markdown parser built for speed", + "keywords": ["markdown", "markup", "html"], + "scripts": ["lib/marked.js"], + "main": "lib/marked.js", + "license": "MIT" +} diff --git a/tools/doc/node_modules/marked/doc/broken.md b/tools/doc/node_modules/marked/doc/broken.md new file mode 100644 index 00000000000000..7bfa49e8a9adf9 --- /dev/null +++ b/tools/doc/node_modules/marked/doc/broken.md @@ -0,0 +1,426 @@ +# Markdown is broken + +I have a lot of scraps of markdown engine oddities that I've collected over the +years. What you see below is slightly messy, but it's what I've managed to +cobble together to illustrate the differences between markdown engines, and +why, if there ever is a markdown specification, it has to be absolutely +thorough. There are a lot more of these little differences I have documented +elsewhere. I know I will find them lingering on my disk one day, but until +then, I'll continue to add whatever strange nonsensical things I find. + +Some of these examples may only mention a particular engine compared to marked. +However, the examples with markdown.pl could easily be swapped out for +discount, upskirt, or markdown.js, and you would very easily see even more +inconsistencies. + +A lot of this was written when I was very unsatisfied with the inconsistencies +between markdown engines. Please excuse the frustration noticeable in my +writing. + +## Examples of markdown's "stupid" list parsing + +``` +$ markdown.pl + + * item1 + + * item2 + + text +^D +
      +
    • item1

      + +
        +
      • item2
      • +
      + +

      text

    • +

    +``` + + +``` +$ marked + * item1 + + * item2 + + text +^D +
      +
    • item1

      +
        +
      • item2
      • +
      +

      text

      +
    • +
    +``` + +Which looks correct to you? + +- - - + +``` +$ markdown.pl +* hello + > world +^D +

      +
    • hello

      + +
      +

      world

    • +

    + +``` + +``` +$ marked +* hello + > world +^D +
      +
    • hello
      +

      world

      +
      +
    • +
    +``` + +Again, which looks correct to you? + +- - - + +EXAMPLE: + +``` +$ markdown.pl +* hello + * world + * hi + code +^D +
      +
    • hello +
        +
      • world
      • +
      • hi + code
      • +
    • +
    +``` + +The code isn't a code block even though it's after the bullet margin. I know, +lets give it two more spaces, effectively making it 8 spaces past the bullet. + +``` +$ markdown.pl +* hello + * world + * hi + code +^D +
      +
    • hello +
        +
      • world
      • +
      • hi + code
      • +
    • +
    +``` + +And, it's still not a code block. Did you also notice that the 3rd item isn't +even its own list? Markdown screws that up too because of its indentation +unaware parsing. + +- - - + +Let's look at some more examples of markdown's list parsing: + +``` +$ markdown.pl + + * item1 + + * item2 + + text +^D +
      +
    • item1

      + +
        +
      • item2
      • +
      + +

      text

    • +

    +``` + +Misnested tags. + + +``` +$ marked + * item1 + + * item2 + + text +^D +
      +
    • item1

      +
        +
      • item2
      • +
      +

      text

      +
    • +
    +``` + +Which looks correct to you? + +- - - + +``` +$ markdown.pl +* hello + > world +^D +

      +
    • hello

      + +
      +

      world

    • +

    + +``` + +More misnested tags. + + +``` +$ marked +* hello + > world +^D +
      +
    • hello
      +

      world

      +
      +
    • +
    +``` + +Again, which looks correct to you? + +- - - + +# Why quality matters - Part 2 + +``` bash +$ markdown.pl +* hello + > world +^D +

      +
    • hello

      + +
      +

      world

    • +

    + +``` + +``` bash +$ sundown # upskirt +* hello + > world +^D +
      +
    • hello +> world
    • +
    +``` + +``` bash +$ marked +* hello + > world +^D +
    • hello

      world

    +``` + +Which looks correct to you? + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/23 + +``` bash +$ markdown.pl # upskirt/markdown.js/discount +* hello + var a = 1; +* world +^D +
      +
    • hello +var a = 1;
    • +
    • world
    • +
    +``` + +``` bash +$ marked +* hello + var a = 1; +* world +^D +
    • hello +
      code>var a = 1;
    • +
    • world
    +``` + +Which looks more reasonable? Why shouldn't code blocks be able to appear in +list items in a sane way? + +- - - + +``` bash +$ markdown.js +
    hello
    + +hello +^D +

    <div>hello</div>

    + +

    <span>hello</span>

    +``` + +``` bash +$ marked +
    hello
    + +hello +^D +
    hello
    + + +

    hello +

    +``` + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/27 + +``` bash +$ markdown.js +[![an image](/image)](/link) +^D +

    ![an image

    +``` + +``` bash +$ marked +[![an image](/image)](/link) +^D +

    an image +

    +``` + +- - - + +See: https://github.com/evilstreak/markdown-js/issues/24 + +``` bash +$ markdown.js +> a + +> b + +> c +^D +

    a

    bundefined> c

    +``` + +``` bash +$ marked +> a + +> b + +> c +^D +

    a + +

    +

    b + +

    +

    c +

    +``` + +- - - + +``` bash +$ markdown.pl +* hello + * world + how + + are + you + + * today +* hi +^D +
      +
    • hello

      + +
        +
      • world +how
      • +
      + +

      are +you

      + +
        +
      • today
      • +
    • +
    • hi
    • +
    +``` + +``` bash +$ marked +* hello + * world + how + + are + you + + * today +* hi +^D +
      +
    • hello

      +
        +
      • world +how

        +

        are +you

        +
      • +
      • today

        +
      • +
      +
    • +
    • hi
    • +
    +``` diff --git a/tools/doc/node_modules/marked/doc/todo.md b/tools/doc/node_modules/marked/doc/todo.md new file mode 100644 index 00000000000000..2e60b162aef82d --- /dev/null +++ b/tools/doc/node_modules/marked/doc/todo.md @@ -0,0 +1,2 @@ +# Todo + diff --git a/tools/doc/node_modules/marked/lib/marked.js b/tools/doc/node_modules/marked/lib/marked.js index e76178471a15bb..03251f3c58a761 100644 --- a/tools/doc/node_modules/marked/lib/marked.js +++ b/tools/doc/node_modules/marked/lib/marked.js @@ -1,6 +1,7 @@ /** - * marked - A markdown parser (https://github.com/chjj/marked) - * Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed) + * marked - a markdown parser + * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) + * https://github.com/chjj/marked */ ;(function() { @@ -11,82 +12,148 @@ var block = { newline: /^\n+/, - code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?:\n+|$)/, - gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/, - hr: /^( *[\-*_]){3,} *(?:\n+|$)/, + code: /^( {4}[^\n]+\n*)+/, + fences: noop, + hr: /^( *[-*_]){3,} *(?:\n+|$)/, heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, - lheading: /^([^\n]+)\n *(=|-){3,} *\n*/, - blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/, - list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )|\s*$)(?!\1bullet)\n*/, - html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, - def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, - paragraph: /^([^\n]+\n?(?!body))+\n*/, + nptable: noop, + lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, + blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/, + list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, + html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/, + def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, + table: noop, + paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, text: /^[^\n]+/ }; -block.list = (function() { - var list = block.list.source; +block.bullet = /(?:[*+-]|\d+\.)/; +block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; +block.item = replace(block.item, 'gm') + (/bull/g, block.bullet) + (); + +block.list = replace(block.list) + (/bull/g, block.bullet) + ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))') + ('def', '\\n+(?=' + block.def.source + ')') + (); + +block.blockquote = replace(block.blockquote) + ('def', block.def) + (); + +block._tag = '(?!(?:' + + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' + + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' + + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b'; + +block.html = replace(block.html) + ('comment', //) + ('closed', /<(tag)[\s\S]+?<\/\1>/) + ('closing', /])*?>/) + (/tag/g, block._tag) + (); + +block.paragraph = replace(block.paragraph) + ('hr', block.hr) + ('heading', block.heading) + ('lheading', block.lheading) + ('blockquote', block.blockquote) + ('tag', '<' + block._tag) + ('def', block.def) + (); - list = list - .replace('bullet', /(?:[*+-](?!(?: *[-*]){2,})|\d+\.)/.source); - - return new RegExp(list); -})(); +/** + * Normal Block Grammar + */ -block.html = (function() { - var html = block.html.source; +block.normal = merge({}, block); - html = html - .replace('comment', //.source) - .replace('closed', /<(tag)[^\0]+?<\/\1>/.source) - .replace('closing', /])*?>/.source) - .replace(/tag/g, tag()); +/** + * GFM Block Grammar + */ - return new RegExp(html); -})(); +block.gfm = merge({}, block.normal, { + fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/, + paragraph: /^/, + heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ +}); -block.paragraph = (function() { - var paragraph = block.paragraph.source - , body = []; +block.gfm.paragraph = replace(block.paragraph) + ('(?!', '(?!' + + block.gfm.fences.source.replace('\\1', '\\2') + '|' + + block.list.source.replace('\\1', '\\3') + '|') + (); - (function push(rule) { - rule = block[rule] ? block[rule].source : rule; - body.push(rule.replace(/(^|[^\[])\^/g, '$1')); - return push; - }) - ('gfm_code') - ('hr') - ('heading') - ('lheading') - ('blockquote') - ('<' + tag()) - ('def'); +/** + * GFM + Tables Block Grammar + */ - return new - RegExp(paragraph.replace('body', body.join('|'))); -})(); +block.tables = merge({}, block.gfm, { + nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, + table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/ +}); /** * Block Lexer */ -block.lexer = function(src) { - var tokens = []; +function Lexer(options) { + this.tokens = []; + this.tokens.links = {}; + this.options = options || marked.defaults; + this.rules = block.normal; + + if (this.options.gfm) { + if (this.options.tables) { + this.rules = block.tables; + } else { + this.rules = block.gfm; + } + } +} + +/** + * Expose Block Rules + */ + +Lexer.rules = block; + +/** + * Static Lex Method + */ - tokens.links = {}; +Lexer.lex = function(src, options) { + var lexer = new Lexer(options); + return lexer.lex(src); +}; +/** + * Preprocessing + */ + +Lexer.prototype.lex = function(src) { src = src .replace(/\r\n|\r/g, '\n') - .replace(/\t/g, ' '); + .replace(/\t/g, ' ') + .replace(/\u00a0/g, ' ') + .replace(/\u2424/g, '\n'); - return block.token(src, tokens, true); + return this.token(src, true); }; -block.token = function(src, tokens, top) { +/** + * Lexing + */ + +Lexer.prototype.token = function(src, top, bq) { var src = src.replace(/^ +$/gm, '') , next , loose , cap + , bull + , b , item , space , i @@ -94,41 +161,43 @@ block.token = function(src, tokens, top) { while (src) { // newline - if (cap = block.newline.exec(src)) { + if (cap = this.rules.newline.exec(src)) { src = src.substring(cap[0].length); if (cap[0].length > 1) { - tokens.push({ + this.tokens.push({ type: 'space' }); } } // code - if (cap = block.code.exec(src)) { + if (cap = this.rules.code.exec(src)) { src = src.substring(cap[0].length); cap = cap[0].replace(/^ {4}/gm, ''); - tokens.push({ + this.tokens.push({ type: 'code', - text: cap.replace(/\n+$/, '') + text: !this.options.pedantic + ? cap.replace(/\n+$/, '') + : cap }); continue; } - // gfm_code - if (cap = block.gfm_code.exec(src)) { + // fences (gfm) + if (cap = this.rules.fences.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'code', - lang: cap[1], - text: cap[2] + lang: cap[2], + text: cap[3] || '' }); continue; } // heading - if (cap = block.heading.exec(src)) { + if (cap = this.rules.heading.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'heading', depth: cap[1].length, text: cap[2] @@ -136,10 +205,42 @@ block.token = function(src, tokens, top) { continue; } + // table no leading pipe (gfm) + if (top && (cap = this.rules.nptable.exec(src))) { + src = src.substring(cap[0].length); + + item = { + type: 'table', + header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + cells: cap[3].replace(/\n$/, '').split('\n') + }; + + for (i = 0; i < item.align.length; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + for (i = 0; i < item.cells.length; i++) { + item.cells[i] = item.cells[i].split(/ *\| */); + } + + this.tokens.push(item); + + continue; + } + // lheading - if (cap = block.lheading.exec(src)) { + if (cap = this.rules.lheading.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'heading', depth: cap[2] === '=' ? 1 : 2, text: cap[1] @@ -148,18 +249,19 @@ block.token = function(src, tokens, top) { } // hr - if (cap = block.hr.exec(src)) { + if (cap = this.rules.hr.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'hr' }); continue; } // blockquote - if (cap = block.blockquote.exec(src)) { + if (cap = this.rules.blockquote.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ + + this.tokens.push({ type: 'blockquote_start' }); @@ -168,27 +270,27 @@ block.token = function(src, tokens, top) { // Pass `top` to keep the current // "toplevel" state. This is exactly // how markdown.pl works. - block.token(cap, tokens, top); + this.token(cap, top, true); - tokens.push({ + this.tokens.push({ type: 'blockquote_end' }); + continue; } // list - if (cap = block.list.exec(src)) { + if (cap = this.rules.list.exec(src)) { src = src.substring(cap[0].length); + bull = cap[2]; - tokens.push({ + this.tokens.push({ type: 'list_start', - ordered: isFinite(cap[2]) + ordered: bull.length > 1 }); // Get each top-level item. - cap = cap[0].match( - /^( *)([*+-]|\d+\.)[^\n]*(?:\n(?!\1(?:[*+-]|\d+\.))[^\n]*)*/gm - ); + cap = cap[0].match(this.rules.item); next = false; l = cap.length; @@ -200,13 +302,25 @@ block.token = function(src, tokens, top) { // Remove the list item's bullet // so it is seen as the next token. space = item.length; - item = item.replace(/^ *([*+-]|\d+\.) */, ''); + item = item.replace(/^ *([*+-]|\d+\.) +/, ''); // Outdent whatever the // list item contains. Hacky. if (~item.indexOf('\n ')) { space -= item.length; - item = item.replace(new RegExp('^ {1,' + space + '}', 'gm'), ''); + item = !this.options.pedantic + ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '') + : item.replace(/^ {1,4}/gm, ''); + } + + // Determine whether the next list item belongs here. + // Backpedal if it does not belong in this list. + if (this.options.smartLists && i !== l - 1) { + b = block.bullet.exec(cap[i + 1])[0]; + if (bull !== b && !(bull.length > 1 && b.length > 1)) { + src = cap.slice(i + 1).join('\n') + src; + i = l - 1; + } } // Determine whether item is loose or not. @@ -214,25 +328,25 @@ block.token = function(src, tokens, top) { // for discount behavior. loose = next || /\n\n(?!\s*$)/.test(item); if (i !== l - 1) { - next = item[item.length-1] === '\n'; + next = item.charAt(item.length - 1) === '\n'; if (!loose) loose = next; } - tokens.push({ + this.tokens.push({ type: loose ? 'loose_item_start' : 'list_item_start' }); // Recurse. - block.token(item, tokens); + this.token(item, false, bq); - tokens.push({ + this.tokens.push({ type: 'list_item_end' }); } - tokens.push({ + this.tokens.push({ type: 'list_end' }); @@ -240,76 +354,213 @@ block.token = function(src, tokens, top) { } // html - if (cap = block.html.exec(src)) { + if (cap = this.rules.html.exec(src)) { src = src.substring(cap[0].length); - tokens.push({ - type: 'html', + this.tokens.push({ + type: this.options.sanitize + ? 'paragraph' + : 'html', + pre: !this.options.sanitizer + && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'), text: cap[0] }); continue; } // def - if (top && (cap = block.def.exec(src))) { + if ((!bq && top) && (cap = this.rules.def.exec(src))) { src = src.substring(cap[0].length); - tokens.links[cap[1].toLowerCase()] = { + this.tokens.links[cap[1].toLowerCase()] = { href: cap[2], title: cap[3] }; continue; } + // table (gfm) + if (top && (cap = this.rules.table.exec(src))) { + src = src.substring(cap[0].length); + + item = { + type: 'table', + header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') + }; + + for (i = 0; i < item.align.length; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + for (i = 0; i < item.cells.length; i++) { + item.cells[i] = item.cells[i] + .replace(/^ *\| *| *\| *$/g, '') + .split(/ *\| */); + } + + this.tokens.push(item); + + continue; + } + // top-level paragraph - if (top && (cap = block.paragraph.exec(src))) { + if (top && (cap = this.rules.paragraph.exec(src))) { src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'paragraph', - text: cap[0] + text: cap[1].charAt(cap[1].length - 1) === '\n' + ? cap[1].slice(0, -1) + : cap[1] }); continue; } // text - if (cap = block.text.exec(src)) { + if (cap = this.rules.text.exec(src)) { // Top-level should never reach here. src = src.substring(cap[0].length); - tokens.push({ + this.tokens.push({ type: 'text', text: cap[0] }); continue; } + + if (src) { + throw new + Error('Infinite loop on byte: ' + src.charCodeAt(0)); + } } - return tokens; + return this.tokens; }; /** - * Inline Processing + * Inline-Level Grammar */ var inline = { escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, - gfm_autolink: /^(\w+:\/\/[^\s]+[^.,:;"')\]\s])/, - tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, - link: /^!?\[((?:\[[^\]]*\]|[^\[\]]|\[|\](?=[^[\]]*\]))*)\]\(([^\)]*)\)/, - reflink: /^!?\[((?:\[[^\]]*\]|[^\[\]]|\[|\](?=[^[\]]*\]))*)\]\s*\[([^\]]*)\]/, + url: noop, + tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, + link: /^!?\[(inside)\]\(href\)/, + reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, - strong: /^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/, - em: /^\b_([^\0]+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/, - code: /^(`+)([^\0]*?[^`])\1(?!`)/, + strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, + em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, + code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/, br: /^ {2,}\n(?!\s*$)/, - text: /^[^\0]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/; + +inline.link = replace(inline.link) + ('inside', inline._inside) + ('href', inline._href) + (); + +inline.reflink = replace(inline.reflink) + ('inside', inline._inside) + (); + +/** + * Normal Inline Grammar + */ + +inline.normal = merge({}, inline); + +/** + * Pedantic Inline Grammar + */ + +inline.pedantic = merge({}, inline.normal, { + strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, + em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/ +}); + +/** + * GFM Inline Grammar + */ + +inline.gfm = merge({}, inline.normal, { + escape: replace(inline.escape)('])', '~|])')(), + url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/, + del: /^~~(?=\S)([\s\S]*?\S)~~/, + text: replace(inline.text) + (']|', '~]|') + ('|', '|https?://|') + () +}); + +/** + * GFM + Line Breaks Inline Grammar + */ + +inline.breaks = merge({}, inline.gfm, { + br: replace(inline.br)('{2,}', '*')(), + text: replace(inline.gfm.text)('{2,}', '*')() +}); + /** - * Inline Lexer + * Inline Lexer & Compiler */ -inline.lexer = function(src) { +function InlineLexer(links, options) { + this.options = options || marked.defaults; + this.links = links; + this.rules = inline.normal; + this.renderer = this.options.renderer || new Renderer; + this.renderer.options = this.options; + + if (!this.links) { + throw new + Error('Tokens array requires a `links` property.'); + } + + if (this.options.gfm) { + if (this.options.breaks) { + this.rules = inline.breaks; + } else { + this.rules = inline.gfm; + } + } else if (this.options.pedantic) { + this.rules = inline.pedantic; + } +} + +/** + * Expose Inline Rules + */ + +InlineLexer.rules = inline; + +/** + * Static Lexing/Compiling Method + */ + +InlineLexer.output = function(src, links, options) { + var inline = new InlineLexer(links, options); + return inline.output(src); +}; + +/** + * Lexing/Compiling + */ + +InlineLexer.prototype.output = function(src) { var out = '' - , links = tokens.links , link , text , href @@ -317,346 +568,718 @@ inline.lexer = function(src) { while (src) { // escape - if (cap = inline.escape.exec(src)) { + if (cap = this.rules.escape.exec(src)) { src = src.substring(cap[0].length); out += cap[1]; continue; } // autolink - if (cap = inline.autolink.exec(src)) { + if (cap = this.rules.autolink.exec(src)) { src = src.substring(cap[0].length); if (cap[2] === '@') { - text = cap[1][6] === ':' - ? mangle(cap[1].substring(7)) - : mangle(cap[1]); - href = mangle('mailto:') + text; + text = cap[1].charAt(6) === ':' + ? this.mangle(cap[1].substring(7)) + : this.mangle(cap[1]); + href = this.mangle('mailto:') + text; } else { text = escape(cap[1]); href = text; } - out += '' - + text - + ''; + out += this.renderer.link(href, null, text); continue; } - // gfm_autolink - if (cap = inline.gfm_autolink.exec(src)) { + // url (gfm) + if (!this.inLink && (cap = this.rules.url.exec(src))) { src = src.substring(cap[0].length); text = escape(cap[1]); href = text; - out += '' - + text - + ''; + out += this.renderer.link(href, null, text); continue; } // tag - if (cap = inline.tag.exec(src)) { + if (cap = this.rules.tag.exec(src)) { + if (!this.inLink && /^/i.test(cap[0])) { + this.inLink = false; + } src = src.substring(cap[0].length); - out += cap[0]; + out += this.options.sanitize + ? this.options.sanitizer + ? this.options.sanitizer(cap[0]) + : escape(cap[0]) + : cap[0] continue; } // link - if (cap = inline.link.exec(src)) { + if (cap = this.rules.link.exec(src)) { src = src.substring(cap[0].length); - text = /^\s*?(?:\s+"([^\n]+)")?\s*$/.exec(cap[2]); - if (!text) { - out += cap[0][0]; - src = cap[0].substring(1) + src; - continue; - } - out += outputLink(cap, { - href: text[1], - title: text[2] + this.inLink = true; + out += this.outputLink(cap, { + href: cap[2], + title: cap[3] }); + this.inLink = false; continue; } // reflink, nolink - if ((cap = inline.reflink.exec(src)) - || (cap = inline.nolink.exec(src))) { + if ((cap = this.rules.reflink.exec(src)) + || (cap = this.rules.nolink.exec(src))) { src = src.substring(cap[0].length); link = (cap[2] || cap[1]).replace(/\s+/g, ' '); - link = links[link.toLowerCase()]; + link = this.links[link.toLowerCase()]; if (!link || !link.href) { - out += cap[0][0]; + out += cap[0].charAt(0); src = cap[0].substring(1) + src; continue; } - out += outputLink(cap, link); + this.inLink = true; + out += this.outputLink(cap, link); + this.inLink = false; continue; } // strong - if (cap = inline.strong.exec(src)) { + if (cap = this.rules.strong.exec(src)) { src = src.substring(cap[0].length); - out += '' - + inline.lexer(cap[2] || cap[1]) - + ''; + out += this.renderer.strong(this.output(cap[2] || cap[1])); continue; } // em - if (cap = inline.em.exec(src)) { + if (cap = this.rules.em.exec(src)) { src = src.substring(cap[0].length); - out += '' - + inline.lexer(cap[2] || cap[1]) - + ''; + out += this.renderer.em(this.output(cap[2] || cap[1])); continue; } // code - if (cap = inline.code.exec(src)) { + if (cap = this.rules.code.exec(src)) { src = src.substring(cap[0].length); - out += '' - + escape(cap[2], true) - + ''; + out += this.renderer.codespan(escape(cap[2], true)); continue; } // br - if (cap = inline.br.exec(src)) { + if (cap = this.rules.br.exec(src)) { + src = src.substring(cap[0].length); + out += this.renderer.br(); + continue; + } + + // del (gfm) + if (cap = this.rules.del.exec(src)) { src = src.substring(cap[0].length); - out += '
    '; + out += this.renderer.del(this.output(cap[1])); continue; } // text - if (cap = inline.text.exec(src)) { + if (cap = this.rules.text.exec(src)) { src = src.substring(cap[0].length); - out += escape(cap[0]); + out += this.renderer.text(escape(this.smartypants(cap[0]))); continue; } + + if (src) { + throw new + Error('Infinite loop on byte: ' + src.charCodeAt(0)); + } + } + + return out; +}; + +/** + * Compile Link + */ + +InlineLexer.prototype.outputLink = function(cap, link) { + var href = escape(link.href) + , title = link.title ? escape(link.title) : null; + + return cap[0].charAt(0) !== '!' + ? this.renderer.link(href, title, this.output(cap[1])) + : this.renderer.image(href, title, escape(cap[1])); +}; + +/** + * Smartypants Transformations + */ + +InlineLexer.prototype.smartypants = function(text) { + if (!this.options.smartypants) return text; + return text + // em-dashes + .replace(/---/g, '\u2014') + // en-dashes + .replace(/--/g, '\u2013') + // opening singles + .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018') + // closing singles & apostrophes + .replace(/'/g, '\u2019') + // opening doubles + .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c') + // closing doubles + .replace(/"/g, '\u201d') + // ellipses + .replace(/\.{3}/g, '\u2026'); +}; + +/** + * Mangle Links + */ + +InlineLexer.prototype.mangle = function(text) { + if (!this.options.mangle) return text; + var out = '' + , l = text.length + , i = 0 + , ch; + + for (; i < l; i++) { + ch = text.charCodeAt(i); + if (Math.random() > 0.5) { + ch = 'x' + ch.toString(16); + } + out += '&#' + ch + ';'; + } + + return out; +}; + +/** + * Renderer + */ + +function Renderer(options) { + this.options = options || {}; +} + +Renderer.prototype.code = function(code, lang, escaped) { + if (this.options.highlight) { + var out = this.options.highlight(code, lang); + if (out != null && out !== code) { + escaped = true; + code = out; + } + } + + if (!lang) { + return '
    '
    +      + (escaped ? code : escape(code, true))
    +      + '\n
    '; + } + + return '
    '
    +    + (escaped ? code : escape(code, true))
    +    + '\n
    \n'; +}; + +Renderer.prototype.blockquote = function(quote) { + return '
    \n' + quote + '
    \n'; +}; + +Renderer.prototype.html = function(html) { + return html; +}; + +Renderer.prototype.heading = function(text, level, raw) { + return '' + + text + + '\n'; +}; + +Renderer.prototype.hr = function() { + return this.options.xhtml ? '
    \n' : '
    \n'; +}; + +Renderer.prototype.list = function(body, ordered) { + var type = ordered ? 'ol' : 'ul'; + return '<' + type + '>\n' + body + '\n'; +}; + +Renderer.prototype.listitem = function(text) { + return '
  • ' + text + '
  • \n'; +}; + +Renderer.prototype.paragraph = function(text) { + return '

    ' + text + '

    \n'; +}; + +Renderer.prototype.table = function(header, body) { + return '\n' + + '\n' + + header + + '\n' + + '\n' + + body + + '\n' + + '
    \n'; +}; + +Renderer.prototype.tablerow = function(content) { + return '\n' + content + '\n'; +}; + +Renderer.prototype.tablecell = function(content, flags) { + var type = flags.header ? 'th' : 'td'; + var tag = flags.align + ? '<' + type + ' style="text-align:' + flags.align + '">' + : '<' + type + '>'; + return tag + content + '\n'; +}; + +// span level renderer +Renderer.prototype.strong = function(text) { + return '' + text + ''; +}; + +Renderer.prototype.em = function(text) { + return '' + text + ''; +}; + +Renderer.prototype.codespan = function(text) { + return '' + text + ''; +}; + +Renderer.prototype.br = function() { + return this.options.xhtml ? '
    ' : '
    '; +}; + +Renderer.prototype.del = function(text) { + return '' + text + ''; +}; + +Renderer.prototype.link = function(href, title, text) { + if (this.options.sanitize) { + try { + var prot = decodeURIComponent(unescape(href)) + .replace(/[^\w:]/g, '') + .toLowerCase(); + } catch (e) { + return ''; + } + if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) { + return ''; + } + } + var out = '
    '; + return out; +}; +Renderer.prototype.image = function(href, title, text) { + var out = '' + text + '' : '>'; return out; }; -var outputLink = function(cap, link) { - if (cap[0][0] !== '!') { - return '' - + inline.lexer(cap[1]) - + ''; - } else { - return ''
-      + escape(cap[1])
-      + ''; +Renderer.prototype.text = function(text) { + return text; +}; + +/** + * Parsing & Compiling + */ + +function Parser(options) { + this.tokens = []; + this.token = null; + this.options = options || marked.defaults; + this.options.renderer = this.options.renderer || new Renderer; + this.renderer = this.options.renderer; + this.renderer.options = this.options; +} + +/** + * Static Parse Method + */ + +Parser.parse = function(src, options, renderer) { + var parser = new Parser(options, renderer); + return parser.parse(src); +}; + +/** + * Parse Loop + */ + +Parser.prototype.parse = function(src) { + this.inline = new InlineLexer(src.links, this.options, this.renderer); + this.tokens = src.reverse(); + + var out = ''; + while (this.next()) { + out += this.tok(); } + + return out; }; /** - * Parsing + * Next Token */ -var tokens - , token; +Parser.prototype.next = function() { + return this.token = this.tokens.pop(); +}; + +/** + * Preview Next Token + */ -var next = function() { - return token = tokens.pop(); +Parser.prototype.peek = function() { + return this.tokens[this.tokens.length - 1] || 0; }; -var tok = function() { - switch (token.type) { +/** + * Parse Text Tokens + */ + +Parser.prototype.parseText = function() { + var body = this.token.text; + + while (this.peek().type === 'text') { + body += '\n' + this.next().text; + } + + return this.inline.output(body); +}; + +/** + * Parse Current Token + */ + +Parser.prototype.tok = function() { + switch (this.token.type) { case 'space': { return ''; } case 'hr': { - return '
    \n'; + return this.renderer.hr(); } case 'heading': { - return '' - + inline.lexer(token.text) - + '\n'; + return this.renderer.heading( + this.inline.output(this.token.text), + this.token.depth, + this.token.text); } case 'code': { - return '
    '
    -        + (token.escaped
    -        ? token.text
    -        : escape(token.text, true))
    -        + '
    \n'; + return this.renderer.code(this.token.text, + this.token.lang, + this.token.escaped); + } + case 'table': { + var header = '' + , body = '' + , i + , row + , cell + , flags + , j; + + // header + cell = ''; + for (i = 0; i < this.token.header.length; i++) { + flags = { header: true, align: this.token.align[i] }; + cell += this.renderer.tablecell( + this.inline.output(this.token.header[i]), + { header: true, align: this.token.align[i] } + ); + } + header += this.renderer.tablerow(cell); + + for (i = 0; i < this.token.cells.length; i++) { + row = this.token.cells[i]; + + cell = ''; + for (j = 0; j < row.length; j++) { + cell += this.renderer.tablecell( + this.inline.output(row[j]), + { header: false, align: this.token.align[j] } + ); + } + + body += this.renderer.tablerow(cell); + } + return this.renderer.table(header, body); } case 'blockquote_start': { var body = ''; - while (next().type !== 'blockquote_end') { - body += tok(); + while (this.next().type !== 'blockquote_end') { + body += this.tok(); } - return '
    \n' - + body - + '
    \n'; + return this.renderer.blockquote(body); } case 'list_start': { - var type = token.ordered ? 'ol' : 'ul' - , body = ''; + var body = '' + , ordered = this.token.ordered; - while (next().type !== 'list_end') { - body += tok(); + while (this.next().type !== 'list_end') { + body += this.tok(); } - return '<' - + type - + '>\n' - + body - + '\n'; + return this.renderer.list(body, ordered); } case 'list_item_start': { var body = ''; - while (next().type !== 'list_item_end') { - body += token.type === 'text' - ? parseText() - : tok(); + while (this.next().type !== 'list_item_end') { + body += this.token.type === 'text' + ? this.parseText() + : this.tok(); } - return '
  • ' - + body - + '
  • \n'; + return this.renderer.listitem(body); } case 'loose_item_start': { var body = ''; - while (next().type !== 'list_item_end') { - body += tok(); + while (this.next().type !== 'list_item_end') { + body += this.tok(); } - return '
  • ' - + body - + '
  • \n'; + return this.renderer.listitem(body); } case 'html': { - return inline.lexer(token.text); + var html = !this.token.pre && !this.options.pedantic + ? this.inline.output(this.token.text) + : this.token.text; + return this.renderer.html(html); } case 'paragraph': { - return '

    ' - + inline.lexer(token.text) - + '

    \n'; + return this.renderer.paragraph(this.inline.output(this.token.text)); } case 'text': { - return '

    ' - + parseText() - + '

    \n'; + return this.renderer.paragraph(this.parseText()); } } }; -var parseText = function() { - var body = token.text - , top; - - while ((top = tokens[tokens.length-1]) - && top.type === 'text') { - body += '\n' + next().text; - } - - return inline.lexer(body); -}; - -var parse = function(src) { - tokens = src.reverse(); - - var out = ''; - while (next()) { - out += tok(); - } - - tokens = null; - token = null; - - return out; -}; - /** * Helpers */ -var escape = function(html, encode) { +function escape(html, encode) { return html .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); -}; +} -var mangle = function(text) { - var out = '' - , l = text.length - , i = 0 - , ch; +function unescape(html) { + return html.replace(/&([#\w]+);/g, function(_, n) { + n = n.toLowerCase(); + if (n === 'colon') return ':'; + if (n.charAt(0) === '#') { + return n.charAt(1) === 'x' + ? String.fromCharCode(parseInt(n.substring(2), 16)) + : String.fromCharCode(+n.substring(1)); + } + return ''; + }); +} - for (; i < l; i++) { - ch = text.charCodeAt(i); - if (Math.random() > 0.5) { - ch = 'x' + ch.toString(16); +function replace(regex, opt) { + regex = regex.source; + opt = opt || ''; + return function self(name, val) { + if (!name) return new RegExp(regex, opt); + val = val.source || val; + val = val.replace(/(^|[^\[])\^/g, '$1'); + regex = regex.replace(name, val); + return self; + }; +} + +function noop() {} +noop.exec = noop; + +function merge(obj) { + var i = 1 + , target + , key; + + for (; i < arguments.length; i++) { + target = arguments[i]; + for (key in target) { + if (Object.prototype.hasOwnProperty.call(target, key)) { + obj[key] = target[key]; + } } - out += '&#' + ch + ';'; } - return out; -}; + return obj; +} -function tag() { - var tag = '(?!(?:' - + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' - + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' - + '|span|br|wbr|ins|del|img)\\b)\\w+'; - return tag; +/** + * Marked + */ + +function marked(src, opt, callback) { + if (callback || typeof opt === 'function') { + if (!callback) { + callback = opt; + opt = null; + } + + opt = merge({}, marked.defaults, opt || {}); + + var highlight = opt.highlight + , tokens + , pending + , i = 0; + + try { + tokens = Lexer.lex(src, opt) + } catch (e) { + return callback(e); + } + + pending = tokens.length; + + var done = function(err) { + if (err) { + opt.highlight = highlight; + return callback(err); + } + + var out; + + try { + out = Parser.parse(tokens, opt); + } catch (e) { + err = e; + } + + opt.highlight = highlight; + + return err + ? callback(err) + : callback(null, out); + }; + + if (!highlight || highlight.length < 3) { + return done(); + } + + delete opt.highlight; + + if (!pending) return done(); + + for (; i < tokens.length; i++) { + (function(token) { + if (token.type !== 'code') { + return --pending || done(); + } + return highlight(token.text, token.lang, function(err, code) { + if (err) return done(err); + if (code == null || code === token.text) { + return --pending || done(); + } + token.text = code; + token.escaped = true; + --pending || done(); + }); + })(tokens[i]); + } + + return; + } + try { + if (opt) opt = merge({}, marked.defaults, opt); + return Parser.parse(Lexer.lex(src, opt), opt); + } catch (e) { + e.message += '\nPlease report this to https://github.com/chjj/marked.'; + if ((opt || marked.defaults).silent) { + return '

    An error occured:

    '
    +        + escape(e.message + '', true)
    +        + '
    '; + } + throw e; + } } /** - * Expose + * Options */ -var marked = function(src) { - return parse(block.lexer(src)); +marked.options = +marked.setOptions = function(opt) { + merge(marked.defaults, opt); + return marked; }; -marked.parser = parse; -marked.lexer = block.lexer; +marked.defaults = { + gfm: true, + tables: true, + breaks: false, + pedantic: false, + sanitize: false, + sanitizer: null, + mangle: true, + smartLists: false, + silent: false, + highlight: null, + langPrefix: 'lang-', + smartypants: false, + headerPrefix: '', + renderer: new Renderer, + xhtml: false +}; + +/** + * Expose + */ + +marked.Parser = Parser; +marked.parser = Parser.parse; + +marked.Renderer = Renderer; + +marked.Lexer = Lexer; +marked.lexer = Lexer.lex; + +marked.InlineLexer = InlineLexer; +marked.inlineLexer = InlineLexer.output; marked.parse = marked; -if (typeof module !== 'undefined') { +if (typeof module !== 'undefined' && typeof exports === 'object') { module.exports = marked; +} else if (typeof define === 'function' && define.amd) { + define(function() { return marked; }); } else { this.marked = marked; } -}).call(this); +}).call(function() { + return this || (typeof window !== 'undefined' ? window : global); +}()); diff --git a/tools/doc/node_modules/marked/man/marked.1 b/tools/doc/node_modules/marked/man/marked.1 index 214533390ce41a..b9bdc8c2123e3b 100644 --- a/tools/doc/node_modules/marked/man/marked.1 +++ b/tools/doc/node_modules/marked/man/marked.1 @@ -1,39 +1,91 @@ .ds q \N'34' -.TH marked 1 +.TH marked 1 "2014-01-31" "v0.3.1" "marked.js" + .SH NAME marked \- a javascript markdown parser + .SH SYNOPSIS -.nf -.B marked [\-o output] [\-i input] [\-th] -.fi +.B marked +[\-o \fI\fP] [\-i \fI\fP] [\-\-help] +[\-\-tokens] [\-\-pedantic] [\-\-gfm] +[\-\-breaks] [\-\-tables] [\-\-sanitize] +[\-\-smart\-lists] [\-\-lang\-prefix \fI\fP] +[\-\-no\-etc...] [\-\-silent] [\fIfilename\fP] + .SH DESCRIPTION .B marked is a full-featured javascript markdown parser, built for speed. It also includes multiple GFM features. + +.SH EXAMPLES +.TP +cat in.md | marked > out.html +.TP +echo "hello *world*" | marked +.TP +marked \-o out.html in.md \-\-gfm +.TP +marked \-\-output="hello world.html" \-i in.md \-\-no-breaks + .SH OPTIONS .TP -.BI \-o,\ \-\-output\ [output] +.BI \-o,\ \-\-output\ [\fIoutput\fP] Specify file output. If none is specified, write to stdout. .TP -.BI \-i,\ \-\-input\ [input] +.BI \-i,\ \-\-input\ [\fIinput\fP] Specify file input, otherwise use last argument as input file. If no input file is specified, read from stdin. .TP .BI \-t,\ \-\-tokens Output a token stream instead of html. .TP -.BI \-h,\ \-\-help -Display help information. -.SH EXAMPLES +.BI \-\-pedantic +Conform to obscure parts of markdown.pl as much as possible. Don't fix original +markdown bugs. .TP -cat in.md | marked > out.html +.BI \-\-gfm +Enable github flavored markdown. .TP -echo "hello *world*" | marked +.BI \-\-breaks +Enable GFM line breaks. Only works with the gfm option. +.TP +.BI \-\-tables +Enable GFM tables. Only works with the gfm option. +.TP +.BI \-\-sanitize +Sanitize output. Ignore any HTML input. +.TP +.BI \-\-smart\-lists +Use smarter list behavior than the original markdown. .TP -marked -o out.html in.md +.BI \-\-lang\-prefix\ [\fIprefix\fP] +Set the prefix for code block classes. .TP -marked --output="hello world.html" -i in.md +.BI \-\-mangle +Mangle email addresses. +.TP +.BI \-\-no\-sanitize,\ \-no-etc... +The inverse of any of the marked options above. +.TP +.BI \-\-silent +Silence error output. +.TP +.BI \-h,\ \-\-help +Display help information. + +.SH CONFIGURATION +For configuring and running programmatically. + +.B Example + + require('marked')('*foo*', { gfm: true }); + .SH BUGS Please report any bugs to https://github.com/chjj/marked. + .SH LICENSE -Copyright (c) 2011-2012, Christopher Jeffrey (MIT License) +Copyright (c) 2011-2014, Christopher Jeffrey (MIT License). + +.SH "SEE ALSO" +.BR markdown(1), +.BR node.js(1) diff --git a/tools/doc/node_modules/marked/marked.min.js b/tools/doc/node_modules/marked/marked.min.js new file mode 100644 index 00000000000000..555c1dc1d9da18 --- /dev/null +++ b/tools/doc/node_modules/marked/marked.min.js @@ -0,0 +1,6 @@ +/** + * marked - a markdown parser + * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) + * https://github.com/chjj/marked + */ +(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
    "+(escaped?code:escape(code,true))+"\n
    "}return'
    '+(escaped?code:escape(code,true))+"\n
    \n"};Renderer.prototype.blockquote=function(quote){return"
    \n"+quote+"
    \n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file diff --git a/tools/doc/node_modules/marked/package.json b/tools/doc/node_modules/marked/package.json index f47a9e12530731..d631092cb80f42 100644 --- a/tools/doc/node_modules/marked/package.json +++ b/tools/doc/node_modules/marked/package.json @@ -1,15 +1,95 @@ { - "name": "marked", + "_args": [ + [ + "marked", + "/Users/firedfox/git/node/tools/doc" + ] + ], + "_from": "marked@latest", + "_id": "marked@0.3.5", + "_inCache": true, + "_installable": true, + "_location": "/marked", + "_nodeVersion": "0.12.7", + "_npmUser": { + "email": "chjjeffrey@gmail.com", + "name": "chjj" + }, + "_npmVersion": "2.13.2", + "_phantomChildren": {}, + "_requested": { + "name": "marked", + "raw": "marked", + "rawSpec": "", + "scope": null, + "spec": "latest", + "type": "tag" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/marked/-/marked-0.3.5.tgz", + "_shasum": "4113a15ac5d7bca158a5aae07224587b9fa15b94", + "_shrinkwrap": null, + "_spec": "marked", + "_where": "/Users/firedfox/git/node/tools/doc", + "author": { + "name": "Christopher Jeffrey" + }, + "bin": { + "marked": "./bin/marked" + }, + "bugs": { + "url": "http://github.com/chjj/marked/issues" + }, + "dependencies": {}, "description": "A markdown parser built for speed", - "author": "Christopher Jeffrey", - "version": "0.1.9", - "main": "./lib/marked.js", - "bin": "./bin/marked", - "man": "./man/marked.1", - "preferGlobal": false, - "repository": "git://github.com/chjj/marked.git", + "devDependencies": { + "gulp": "^3.8.11", + "gulp-concat": "^2.5.2", + "gulp-uglify": "^1.1.0", + "markdown": "*", + "showdown": "*" + }, + "directories": {}, + "dist": { + "shasum": "4113a15ac5d7bca158a5aae07224587b9fa15b94", + "tarball": "https://registry.npmjs.org/marked/-/marked-0.3.5.tgz" + }, + "gitHead": "88ce4df47c4d994dc1b1df1477a21fb893e11ddc", "homepage": "https://github.com/chjj/marked", - "bugs": "http://github.com/chjj/marked/issues", - "keywords": [ "markdown", "markup", "html" ], - "tags": [ "markdown", "markup", "html" ] + "keywords": [ + "markdown", + "markup", + "html" + ], + "license": "MIT", + "main": "./lib/marked.js", + "maintainers": [ + { + "email": "chjjeffrey@gmail.com", + "name": "chjj" + } + ], + "man": [ + "./man/marked.1" + ], + "name": "marked", + "optionalDependencies": {}, + "preferGlobal": true, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/chjj/marked.git" + }, + "scripts": { + "bench": "node test --bench", + "test": "node test" + }, + "tags": [ + "markdown", + "markup", + "html" + ], + "version": "0.3.5" } diff --git a/tools/doc/package.json b/tools/doc/package.json index 0dda4b971cf14f..41a50ac04ed188 100644 --- a/tools/doc/package.json +++ b/tools/doc/package.json @@ -7,7 +7,7 @@ "node": ">=0.6.10" }, "dependencies": { - "marked": "~0.1.9", + "marked": "^0.3.5", "js-yaml": "^3.5.2" }, "devDependencies": {}, From 8b88c384f06c15e911e042105ddff518bb47749f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 4 May 2016 22:20:27 -0700 Subject: [PATCH 241/261] tools: lint for object literal spacing There has been occasional nits for spacing in object literals in PRs but the project does not lint for it and it is not always handled consistently in the existing code, even on adjacent lines of a file. This change enables a linting rule requiring no space between the key and the colon, and requiring at least one space (but allowing for more so property values can be lined up if desired) between the colon and the value. This appears to be the most common style used in the current code base. Example code the complies with lint rule: myObj = { foo: 'bar' }; Examples that do not comply with the lint rule: myObj = { foo : 'bar' }; myObj = { foo:'bar' }; PR-URL: https://github.com/nodejs/node/pull/6592 Reviewed-By: James M Snell Reviewed-By: Brian White --- .eslintrc | 1 + benchmark/path/format.js | 10 +- lib/_http_server.js | 122 +++++++++--------- lib/util.js | 26 ++-- test/doctool/test-doctool-json.js | 10 +- test/parallel/test-console.js | 4 +- test/parallel/test-crypto-binary-default.js | 8 +- test/parallel/test-crypto.js | 8 +- test/parallel/test-domain-http-server.js | 2 +- ...st-domain-top-level-error-handler-throw.js | 2 +- test/parallel/test-fs-realpath.js | 12 +- test/parallel/test-http-chunk-problem.js | 2 +- test/parallel/test-http-client-pipe-end.js | 2 +- ...ient-reject-chunked-with-content-length.js | 2 +- .../test-http-client-reject-cr-no-lf.js | 2 +- .../test-http-client-response-domain.js | 2 +- .../test-http-client-timeout-with-data.js | 2 +- test/parallel/test-http-expect-continue.js | 4 +- .../test-http-remove-header-stays-removed.js | 2 +- ...test-http-response-multi-content-length.js | 2 +- test/parallel/test-http-response-splitting.js | 4 +- .../parallel/test-http-server-multiheaders.js | 2 +- .../test-http-server-multiheaders2.js | 2 +- .../test-http-server-reject-cr-no-lf.js | 2 +- test/parallel/test-listen-fd-ebadf.js | 4 +- test/parallel/test-net-listen-fd0.js | 2 +- .../test-stream-transform-split-objectmode.js | 8 +- test/parallel/test-stream2-transform.js | 2 +- test/parallel/test-tls-alert.js | 2 +- test/parallel/test-url.js | 8 +- test/parallel/test-util.js | 14 +- test/parallel/test-vm-context.js | 2 +- test/pummel/test-crypto-dh.js | 16 +-- test/pummel/test-fs-watch-file-slow.js | 2 +- test/sequential/test-fs-watch.js | 2 +- tools/doc/html.js | 4 +- 36 files changed, 151 insertions(+), 150 deletions(-) diff --git a/.eslintrc b/.eslintrc index 59f9f06e8baa0d..ffb768217805b9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -57,6 +57,7 @@ rules: comma-spacing: 2 eol-last: 2 indent: [2, 2, {SwitchCase: 1}] + key-spacing: [2, {mode: "minimum"}] keyword-spacing: 2 max-len: [2, 80, 2] new-parens: 2 diff --git a/benchmark/path/format.js b/benchmark/path/format.js index 478a30cbaedbd2..6c6f2106dd3fb7 100644 --- a/benchmark/path/format.js +++ b/benchmark/path/format.js @@ -18,11 +18,11 @@ function main(conf) { ext: '.html', name: 'index' } : { - root : '/', - dir : '/home/user/dir', - base : 'index.html', - ext : '.html', - name : 'index' + root: '/', + dir: '/home/user/dir', + base: 'index.html', + ext: '.html', + name: 'index' }; // Force optimization before starting the benchmark diff --git a/lib/_http_server.js b/lib/_http_server.js index 399f9d49e1d4b0..827c9c346cb708 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -16,67 +16,67 @@ const httpSocketSetup = common.httpSocketSetup; const OutgoingMessage = require('_http_outgoing').OutgoingMessage; const STATUS_CODES = exports.STATUS_CODES = { - 100 : 'Continue', - 101 : 'Switching Protocols', - 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 - 200 : 'OK', - 201 : 'Created', - 202 : 'Accepted', - 203 : 'Non-Authoritative Information', - 204 : 'No Content', - 205 : 'Reset Content', - 206 : 'Partial Content', - 207 : 'Multi-Status', // RFC 4918 - 208 : 'Already Reported', - 226 : 'IM Used', - 300 : 'Multiple Choices', - 301 : 'Moved Permanently', - 302 : 'Found', - 303 : 'See Other', - 304 : 'Not Modified', - 305 : 'Use Proxy', - 307 : 'Temporary Redirect', - 308 : 'Permanent Redirect', // RFC 7238 - 400 : 'Bad Request', - 401 : 'Unauthorized', - 402 : 'Payment Required', - 403 : 'Forbidden', - 404 : 'Not Found', - 405 : 'Method Not Allowed', - 406 : 'Not Acceptable', - 407 : 'Proxy Authentication Required', - 408 : 'Request Timeout', - 409 : 'Conflict', - 410 : 'Gone', - 411 : 'Length Required', - 412 : 'Precondition Failed', - 413 : 'Payload Too Large', - 414 : 'URI Too Long', - 415 : 'Unsupported Media Type', - 416 : 'Range Not Satisfiable', - 417 : 'Expectation Failed', - 418 : 'I\'m a teapot', // RFC 2324 - 421 : 'Misdirected Request', - 422 : 'Unprocessable Entity', // RFC 4918 - 423 : 'Locked', // RFC 4918 - 424 : 'Failed Dependency', // RFC 4918 - 425 : 'Unordered Collection', // RFC 4918 - 426 : 'Upgrade Required', // RFC 2817 - 428 : 'Precondition Required', // RFC 6585 - 429 : 'Too Many Requests', // RFC 6585 - 431 : 'Request Header Fields Too Large', // RFC 6585 - 500 : 'Internal Server Error', - 501 : 'Not Implemented', - 502 : 'Bad Gateway', - 503 : 'Service Unavailable', - 504 : 'Gateway Timeout', - 505 : 'HTTP Version Not Supported', - 506 : 'Variant Also Negotiates', // RFC 2295 - 507 : 'Insufficient Storage', // RFC 4918 - 508 : 'Loop Detected', - 509 : 'Bandwidth Limit Exceeded', - 510 : 'Not Extended', // RFC 2774 - 511 : 'Network Authentication Required' // RFC 6585 + 100: 'Continue', + 101: 'Switching Protocols', + 102: 'Processing', // RFC 2518, obsoleted by RFC 4918 + 200: 'OK', + 201: 'Created', + 202: 'Accepted', + 203: 'Non-Authoritative Information', + 204: 'No Content', + 205: 'Reset Content', + 206: 'Partial Content', + 207: 'Multi-Status', // RFC 4918 + 208: 'Already Reported', + 226: 'IM Used', + 300: 'Multiple Choices', + 301: 'Moved Permanently', + 302: 'Found', + 303: 'See Other', + 304: 'Not Modified', + 305: 'Use Proxy', + 307: 'Temporary Redirect', + 308: 'Permanent Redirect', // RFC 7238 + 400: 'Bad Request', + 401: 'Unauthorized', + 402: 'Payment Required', + 403: 'Forbidden', + 404: 'Not Found', + 405: 'Method Not Allowed', + 406: 'Not Acceptable', + 407: 'Proxy Authentication Required', + 408: 'Request Timeout', + 409: 'Conflict', + 410: 'Gone', + 411: 'Length Required', + 412: 'Precondition Failed', + 413: 'Payload Too Large', + 414: 'URI Too Long', + 415: 'Unsupported Media Type', + 416: 'Range Not Satisfiable', + 417: 'Expectation Failed', + 418: 'I\'m a teapot', // RFC 2324 + 421: 'Misdirected Request', + 422: 'Unprocessable Entity', // RFC 4918 + 423: 'Locked', // RFC 4918 + 424: 'Failed Dependency', // RFC 4918 + 425: 'Unordered Collection', // RFC 4918 + 426: 'Upgrade Required', // RFC 2817 + 428: 'Precondition Required', // RFC 6585 + 429: 'Too Many Requests', // RFC 6585 + 431: 'Request Header Fields Too Large', // RFC 6585 + 500: 'Internal Server Error', + 501: 'Not Implemented', + 502: 'Bad Gateway', + 503: 'Service Unavailable', + 504: 'Gateway Timeout', + 505: 'HTTP Version Not Supported', + 506: 'Variant Also Negotiates', // RFC 2295 + 507: 'Insufficient Storage', // RFC 4918 + 508: 'Loop Detected', + 509: 'Bandwidth Limit Exceeded', + 510: 'Not Extended', // RFC 2774 + 511: 'Network Authentication Required' // RFC 6585 }; const kOnExecute = HTTPParser.kOnExecute | 0; diff --git a/lib/util.js b/lib/util.js index 79fdb33326ebc9..cd643c3120714a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -147,19 +147,19 @@ exports.inspect = inspect; // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics inspect.colors = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'inverse' : [7, 27], - 'white' : [37, 39], - 'grey' : [90, 39], - 'black' : [30, 39], - 'blue' : [34, 39], - 'cyan' : [36, 39], - 'green' : [32, 39], - 'magenta' : [35, 39], - 'red' : [31, 39], - 'yellow' : [33, 39] + 'bold': [1, 22], + 'italic': [3, 23], + 'underline': [4, 24], + 'inverse': [7, 27], + 'white': [37, 39], + 'grey': [90, 39], + 'black': [30, 39], + 'blue': [34, 39], + 'cyan': [36, 39], + 'green': [32, 39], + 'magenta': [35, 39], + 'red': [31, 39], + 'yellow': [33, 39] }; // Don't use 'blue' not visible on cmd.exe diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index f57fcd94752871..79cf4ce3c3ed47 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -17,7 +17,7 @@ var testData = [ 'source': 'foo', 'modules': [ { 'textRaw': 'Sample Markdown', 'name': 'sample_markdown', - 'modules': [ { 'textRaw':'Seussian Rhymes', + 'modules': [ { 'textRaw': 'Seussian Rhymes', 'name': 'seussian_rhymes', 'desc': '
      \n
    1. fish
    2. \n
    3. fish

      \n
    4. \n
    5. ' + '

      Red fish

      \n
    6. \n
    7. Blue fish
    8. \n
    \n', @@ -32,7 +32,7 @@ var testData = [ { 'file': common.fixturesDir + '/order_of_end_tags_5873.md', 'json': { - 'source':'foo', + 'source': 'foo', 'modules': [ { 'textRaw': 'Title', 'name': 'title', @@ -41,8 +41,8 @@ var testData = [ 'name': 'subsection', 'classMethods': [ { 'textRaw': 'Class Method: Buffer.from(array)', - 'type':'classMethod', - 'name':'from', + 'type': 'classMethod', + 'name': 'from', 'signatures': [ { 'params': [ { 'textRaw': '`array` {Array} ', @@ -51,7 +51,7 @@ var testData = [ } ] }, { - 'params' : [ { + 'params': [ { 'name': 'array' } ] } diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index 5f908442339e03..a396bda8cd3350 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -37,8 +37,8 @@ console.log(custom_inspect); // test console.dir() console.dir(custom_inspect); console.dir(custom_inspect, { showHidden: false }); -console.dir({ foo : { bar : { baz : true } } }, { depth: 0 }); -console.dir({ foo : { bar : { baz : true } } }, { depth: 1 }); +console.dir({ foo: { bar: { baz: true } } }, { depth: 0 }); +console.dir({ foo: { bar: { baz: true } } }, { depth: 1 }); // test console.trace() console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo'); diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js index 129bbcacef151e..da29d690645683 100644 --- a/test/parallel/test-crypto-binary-default.js +++ b/test/parallel/test-crypto-binary-default.js @@ -30,19 +30,19 @@ var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', // PFX tests assert.doesNotThrow(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'sample'}); }); assert.throws(function() { - tls.createSecureContext({pfx:certPfx}); + tls.createSecureContext({pfx: certPfx}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'test'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:'sample', passphrase:'test'}); + tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); }, 'not enough data'); // Test HMAC diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index 271541d54a242d..bf87900875b7c4 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -32,19 +32,19 @@ assert.throws(function() { // PFX tests assert.doesNotThrow(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'sample'}); }); assert.throws(function() { - tls.createSecureContext({pfx:certPfx}); + tls.createSecureContext({pfx: certPfx}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:certPfx, passphrase:'test'}); + tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); }, 'mac verify failure'); assert.throws(function() { - tls.createSecureContext({pfx:'sample', passphrase:'test'}); + tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); }, 'not enough data'); diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 37dbc30f4234d7..594c34aae8d201 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -20,7 +20,7 @@ var server = http.createServer(function(req, res) { serverCaught++; console.log('horray! got a server error', er); // try to send a 500. If that fails, oh well. - res.writeHead(500, {'content-type':'text/plain'}); + res.writeHead(500, {'content-type': 'text/plain'}); res.end(er.stack || er.message || 'Unknown error'); }); diff --git a/test/parallel/test-domain-top-level-error-handler-throw.js b/test/parallel/test-domain-top-level-error-handler-throw.js index 4bde30d17cb8c8..7933c5d052fe11 100644 --- a/test/parallel/test-domain-top-level-error-handler-throw.js +++ b/test/parallel/test-domain-top-level-error-handler-throw.js @@ -29,7 +29,7 @@ if (process.argv[2] === 'child') { var fork = require('child_process').fork; var assert = require('assert'); - var child = fork(process.argv[1], ['child'], {silent:true}); + var child = fork(process.argv[1], ['child'], {silent: true}); var stderrOutput = ''; if (child) { child.stderr.on('data', function onStderrData(data) { diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index d627c01487c2c2..46fbbd85877a81 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -464,12 +464,12 @@ function test_lying_cache_liar(cb) { // this should not require *any* stat calls, since everything // checked by realpath will be found in the cache. console.log('test_lying_cache_liar'); - var cache = { '/foo/bar/baz/bluff' : '/foo/bar/bluff', - '/1/2/3/4/5/6/7' : '/1', - '/a' : '/a', - '/a/b' : '/a/b', - '/a/b/c' : '/a/b', - '/a/b/d' : '/a/b/d' }; + var cache = { '/foo/bar/baz/bluff': '/foo/bar/bluff', + '/1/2/3/4/5/6/7': '/1', + '/a': '/a', + '/a/b': '/a/b', + '/a/b/c': '/a/b', + '/a/b/d': '/a/b/d' }; if (common.isWindows) { var wc = {}; Object.keys(cache).forEach(function(k) { diff --git a/test/parallel/test-http-chunk-problem.js b/test/parallel/test-http-chunk-problem.js index 26df0b95e29572..23ec2d0263fa94 100644 --- a/test/parallel/test-http-chunk-problem.js +++ b/test/parallel/test-http-chunk-problem.js @@ -11,7 +11,7 @@ if (process.argv[2] === 'request') { const http = require('http'); const options = { port: common.PORT, - path : '/' + path: '/' }; http.get(options, (res) => { diff --git a/test/parallel/test-http-client-pipe-end.js b/test/parallel/test-http-client-pipe-end.js index 715f8ccf79df92..5b2db49435a1b6 100644 --- a/test/parallel/test-http-client-pipe-end.js +++ b/test/parallel/test-http-client-pipe-end.js @@ -18,7 +18,7 @@ common.refreshTmpDir(); server.listen(common.PIPE, function() { var req = http.request({ socketPath: common.PIPE, - headers: {'Content-Length':'1'}, + headers: {'Content-Length': '1'}, method: 'POST', path: '/' }); diff --git a/test/parallel/test-http-client-reject-chunked-with-content-length.js b/test/parallel/test-http-client-reject-chunked-with-content-length.js index a6639c90690da3..400a1d0ddbb991 100644 --- a/test/parallel/test-http-client-reject-chunked-with-content-length.js +++ b/test/parallel/test-http-client-reject-chunked-with-content-length.js @@ -17,7 +17,7 @@ server.listen(common.PORT, () => { // The callback should not be called because the server is sending // both a Content-Length header and a Transfer-Encoding: chunked // header, which is a violation of the HTTP spec. - const req = http.get({port:common.PORT}, (res) => { + const req = http.get({port: common.PORT}, (res) => { assert.fail(null, null, 'callback should not be called'); }); req.on('error', common.mustCall((err) => { diff --git a/test/parallel/test-http-client-reject-cr-no-lf.js b/test/parallel/test-http-client-reject-cr-no-lf.js index b60220cbb629b3..350d7f40e95b9b 100644 --- a/test/parallel/test-http-client-reject-cr-no-lf.js +++ b/test/parallel/test-http-client-reject-cr-no-lf.js @@ -16,7 +16,7 @@ const server = net.createServer((socket) => { server.listen(common.PORT, () => { // The callback should not be called because the server is sending a // header field that ends only in \r with no following \n - const req = http.get({port:common.PORT}, (res) => { + const req = http.get({port: common.PORT}, (res) => { assert.fail(null, null, 'callback should not be called'); }); req.on('error', common.mustCall((err) => { diff --git a/test/parallel/test-http-client-response-domain.js b/test/parallel/test-http-client-response-domain.js index 59b95144867538..3034b1087e4d33 100644 --- a/test/parallel/test-http-client-response-domain.js +++ b/test/parallel/test-http-client-response-domain.js @@ -34,7 +34,7 @@ function test() { var req = http.get({ socketPath: common.PIPE, - headers: {'Content-Length':'1'}, + headers: {'Content-Length': '1'}, method: 'POST', path: '/' }); diff --git a/test/parallel/test-http-client-timeout-with-data.js b/test/parallel/test-http-client-timeout-with-data.js index 673908fe6d465f..2fff91227d1984 100644 --- a/test/parallel/test-http-client-timeout-with-data.js +++ b/test/parallel/test-http-client-timeout-with-data.js @@ -19,7 +19,7 @@ const options = { }; const server = http.createServer(function(req, res) { - res.writeHead(200, {'Content-Length':'2'}); + res.writeHead(200, {'Content-Length': '2'}); res.write('*'); setTimeout(function() { res.end('*'); }, common.platformTimeout(100)); }); diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js index 84c7d473efa108..247346a9ec81a4 100644 --- a/test/parallel/test-http-expect-continue.js +++ b/test/parallel/test-http-expect-continue.js @@ -13,8 +13,8 @@ function handler(req, res) { assert.equal(sent_continue, true, 'Full response sent before 100 Continue'); console.error('Server sending full response...'); res.writeHead(200, { - 'Content-Type' : 'text/plain', - 'ABCD' : '1' + 'Content-Type': 'text/plain', + 'ABCD': '1' }); res.end(test_res_body); } diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 904b8210103ebf..20390ffb2060d6 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -30,7 +30,7 @@ process.on('exit', function() { server.listen(common.PORT, function() { http.get({ port: common.PORT }, function(res) { assert.equal(200, res.statusCode); - assert.deepEqual(res.headers, { date : 'coffee o clock' }); + assert.deepStrictEqual(res.headers, { date: 'coffee o clock' }); res.setEncoding('ascii'); res.on('data', function(chunk) { diff --git a/test/parallel/test-http-response-multi-content-length.js b/test/parallel/test-http-response-multi-content-length.js index 4b0f2c11e3e901..8c03332fb2b7d2 100644 --- a/test/parallel/test-http-response-multi-content-length.js +++ b/test/parallel/test-http-response-multi-content-length.js @@ -33,7 +33,7 @@ server.listen(common.PORT, common.mustCall(() => { // case, the error handler must be called because the client // is not allowed to accept multiple content-length headers. http.get( - {port:common.PORT, headers:{'x-num': n}}, + {port: common.PORT, headers: {'x-num': n}}, (res) => { assert(false, 'client allowed multiple content-length headers.'); } diff --git a/test/parallel/test-http-response-splitting.js b/test/parallel/test-http-response-splitting.js index 4c954bf90acc7e..3675f8182d21a5 100644 --- a/test/parallel/test-http-response-splitting.js +++ b/test/parallel/test-http-response-splitting.js @@ -29,12 +29,12 @@ const server = http.createServer((req, res) => { break; case 1: assert.throws(common.mustCall(() => { - res.writeHead(200, {'foo' : x}); + res.writeHead(200, {'foo': x}); })); break; case 2: assert.throws(common.mustCall(() => { - res.writeHead(200, {'foo' : y}); + res.writeHead(200, {'foo': y}); })); break; default: diff --git a/test/parallel/test-http-server-multiheaders.js b/test/parallel/test-http-server-multiheaders.js index 99d72988479928..132f3fc1ea047f 100644 --- a/test/parallel/test-http-server-multiheaders.js +++ b/test/parallel/test-http-server-multiheaders.js @@ -18,7 +18,7 @@ var srv = http.createServer(function(req, res) { assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz'); assert.equal(req.headers['constructor'], 'foo, bar, baz'); - res.writeHead(200, {'Content-Type' : 'text/plain'}); + res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('EOF'); srv.close(); diff --git a/test/parallel/test-http-server-multiheaders2.js b/test/parallel/test-http-server-multiheaders2.js index bf54af3465319e..80cc3416d60dae 100644 --- a/test/parallel/test-http-server-multiheaders2.js +++ b/test/parallel/test-http-server-multiheaders2.js @@ -58,7 +58,7 @@ var srv = http.createServer(function(req, res) { 'foo, bar', 'header parsed incorrectly: ' + header); }); - res.writeHead(200, {'Content-Type' : 'text/plain'}); + res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('EOF'); srv.close(); diff --git a/test/parallel/test-http-server-reject-cr-no-lf.js b/test/parallel/test-http-server-reject-cr-no-lf.js index fbb89f0ff3004d..9245dc2de54999 100644 --- a/test/parallel/test-http-server-reject-cr-no-lf.js +++ b/test/parallel/test-http-server-reject-cr-no-lf.js @@ -20,7 +20,7 @@ server.on('clientError', common.mustCall((err) => { server.close(); })); server.listen(common.PORT, () => { - const client = net.connect({port:common.PORT}, () => { + const client = net.connect({port: common.PORT}, () => { client.on('data', (chunk) => { assert.fail(null, null, 'this should not be called'); }); diff --git a/test/parallel/test-listen-fd-ebadf.js b/test/parallel/test-listen-fd-ebadf.js index 51e09a7907f18e..452eb7e14046d5 100644 --- a/test/parallel/test-listen-fd-ebadf.js +++ b/test/parallel/test-listen-fd-ebadf.js @@ -9,8 +9,8 @@ process.on('exit', function() { assert.equal(gotError, 2); }); -net.createServer(common.fail).listen({fd:2}).on('error', onError); -net.createServer(common.fail).listen({fd:42}).on('error', onError); +net.createServer(common.fail).listen({fd: 2}).on('error', onError); +net.createServer(common.fail).listen({fd: 42}).on('error', onError); function onError(ex) { assert.equal(ex.code, 'EINVAL'); diff --git a/test/parallel/test-net-listen-fd0.js b/test/parallel/test-net-listen-fd0.js index 1a6c4716eb6178..b484c6306f8463 100644 --- a/test/parallel/test-net-listen-fd0.js +++ b/test/parallel/test-net-listen-fd0.js @@ -10,7 +10,7 @@ process.on('exit', function() { }); // this should fail with an async EINVAL error, not throw an exception -net.createServer(common.fail).listen({fd:0}).on('error', function(e) { +net.createServer(common.fail).listen({fd: 0}).on('error', function(e) { switch (e.code) { case 'EINVAL': case 'ENOTSOCK': diff --git a/test/parallel/test-stream-transform-split-objectmode.js b/test/parallel/test-stream-transform-split-objectmode.js index 4e33028da2f7de..9d1b01c01b5f47 100644 --- a/test/parallel/test-stream-transform-split-objectmode.js +++ b/test/parallel/test-stream-transform-split-objectmode.js @@ -4,7 +4,7 @@ var assert = require('assert'); var Transform = require('stream').Transform; -var parser = new Transform({ readableObjectMode : true }); +var parser = new Transform({ readableObjectMode: true }); assert(parser._readableState.objectMode); assert(!parser._writableState.objectMode); @@ -12,7 +12,7 @@ assert(parser._readableState.highWaterMark === 16); assert(parser._writableState.highWaterMark === (16 * 1024)); parser._transform = function(chunk, enc, callback) { - callback(null, { val : chunk[0] }); + callback(null, { val: chunk[0] }); }; var parsed; @@ -28,7 +28,7 @@ process.on('exit', function() { }); -var serializer = new Transform({ writableObjectMode : true }); +var serializer = new Transform({ writableObjectMode: true }); assert(!serializer._readableState.objectMode); assert(serializer._writableState.objectMode); @@ -45,7 +45,7 @@ serializer.on('data', function(chunk) { serialized = chunk; }); -serializer.write({ val : 42 }); +serializer.write({ val: 42 }); process.on('exit', function() { assert(serialized[0] === 42); diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js index 11ee45915c8395..8554c965e9481b 100644 --- a/test/parallel/test-stream2-transform.js +++ b/test/parallel/test-stream2-transform.js @@ -268,7 +268,7 @@ test('assymetric transform (compress)', function(t) { test('complex transform', function(t) { var count = 0; var saved = null; - var pt = new Transform({highWaterMark:3}); + var pt = new Transform({highWaterMark: 3}); pt._transform = function(c, e, cb) { if (count++ === 1) saved = c; diff --git a/test/parallel/test-tls-alert.js b/test/parallel/test-tls-alert.js index 6ebb1e9e0d704b..20e77afda4a4be 100644 --- a/test/parallel/test-tls-alert.js +++ b/test/parallel/test-tls-alert.js @@ -29,7 +29,7 @@ function loadPEM(n) { var server = tls.Server({ secureProtocol: 'TLSv1_2_server_method', key: loadPEM('agent2-key'), - cert:loadPEM('agent2-cert') + cert: loadPEM('agent2-cert') }, null).listen(common.PORT, function() { var args = ['s_client', '-quiet', '-tls1_1', '-connect', '127.0.0.1:' + common.PORT]; diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 9aa2682cbcb523..08f13c809df51e 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -822,7 +822,7 @@ var parseTests = { query: '@c' }, - 'http://a\r" \t\n<\'b:b@c\r\nd/e?f':{ + 'http://a\r" \t\n<\'b:b@c\r\nd/e?f': { protocol: 'http:', slashes: true, auth: 'a\r" \t\n<\'b:b', @@ -912,7 +912,7 @@ var parseTestsWithQueryString = { path: '/example', href: '/example' }, - '/example?query=value':{ + '/example?query=value': { protocol: null, slashes: null, auth: null, @@ -1091,7 +1091,7 @@ var formatTests = { // `#`,`?` in path '/path/to/%%23%3F+=&.txt?foo=theA1#bar': { - href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar', + href: '/path/to/%%23%3F+=&.txt?foo=theA1#bar', pathname: '/path/to/%#?+=&.txt', query: { foo: 'theA1' @@ -1101,7 +1101,7 @@ var formatTests = { // `#`,`?` in path + `#` in query '/path/to/%%23%3F+=&.txt?foo=the%231#bar': { - href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar', + href: '/path/to/%%23%3F+=&.txt?foo=the%231#bar', pathname: '/path/to/%#?+=&.txt', query: { foo: 'the#1' diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 864361d80a6dfa..84cd058714df02 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -76,10 +76,10 @@ assert.equal(false, util.isBuffer('foo')); assert.equal(true, util.isBuffer(new Buffer('foo'))); // _extend -assert.deepEqual(util._extend({a:1}), {a:1}); -assert.deepEqual(util._extend({a:1}, []), {a:1}); -assert.deepEqual(util._extend({a:1}, null), {a:1}); -assert.deepEqual(util._extend({a:1}, true), {a:1}); -assert.deepEqual(util._extend({a:1}, false), {a:1}); -assert.deepEqual(util._extend({a:1}, {b:2}), {a:1, b:2}); -assert.deepEqual(util._extend({a:1, b:2}, {b:3}), {a:1, b:3}); +assert.deepStrictEqual(util._extend({a: 1}), {a: 1}); +assert.deepStrictEqual(util._extend({a: 1}, []), {a: 1}); +assert.deepStrictEqual(util._extend({a: 1}, null), {a: 1}); +assert.deepStrictEqual(util._extend({a: 1}, true), {a: 1}); +assert.deepStrictEqual(util._extend({a: 1}, false), {a: 1}); +assert.deepStrictEqual(util._extend({a: 1}, {b: 2}), {a: 1, b: 2}); +assert.deepStrictEqual(util._extend({a: 1, b: 2}, {b: 3}), {a: 1, b: 3}); diff --git a/test/parallel/test-vm-context.js b/test/parallel/test-vm-context.js index 3fe3cf1b66a88e..48bceb14593679 100644 --- a/test/parallel/test-vm-context.js +++ b/test/parallel/test-vm-context.js @@ -52,7 +52,7 @@ console.error('test RegExp as argument to assert.throws'); script = vm.createScript('var assert = require(\'assert\'); assert.throws(' + 'function() { throw "hello world"; }, /hello/);', 'some.js'); -script.runInNewContext({ require : require }); +script.runInNewContext({ require: require }); // Issue GH-7529 script = vm.createScript('delete b'); diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js index dfef8c6a657cf2..302b645bdd52f2 100644 --- a/test/pummel/test-crypto-dh.js +++ b/test/pummel/test-crypto-dh.js @@ -20,14 +20,14 @@ assert.throws(function() { }); var hashes = { - modp1 : '630e9acd2cc63f7e80d8507624ba60ac0757201a', - modp2 : '18f7aa964484137f57bca64b21917a385b6a0b60', - modp5 : 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61', - modp14 : 'af5455606fe74cec49782bb374e4c63c9b1d132c', - modp15 : '7bdd39e5cdbb9748113933e5c2623b559c534e74', - modp16 : 'daea5277a7ad0116e734a8e0d2f297ef759d1161', - modp17 : '3b62aaf0142c2720f0bf26a9589b0432c00eadc1', - modp18 : 'a870b491bbbec9b131ae9878d07449d32e54f160' + modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a', + modp2: '18f7aa964484137f57bca64b21917a385b6a0b60', + modp5: 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61', + modp14: 'af5455606fe74cec49782bb374e4c63c9b1d132c', + modp15: '7bdd39e5cdbb9748113933e5c2623b559c534e74', + modp16: 'daea5277a7ad0116e734a8e0d2f297ef759d1161', + modp17: '3b62aaf0142c2720f0bf26a9589b0432c00eadc1', + modp18: 'a870b491bbbec9b131ae9878d07449d32e54f160' }; for (const name in hashes) { diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index c21785f233c58f..cb3bc5e579b86b 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -16,7 +16,7 @@ catch (e) { // swallow } -fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { +fs.watchFile(FILENAME, {interval: TIMEOUT - 250}, function(curr, prev) { console.log([curr, prev]); switch (++nevents) { case 1: diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js index 51d737ddbeede8..249164c7e4e991 100644 --- a/test/sequential/test-fs-watch.js +++ b/test/sequential/test-fs-watch.js @@ -119,7 +119,7 @@ assert.throws(function() { oldhandle.close(); // clean up assert.throws(function() { - var w = fs.watchFile(__filename, {persistent:false}, function() {}); + var w = fs.watchFile(__filename, {persistent: false}, function() {}); oldhandle = w._handle; w._handle = { stop: w._handle.stop }; w.stop(); diff --git a/tools/doc/html.js b/tools/doc/html.js index 27e9bee17bccec..5f349abe7145b3 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -152,7 +152,7 @@ function parseLists(input) { if (tok.type === 'list_start') { state = 'LIST'; if (depth === 0) { - output.push({ type:'html', text: '
    ' }); + output.push({ type: 'html', text: '
    ' }); } depth++; output.push(tok); @@ -176,7 +176,7 @@ function parseLists(input) { output.push(tok); if (depth === 0) { state = null; - output.push({ type:'html', text: '
    ' }); + output.push({ type: 'html', text: '
    ' }); } return; } From 686d7b329c3667516a993130a53f98227f6dd1f6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 9 May 2016 14:42:40 +0200 Subject: [PATCH 242/261] test: build addons with V8_DEPRECATION_WARNINGS=1 PR-URL: https://github.com/nodejs/node/pull/6652 Reviewed-By: Anna Henningsen --- test/addons/async-hello-world/binding.gyp | 1 + test/addons/at-exit/binding.gyp | 1 + test/addons/buffer-free-callback/binding.gyp | 1 + test/addons/heap-profiler/binding.gyp | 1 + test/addons/hello-world-function-export/binding.gyp | 1 + test/addons/hello-world/binding.gyp | 1 + test/addons/load-long-path/binding.gyp | 1 + test/addons/make-callback-recurse/binding.gyp | 1 + test/addons/make-callback/binding.gyp | 1 + test/addons/repl-domain-abort/binding.gyp | 1 + test/addons/stringbytes-external-exceed-max/binding.gyp | 1 + tools/doc/addon-verify.js | 1 + 12 files changed, 12 insertions(+) diff --git a/test/addons/async-hello-world/binding.gyp b/test/addons/async-hello-world/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/async-hello-world/binding.gyp +++ b/test/addons/async-hello-world/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/at-exit/binding.gyp b/test/addons/at-exit/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/at-exit/binding.gyp +++ b/test/addons/at-exit/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/buffer-free-callback/binding.gyp b/test/addons/buffer-free-callback/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/buffer-free-callback/binding.gyp +++ b/test/addons/buffer-free-callback/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/heap-profiler/binding.gyp b/test/addons/heap-profiler/binding.gyp index b75f68fe3a4e84..ceb1d3e73415de 100644 --- a/test/addons/heap-profiler/binding.gyp +++ b/test/addons/heap-profiler/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ], 'win_delay_load_hook': 'false' } diff --git a/test/addons/hello-world-function-export/binding.gyp b/test/addons/hello-world-function-export/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/hello-world-function-export/binding.gyp +++ b/test/addons/hello-world-function-export/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/hello-world/binding.gyp b/test/addons/hello-world/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/hello-world/binding.gyp +++ b/test/addons/hello-world/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/load-long-path/binding.gyp b/test/addons/load-long-path/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/load-long-path/binding.gyp +++ b/test/addons/load-long-path/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/make-callback-recurse/binding.gyp b/test/addons/make-callback-recurse/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/make-callback-recurse/binding.gyp +++ b/test/addons/make-callback-recurse/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/make-callback/binding.gyp b/test/addons/make-callback/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/make-callback/binding.gyp +++ b/test/addons/make-callback/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/repl-domain-abort/binding.gyp b/test/addons/repl-domain-abort/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/repl-domain-abort/binding.gyp +++ b/test/addons/repl-domain-abort/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/test/addons/stringbytes-external-exceed-max/binding.gyp b/test/addons/stringbytes-external-exceed-max/binding.gyp index 3bfb84493f3e87..7ede63d94a0d77 100644 --- a/test/addons/stringbytes-external-exceed-max/binding.gyp +++ b/test/addons/stringbytes-external-exceed-max/binding.gyp @@ -2,6 +2,7 @@ 'targets': [ { 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ 'binding.cc' ] } ] diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.js index 2abd3574cffd7f..96e1db0ea4647e 100644 --- a/tools/doc/addon-verify.js +++ b/tools/doc/addon-verify.js @@ -82,6 +82,7 @@ ${files[name]} targets: [ { target_name: 'addon', + defines: [ 'V8_DEPRECATION_WARNINGS=1' ], sources: files.map(function(file) { return file.name; }) From b869cdb876ede6350fbb8a3b071b65fefbad119d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 9 May 2016 15:09:09 +0200 Subject: [PATCH 243/261] doc: fix deprecation warnings in addon examples Use the overload of `v8::Function::NewInstance()` that returns a `v8::MaybeLocal`. The overloads that return a simple `v8::Local` are deprecated. PR-URL: https://github.com/nodejs/node/pull/6652 Reviewed-By: Anna Henningsen --- doc/api/addons.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 9650329b0a5604..a4041637f2fcea 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -549,6 +549,7 @@ prototype: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -597,8 +598,11 @@ void MyObject::New(const FunctionCallbackInfo& args) { // Invoked as plain function `MyObject(...)`, turn into construct call. const int argc = 1; Local argv[argc] = { args[0] }; + Local context = isolate->GetCurrentContext(); Local cons = Local::New(isolate, constructor); - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); + Local result = + cons->NewInstance(context, argc, argv).ToLocalChecked(); + args.GetReturnValue().Set(result); } } @@ -728,6 +732,7 @@ The implementation in `myobject.cc` is similar to the previous example: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -773,7 +778,10 @@ void MyObject::New(const FunctionCallbackInfo& args) { const int argc = 1; Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); + Local context = isolate->GetCurrentContext(); + Local instance = + cons->NewInstance(context, argc, argv).ToLocalChecked(); + args.GetReturnValue().Set(instance); } } @@ -783,7 +791,9 @@ void MyObject::NewInstance(const FunctionCallbackInfo& args) { const unsigned argc = 1; Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); - Local instance = cons->NewInstance(argc, argv); + Local context = isolate->GetCurrentContext(); + Local instance = + cons->NewInstance(context, argc, argv).ToLocalChecked(); args.GetReturnValue().Set(instance); } @@ -928,6 +938,7 @@ The implementation of `myobject.cc` is similar to before: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -968,8 +979,11 @@ void MyObject::New(const FunctionCallbackInfo& args) { // Invoked as plain function `MyObject(...)`, turn into construct call. const int argc = 1; Local argv[argc] = { args[0] }; + Local context = isolate->GetCurrentContext(); Local cons = Local::New(isolate, constructor); - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); + Local instance = + cons->NewInstance(context, argc, argv).ToLocalChecked(); + args.GetReturnValue().Set(instance); } } @@ -979,7 +993,9 @@ void MyObject::NewInstance(const FunctionCallbackInfo& args) { const unsigned argc = 1; Local argv[argc] = { args[0] }; Local cons = Local::New(isolate, constructor); - Local instance = cons->NewInstance(argc, argv); + Local context = isolate->GetCurrentContext(); + Local instance = + cons->NewInstance(context, argc, argv).ToLocalChecked(); args.GetReturnValue().Set(instance); } From ea20796e9d63766f533adfb3df9258623fcf663d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 9 May 2016 15:21:09 +0200 Subject: [PATCH 244/261] build,test: fix build-addons dependency chain * Make the 'extract embedded addons in the documentations' step a normal prerequisite. As an order-only prerequisite, it's sometimes skipped when it shouldn't be. * Make `tools/doc/addon-verify.js` a dependency of that step. Changes to that file should result in a rebuild. PR-URL: https://github.com/nodejs/node/pull/6652 Reviewed-By: Anna Henningsen --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 091dca717b5757..f6a6330e6020fc 100644 --- a/Makefile +++ b/Makefile @@ -128,9 +128,9 @@ test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE) --nodedir="$(shell pwd)" # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale. -test/addons/.docbuildstamp: doc/api/addons.md +test/addons/.docbuildstamp: tools/doc/addon-verify.js doc/api/addons.md $(RM) -r test/addons/??_*/ - $(NODE) tools/doc/addon-verify.js + $(NODE) $< touch $@ ADDONS_BINDING_GYPS := \ @@ -138,7 +138,7 @@ ADDONS_BINDING_GYPS := \ $(wildcard test/addons/*/binding.gyp)) # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale. -test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) | test/addons/.docbuildstamp +test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) test/addons/.docbuildstamp # Cannot use $(wildcard test/addons/*/) here, it's evaluated before # embedded addons have been generated from the documentation. for dirname in test/addons/*/; do \ From ed193ad8ae9bd3e023a4178cf3cbb8fcd67bd767 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 9 May 2016 15:15:23 +0200 Subject: [PATCH 245/261] tools: fix tools/doc/addon-verify.js regression Introduced in commit 3f69ea5 ("tools: update marked dependency"), it stopped the embedded addons in the documentation from getting built. PR-URL: https://github.com/nodejs/node/pull/6652 Reviewed-By: Ben Noordhuis --- tools/doc/addon-verify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/doc/addon-verify.js b/tools/doc/addon-verify.js index 96e1db0ea4647e..299d4847ef3eb3 100644 --- a/tools/doc/addon-verify.js +++ b/tools/doc/addon-verify.js @@ -10,7 +10,7 @@ const verifyDir = path.resolve(rootDir, 'test', 'addons'); const contents = fs.readFileSync(doc).toString(); -const tokens = marked.lexer(contents, {}); +const tokens = marked.lexer(contents); let files = null; let id = 0; From da1e13fde77d41a739cde913122730cbe98098f0 Mon Sep 17 00:00:00 2001 From: Jesse McCarthy Date: Wed, 18 Nov 2015 17:40:03 -0500 Subject: [PATCH 246/261] build: add Make `doc-only` target Allows building just docs using existing Node instead of building Node first. PR-URL: https://github.com/nodejs/node/pull/3888 Reviewed-By: Chris Dickinson Reviewed-By: Rod Vagg Reviewed-By: James M Snell Reviewed-By: Myles Borins --- BUILDING.md | 10 ++++++++++ Makefile | 14 ++++++++------ tools/doc/generate.js | 13 +++++++++---- tools/doc/html.js | 27 ++++++++++++++++++++++----- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index fa5fbe2c050c81..b634d34b6d1cca 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -67,10 +67,20 @@ $ make test-npm To build the documentation: +This will build Node.js first (if necessary) and then use it to build the docs: + ```text $ make doc ``` +If you have an existing Node.js you can build just the docs with: + +```text +$ NODE=node make doc-only +``` + +(Where `node` is the path to your executable.) + To read the documentation: ```text diff --git a/Makefile b/Makefile index f6a6330e6020fc..c10858f4efc6d5 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,8 @@ BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]') EXEEXT := $(shell $(PYTHON) -c \ "import sys; print('.exe' if sys.platform == 'win32' else '')") -NODE ?= ./node$(EXEEXT) NODE_EXE = node$(EXEEXT) +NODE ?= ./$(NODE_EXE) NODE_G_EXE = node_g$(EXEEXT) # Flags for packaging. @@ -259,7 +259,9 @@ apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*))) -doc: $(apidoc_dirs) $(apiassets) $(apidocs) tools/doc/ $(NODE_EXE) +doc-only: $(apidoc_dirs) $(apiassets) $(apidocs) tools/doc/ + +doc: $(NODE_EXE) doc-only $(apidoc_dirs): mkdir -p $@ @@ -270,11 +272,11 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/ out/doc/%: doc/% cp -r $< $@ -out/doc/api/%.json: doc/api/%.md $(NODE_EXE) +out/doc/api/%.json: doc/api/%.md $(NODE) tools/doc/generate.js --format=json $< > $@ -out/doc/api/%.html: doc/api/%.md $(NODE_EXE) - $(NODE) tools/doc/generate.js --format=html --template=doc/template.html $< > $@ +out/doc/api/%.html: doc/api/%.md + $(NODE) tools/doc/generate.js --node-version=$(FULLVERSION) --format=html --template=doc/template.html $< > $@ docopen: out/doc/api/all.html -google-chrome out/doc/api/all.html @@ -664,4 +666,4 @@ lint-ci: lint bench-all bench bench-misc bench-array bench-buffer bench-net \ bench-http bench-fs bench-tls cctest run-ci lint-ci bench-ci \ test-v8 test-v8-intl test-v8-benchmarks test-v8-all v8 \ - $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci + $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci doc-only diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 9048b484ce4e07..94c0905468f862 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -10,6 +10,7 @@ const args = process.argv.slice(2); let format = 'json'; let template = null; let inputFile = null; +let nodeVersion = null; args.forEach(function(arg) { if (!arg.match(/^\-\-/)) { @@ -18,15 +19,15 @@ args.forEach(function(arg) { format = arg.replace(/^\-\-format=/, ''); } else if (arg.match(/^\-\-template=/)) { template = arg.replace(/^\-\-template=/, ''); + } else if (arg.match(/^\-\-node\-version=/)) { + nodeVersion = arg.replace(/^\-\-node\-version=/, ''); } }); - if (!inputFile) { throw new Error('No input file specified'); } - console.error('Input file = %s', inputFile); fs.readFile(inputFile, 'utf8', function(er, input) { if (er) throw er; @@ -34,7 +35,6 @@ fs.readFile(inputFile, 'utf8', function(er, input) { processIncludes(inputFile, input, next); }); - function next(er, input) { if (er) throw er; switch (format) { @@ -46,7 +46,12 @@ function next(er, input) { break; case 'html': - require('./html.js')(input, inputFile, template, function(er, html) { + require('./html.js')({ + input: input, + filename: inputFile, + template: template, + nodeVersion: nodeVersion, + }, function(er, html) { if (er) throw er; console.log(html); }); diff --git a/tools/doc/html.js b/tools/doc/html.js index 5f349abe7145b3..45d0a809143a8f 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -30,7 +30,12 @@ var gtocPath = path.resolve(path.join( var gtocLoading = null; var gtocData = null; -function toHTML(input, filename, template, cb) { +/** + * opts: input, filename, template, nodeVersion. + */ +function toHTML(opts, cb) { + var template = opts.template; + if (gtocData) { return onGtocLoaded(); } @@ -51,10 +56,15 @@ function toHTML(input, filename, template, cb) { } function onGtocLoaded() { - var lexed = marked.lexer(input); + var lexed = marked.lexer(opts.input); fs.readFile(template, 'utf8', function(er, template) { if (er) return cb(er); - render(lexed, filename, template, cb); + render({ + lexed: lexed, + filename: opts.filename, + template: template, + nodeVersion: opts.nodeVersion, + }, cb); }); } } @@ -81,7 +91,14 @@ function toID(filename) { .replace(/-+/g, '-'); } -function render(lexed, filename, template, cb) { +/** + * opts: lexed, filename, template, nodeVersion. + */ +function render(opts, cb) { + var lexed = opts.lexed; + var filename = opts.filename; + var template = opts.template; + // get the section var section = getSection(lexed); @@ -100,7 +117,7 @@ function render(lexed, filename, template, cb) { template = template.replace(/__ID__/g, id); template = template.replace(/__FILENAME__/g, filename); template = template.replace(/__SECTION__/g, section); - template = template.replace(/__VERSION__/g, process.version); + template = template.replace(/__VERSION__/g, opts.nodeVersion); template = template.replace(/__TOC__/g, toc); template = template.replace( /__GTOC__/g, From 607173bbacdce9cb572f9728b8e78feb0961a7ac Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 10 May 2016 11:56:56 -0700 Subject: [PATCH 247/261] tools: fix regression in doctool 101dd1e introduced a regression in the doctool. This commit reverts the changes that were made to the function signature of the various doctool functions while maintaining support for passing in specific node versions. Refs: https://github.com/nodejs/node/commit/101dd1e PR-URL: https://github.com/nodejs/node/pull/6680 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Robert Lindstaedt --- tools/doc/generate.js | 16 +++++++--------- tools/doc/html.js | 36 ++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 94c0905468f862..7df987e1cf78f9 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -24,6 +24,8 @@ args.forEach(function(arg) { } }); +nodeVersion = nodeVersion || process.version; + if (!inputFile) { throw new Error('No input file specified'); } @@ -46,15 +48,11 @@ function next(er, input) { break; case 'html': - require('./html.js')({ - input: input, - filename: inputFile, - template: template, - nodeVersion: nodeVersion, - }, function(er, html) { - if (er) throw er; - console.log(html); - }); + require('./html.js')(input, inputFile, template, nodeVersion, + function(er, html) { + if (er) throw er; + console.log(html); + }); break; default: diff --git a/tools/doc/html.js b/tools/doc/html.js index 45d0a809143a8f..ef7d78d5b70ab3 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -30,11 +30,12 @@ var gtocPath = path.resolve(path.join( var gtocLoading = null; var gtocData = null; -/** - * opts: input, filename, template, nodeVersion. - */ -function toHTML(opts, cb) { - var template = opts.template; +function toHTML(input, filename, template, nodeVersion, cb) { + if (typeof nodeVersion === 'function') { + cb = nodeVersion; + nodeVersion = null; + } + nodeVersion = nodeVersion || process.version; if (gtocData) { return onGtocLoaded(); @@ -56,15 +57,10 @@ function toHTML(opts, cb) { } function onGtocLoaded() { - var lexed = marked.lexer(opts.input); + var lexed = marked.lexer(input); fs.readFile(template, 'utf8', function(er, template) { if (er) return cb(er); - render({ - lexed: lexed, - filename: opts.filename, - template: template, - nodeVersion: opts.nodeVersion, - }, cb); + render(lexed, filename, template, nodeVersion, cb); }); } } @@ -91,13 +87,13 @@ function toID(filename) { .replace(/-+/g, '-'); } -/** - * opts: lexed, filename, template, nodeVersion. - */ -function render(opts, cb) { - var lexed = opts.lexed; - var filename = opts.filename; - var template = opts.template; +function render(lexed, filename, template, nodeVersion, cb) { + if (typeof nodeVersion === 'function') { + cb = nodeVersion; + nodeVersion = null; + } + + nodeVersion = nodeVersion || process.version; // get the section var section = getSection(lexed); @@ -117,7 +113,7 @@ function render(opts, cb) { template = template.replace(/__ID__/g, id); template = template.replace(/__FILENAME__/g, filename); template = template.replace(/__SECTION__/g, section); - template = template.replace(/__VERSION__/g, opts.nodeVersion); + template = template.replace(/__VERSION__/g, nodeVersion); template = template.replace(/__TOC__/g, toc); template = template.replace( /__GTOC__/g, From 3681b9b868f789c1eb48420295e6e5e0f7a82898 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 12 May 2016 13:23:07 -0700 Subject: [PATCH 248/261] test: refactor doctool tests Adjust style in doctool tests to conform with predominant style of the rest of the project. The biggest changes are: * Replace string concatenation with `path.join()` * Remove unnecessary quotes from property names PR-URL: https://github.com/nodejs/node/pull/6719 Reviewed-By: James M Snell --- test/doctool/test-doctool-html.js | 13 +-- test/doctool/test-doctool-json.js | 164 +++++++++++++++--------------- 2 files changed, 91 insertions(+), 86 deletions(-) diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index 1eb96751cc0adb..a8476b7234c9fa 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); +const path = require('path'); const html = require('../../tools/doc/html.js'); @@ -13,13 +14,13 @@ const html = require('../../tools/doc/html.js'); // have an html parser. const testData = [ { - 'file': common.fixturesDir + '/sample_document.md', - 'html': '
    1. fish
    2. fish

    3. Redfish

    4. ' + + file: path.join(common.fixturesDir, 'sample_document.md'), + html: '
      1. fish
      2. fish

      3. Redfish

      4. ' + '
      5. Bluefish
      ' }, { - 'file': common.fixturesDir + '/order_of_end_tags_5873.md', - 'html': '

      ClassMethod: Buffer.from(array) ' + + file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'), + html: '

      ClassMethod: Buffer.from(array) ' + '#

      • array' }, { - 'file': common.fixturesDir + '/doc_with_yaml.md', - 'html': '

        Sample Markdown with YAML info' + + file: path.join(common.fixturesDir, 'doc_with_yaml.md'), + html: '

        Sample Markdown with YAML info' + '#

        ' + '

        Foobar\n
      • fish
      • \n
      • fish

        \n
      • \n
      • ' + + file: path.join(common.fixturesDir, 'sample_document.md'), + json: { + source: 'foo', + modules: [{ + textRaw: 'Sample Markdown', + name: 'sample_markdown', + modules: [{ + textRaw: 'Seussian Rhymes', + name: 'seussian_rhymes', + desc: '
          \n
        1. fish
        2. \n
        3. fish

          \n
        4. \n
        5. ' + '

          Red fish

          \n
        6. \n
        7. Blue fish
        8. \n
        \n', - 'type': 'module', - 'displayName': 'Seussian Rhymes' - } ], - 'type': 'module', - 'displayName': 'Sample Markdown' - } ] + type: 'module', + displayName: 'Seussian Rhymes' + }], + type: 'module', + displayName: 'Sample Markdown' + }] } }, { - 'file': common.fixturesDir + '/order_of_end_tags_5873.md', - 'json': { - 'source': 'foo', - 'modules': [ { - 'textRaw': 'Title', - 'name': 'title', - 'modules': [ { - 'textRaw': 'Subsection', - 'name': 'subsection', - 'classMethods': [ { - 'textRaw': 'Class Method: Buffer.from(array)', - 'type': 'classMethod', - 'name': 'from', - 'signatures': [ { - 'params': [ { - 'textRaw': '`array` {Array} ', - 'name': 'array', - 'type': 'Array' - } ] - }, + file: path.join(common.fixturesDir, 'order_of_end_tags_5873.md'), + json: { + source: 'foo', + modules: [{ + textRaw: 'Title', + name: 'title', + modules: [{ + textRaw: 'Subsection', + name: 'subsection', + classMethods: [{ + textRaw: 'Class Method: Buffer.from(array)', + type: 'classMethod', + name: 'from', + signatures: [ + { + params: [{ + textRaw: '`array` {Array} ', + name: 'array', + type: 'Array' + }] + }, { - 'params': [ { - 'name': 'array' - } ] + params: [{ + name: 'array' + }] } ] - } ], - 'type': 'module', - 'displayName': 'Subsection' - } ], - 'type': 'module', - 'displayName': 'Title' - } ] + }], + type: 'module', + displayName: 'Subsection' + }], + type: 'module', + displayName: 'Title' + }] } }, { - 'file': common.fixturesDir + '/doc_with_yaml.md', - 'json': { - 'source': 'foo', - 'modules': [ + file: path.join(common.fixturesDir, 'doc_with_yaml.md'), + json: { + source: 'foo', + modules: [ { - 'textRaw': 'Sample Markdown with YAML info', - 'name': 'sample_markdown_with_yaml_info', - 'modules': [ + textRaw: 'Sample Markdown with YAML info', + name: 'sample_markdown_with_yaml_info', + modules: [ { - 'textRaw': 'Foobar', - 'name': 'foobar', - 'meta': { - 'added': ['v1.0.0'] + textRaw: 'Foobar', + name: 'foobar', + meta: { + added: ['v1.0.0'] }, - 'desc': '

        Describe Foobar in more detail ' + + desc: '

        Describe Foobar in more detail ' + 'here.

        \n', - 'type': 'module', - 'displayName': 'Foobar' + type: 'module', + displayName: 'Foobar' }, { - 'textRaw': 'Foobar II', - 'name': 'foobar_ii', - 'meta': { - 'added': ['v5.3.0', 'v4.2.0'] + textRaw: 'Foobar II', + name: 'foobar_ii', + meta: { + added: ['v5.3.0', 'v4.2.0'] }, - 'desc': '

        Describe Foobar II in more detail ' + + desc: '

        Describe Foobar II in more detail ' + 'here.

        \n', - 'type': 'module', - 'displayName': 'Foobar II' + type: 'module', + displayName: 'Foobar II' }, { - 'textRaw': 'Deprecated thingy', - 'name': 'deprecated_thingy', - 'meta': { - 'added': ['v1.0.0'], - 'deprecated': ['v2.0.0'] + textRaw: 'Deprecated thingy', + name: 'deprecated_thingy', + meta: { + added: ['v1.0.0'], + deprecated: ['v2.0.0'] }, - 'desc': '

        Describe Deprecated thingy in more ' + + desc: '

        Describe Deprecated thingy in more ' + 'detail here.

        \n', - 'type': 'module', - 'displayName': 'Deprecated thingy' + type: 'module', + displayName: 'Deprecated thingy' }, { - 'textRaw': 'Something', - 'name': 'something', - 'desc': '\n

        ' + + textRaw: 'Something', + name: 'something', + desc: '\n

        ' + 'Describe Something in more detail here.

        \n', - 'type': 'module', - 'displayName': 'Something' + type: 'module', + displayName: 'Something' } ], - 'type': 'module', - 'displayName': 'Sample Markdown with YAML info' + type: 'module', + displayName: 'Sample Markdown with YAML info' } ] } From f9f85a006f58f9846c18edb37ca110ffd2862e3f Mon Sep 17 00:00:00 2001 From: Jesse McCarthy Date: Tue, 10 May 2016 18:40:31 -0400 Subject: [PATCH 249/261] tools: restore change of signatures to opts hashes These signatures were originally converted to opts hashes in #3888. That change was misinterpreted as the intrinsic cause of a test failure and reverted in #6680. PR-URL: https://github.com/nodejs/node/pull/6690 Reviewed-By: Anna Henningsen Reviewed-By: Robert Jefe Lindstaedt --- test/doctool/test-doctool-html.js | 12 +++++++++-- tools/doc/generate.js | 12 +++++++++-- tools/doc/html.js | 36 ++++++++++++++++++------------- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index a8476b7234c9fa..8e16403901a00a 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -61,7 +61,14 @@ testData.forEach(function(item) { fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { assert.ifError(err); - html(input, 'foo', 'doc/template.html', + html( + { + input: input, + filename: 'foo', + template: 'doc/template.html', + nodeVersion: process.version, + }, + common.mustCall(function(err, output) { assert.ifError(err); @@ -69,6 +76,7 @@ testData.forEach(function(item) { // Assert that the input stripped of all whitespace contains the // expected list assert.notEqual(actual.indexOf(expected), -1); - })); + }) + ); })); }); diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 7df987e1cf78f9..077e740432c837 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -48,11 +48,19 @@ function next(er, input) { break; case 'html': - require('./html.js')(input, inputFile, template, nodeVersion, + require('./html.js')( + { + input: input, + filename: inputFile, + template: template, + nodeVersion: nodeVersion, + }, + function(er, html) { if (er) throw er; console.log(html); - }); + } + ); break; default: diff --git a/tools/doc/html.js b/tools/doc/html.js index ef7d78d5b70ab3..de63aefa43b510 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -30,12 +30,12 @@ var gtocPath = path.resolve(path.join( var gtocLoading = null; var gtocData = null; -function toHTML(input, filename, template, nodeVersion, cb) { - if (typeof nodeVersion === 'function') { - cb = nodeVersion; - nodeVersion = null; - } - nodeVersion = nodeVersion || process.version; +/** + * opts: input, filename, template, nodeVersion. + */ +function toHTML(opts, cb) { + var template = opts.template; + var nodeVersion = opts.nodeVersion || process.version; if (gtocData) { return onGtocLoaded(); @@ -57,10 +57,15 @@ function toHTML(input, filename, template, nodeVersion, cb) { } function onGtocLoaded() { - var lexed = marked.lexer(input); + var lexed = marked.lexer(opts.input); fs.readFile(template, 'utf8', function(er, template) { if (er) return cb(er); - render(lexed, filename, template, nodeVersion, cb); + render({ + lexed: lexed, + filename: opts.filename, + template: template, + nodeVersion: nodeVersion, + }, cb); }); } } @@ -87,13 +92,14 @@ function toID(filename) { .replace(/-+/g, '-'); } -function render(lexed, filename, template, nodeVersion, cb) { - if (typeof nodeVersion === 'function') { - cb = nodeVersion; - nodeVersion = null; - } - - nodeVersion = nodeVersion || process.version; +/** + * opts: lexed, filename, template, nodeVersion. + */ +function render(opts, cb) { + var lexed = opts.lexed; + var filename = opts.filename; + var template = opts.template; + var nodeVersion = opts.nodeVersion || process.version; // get the section var section = getSection(lexed); From 9ef6e23088ed4a310d1eee31eec821fd059624d2 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 24 May 2016 00:06:09 +0200 Subject: [PATCH 250/261] tools: make sure doctool anchors respect includes Previously, output files which were created using includes (notably, the single-page all.html) had basically broken internal links all over the place because references like `errors.html#errors_class_error` are being used, yet `id` attributes were generated that looked like `all_class_error`. This PR adds generation of comments from the include preprocessor that indicate from which file the current markdown bits come and lets the HTML output generation take advantage of that so that more appropriate `id` attributes can be generated. PR-URL: https://github.com/nodejs/node/pull/6943 Reviewed-By: Robert Jefe Lindstaedt Reviewed-By: Daniel Wang --- test/doctool/test-doctool-html.js | 46 +++++++++++++++++++----------- test/fixtures/doc_inc_1.md | 3 ++ test/fixtures/doc_inc_2.md | 3 ++ test/fixtures/doc_with_includes.md | 2 ++ tools/doc/html.js | 17 ++++++++++- tools/doc/preprocess.js | 6 +++- 6 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 test/fixtures/doc_inc_1.md create mode 100644 test/fixtures/doc_inc_2.md create mode 100644 test/fixtures/doc_with_includes.md diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index 8e16403901a00a..91b9e0de6d3777 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -5,6 +5,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); +const processIncludes = require('../../tools/doc/preprocess.js'); const html = require('../../tools/doc/html.js'); // Test data is a list of objects with two properties. @@ -53,30 +54,43 @@ const testData = [ '

        Describe Something in more detail here. ' + '

        ' }, + { + file: path.join(common.fixturesDir, 'doc_with_includes.md'), + html: '' + + '

        Look here!

        ' + + '' + + '' + + '

        foobar#

        ' + + '

        I exist and am being linked to.

        ' + + '' + }, ]; testData.forEach(function(item) { // Normalize expected data by stripping whitespace const expected = item.html.replace(/\s/g, ''); - fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { + fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); - html( - { - input: input, - filename: 'foo', - template: 'doc/template.html', - nodeVersion: process.version, - }, + processIncludes(item.file, input, common.mustCall((err, preprocessed) => { + assert.ifError(err); - common.mustCall(function(err, output) { - assert.ifError(err); + html( + { + input: preprocessed, + filename: 'foo', + template: 'doc/template.html', + nodeVersion: process.version, + }, + common.mustCall((err, output) => { + assert.ifError(err); - const actual = output.replace(/\s/g, ''); - // Assert that the input stripped of all whitespace contains the - // expected list - assert.notEqual(actual.indexOf(expected), -1); - }) - ); + const actual = output.replace(/\s/g, ''); + // Assert that the input stripped of all whitespace contains the + // expected list + assert.notEqual(actual.indexOf(expected), -1); + })); + })); })); }); diff --git a/test/fixtures/doc_inc_1.md b/test/fixtures/doc_inc_1.md new file mode 100644 index 00000000000000..92858d0200c237 --- /dev/null +++ b/test/fixtures/doc_inc_1.md @@ -0,0 +1,3 @@ +Look [here][]! + +[here]: doc_inc_2.html#doc_inc_2_foobar diff --git a/test/fixtures/doc_inc_2.md b/test/fixtures/doc_inc_2.md new file mode 100644 index 00000000000000..17d0b86a0cc51f --- /dev/null +++ b/test/fixtures/doc_inc_2.md @@ -0,0 +1,3 @@ +# foobar + +I exist and am being linked to. diff --git a/test/fixtures/doc_with_includes.md b/test/fixtures/doc_with_includes.md new file mode 100644 index 00000000000000..901bf0f1b0bf3b --- /dev/null +++ b/test/fixtures/doc_with_includes.md @@ -0,0 +1,2 @@ +@include doc_inc_1 +@include doc_inc_2.md diff --git a/tools/doc/html.js b/tools/doc/html.js index de63aefa43b510..769d601e26c800 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -283,7 +283,21 @@ function getSection(lexed) { function buildToc(lexed, filename, cb) { var toc = []; var depth = 0; + + const startIncludeRefRE = /^\s*\s*$/; + const endIncludeRefRE = /^\s*\s*$/; + const realFilenames = [filename]; + lexed.forEach(function(tok) { + // Keep track of the current filename along @include directives. + if (tok.type === 'html') { + let match; + if ((match = tok.text.match(startIncludeRefRE)) !== null) + realFilenames.unshift(match[1]); + else if (tok.text.match(endIncludeRefRE)) + realFilenames.shift(); + } + if (tok.type !== 'heading') return; if (tok.depth - depth > 1) { return cb(new Error('Inappropriate heading level\n' + @@ -291,7 +305,8 @@ function buildToc(lexed, filename, cb) { } depth = tok.depth; - var id = getId(filename + '_' + tok.text.trim()); + const realFilename = path.basename(realFilenames[0], '.md'); + const id = getId(realFilename + '_' + tok.text.trim()); toc.push(new Array((depth - 1) * 2 + 1).join(' ') + '* ' + tok.text + ''); diff --git a/tools/doc/preprocess.js b/tools/doc/preprocess.js index 295737a2a53aee..55d90996f71c13 100644 --- a/tools/doc/preprocess.js +++ b/tools/doc/preprocess.js @@ -48,7 +48,11 @@ function processIncludes(inputFile, input, cb) { if (errState) return; if (er) return cb(errState = er); incCount--; - includeData[fname] = inc; + + // Add comments to let the HTML generator know how the anchors for + // headings should look like. + includeData[fname] = `\n` + + inc + `\n\n`; input = input.split(include + '\n').join(includeData[fname] + '\n'); if (incCount === 0) { return cb(null, input); From d50f16969de18b59c8bcbac5b4a6a691ed7bf81c Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 19 May 2016 11:11:51 +0200 Subject: [PATCH 251/261] tools,doc: add example usage for REPLACEME tag Ref: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6864 Reviewed-By: Ben Noordhuis Reviewed-By: Claudio Rodriguez Reviewed-By: Colin Ihrig --- tools/doc/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/doc/README.md b/tools/doc/README.md index 22bd053ed1b058..1620d6c25acbc9 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -34,6 +34,15 @@ Each type of heading has a description block. A description of the function. + ### module.someNewFunction(x) + + + * `x` {String} the description of the string + + This feature is not in a release yet. + ### Event: 'blerg' regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) - - this.debug(this.pattern, set) - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }) - - this.debug(this.pattern, set) - - this.set = set -} - -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - var negate = false - var options = this.options - var negateOffset = 0 - - if (options.nonegate) return - - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate - negateOffset++ - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} - -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} - -Minimatch.prototype.braceExpand = braceExpand - -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options - } else { - options = {} - } - } - - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern - - if (typeof pattern === 'undefined') { - throw new Error('undefined pattern') - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) -} - -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - var options = this.options - - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' - - var re = '' - var hasMagic = !!options.nocase - var escaping = false - // ? => one single character - var patternListStack = [] - var negativeLists = [] - var plType - var stateChar - var inClass = false - var reClassStart = -1 - var classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)' - var self = this - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star - hasMagic = true - break - case '?': - re += qmark - hasMagic = true - break - default: - re += '\\' + stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } - } - - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c - escaping = false - continue - } - - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case '\\': - clearStateChar() - escaping = true - continue - - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === '!' && i === classStart + 1) c = '^' - re += c - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue - - case '(': - if (inClass) { - re += '(' - continue - } - - if (!stateChar) { - re += '\\(' - continue - } - - plType = stateChar - patternListStack.push({ - type: plType, - start: i - 1, - reStart: re.length - }) - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:' - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue - - case ')': - if (inClass || !patternListStack.length) { - re += '\\)' - continue - } - - clearStateChar() - hasMagic = true - re += ')' - var pl = patternListStack.pop() - plType = pl.type - // negation is (?:(?!js)[^/]*) - // The others are (?:) - switch (plType) { - case '!': - negativeLists.push(pl) - re += ')[^/]*?)' - pl.reEnd = re.length - break - case '?': - case '+': - case '*': - re += plType - break - case '@': break // the default anyway - } - continue - - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|' - escaping = false - continue - } - - clearStateChar() - re += '|' - continue - - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar() - - if (inClass) { - re += '\\' + c - continue - } - - inClass = true - classStart = i - reClassStart = re.length - re += c - continue - - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c - escaping = false - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - - // finish up the class. - hasMagic = true - inClass = false - re += c - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar() - - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\' - } - - re += c - - } // switch - } // for - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1) - sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] - hasMagic = hasMagic || sp[1] - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + 3) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\' - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }) - - this.debug('tail=%j\n %s', tail, tail) - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type - - hasMagic = true - re = re.slice(0, pl.reStart) + t + '\\(' + tail - } - - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += '\\\\' - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true - } - - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n] - - var nlBefore = re.slice(0, nl.reStart) - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) - var nlAfter = re.slice(nl.reEnd) - - nlLast += nlAfter - - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1 - var cleanAfter = nlAfter - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') - } - nlAfter = cleanAfter - - var dollar = '' - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$' - } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast - re = newRe - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re - } - - if (addPatternStart) { - re = patternStart + re - } - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? 'i' : '' - var regExp = new RegExp('^' + re + '$', flags) - - regExp._glob = pattern - regExp._src = re - - return regExp -} - -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} - -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set - - if (!set.length) { - this.regexp = false - return this.regexp - } - var options = this.options - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - var flags = options.nocase ? 'i' : '' - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|') - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$' - - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$' - - try { - this.regexp = new RegExp(re, flags) - } catch (ex) { - this.regexp = false - } - return this.regexp -} - -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} - -Minimatch.prototype.match = match -function match (f, partial) { - this.debug('match', f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' - - if (f === '/' && partial) return true - - var options = this.options - - // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/') - } - - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, 'split', f) - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set - this.debug(this.pattern, 'set', set) - - // Find the basename of the path by looking for the last non-empty segment - var filename - var i - for (i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } - - for (i = 0; i < set.length; i++) { - var pattern = set[i] - var file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate -} - -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options - - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }) - - this.debug('matchOne', file.length, pattern.length) - - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop') - var p = pattern[pi] - var f = file[fi] - - this.debug(pattern, p, f) - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - var pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr] - - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr) - break - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr++ - } - } - - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug('string match', p, f, hit) - } else { - hit = f.match(p) - this.debug('pattern match', p, f, hit) - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd - } - - // should be unreachable. - throw new Error('wtf?') -} - -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') -} - -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') -} - -},{"brace-expansion":2,"path":undefined}],2:[function(require,module,exports){ -var concatMap = require('concat-map'); -var balanced = require('balanced-match'); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - var expansions = expand(escapeBraces(str)); - return expansions.filter(identity).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0]).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - expansions.push([pre, N[j], post[k]].join('')) - } - } - - return expansions; -} - - -},{"balanced-match":3,"concat-map":4}],3:[function(require,module,exports){ -module.exports = balanced; -function balanced(a, b, str) { - var bal = 0; - var m = {}; - var ended = false; - - for (var i = 0; i < str.length; i++) { - if (a == str.substr(i, a.length)) { - if (!('start' in m)) m.start = i; - bal++; - } - else if (b == str.substr(i, b.length) && 'start' in m) { - ended = true; - bal--; - if (!bal) { - m.end = i; - m.pre = str.substr(0, m.start); - m.body = (m.end - m.start > 1) - ? str.substring(m.start + a.length, m.end) - : ''; - m.post = str.slice(m.end + b.length); - return m; - } - } - } - - // if we opened more than we closed, find the one we closed - if (bal && ended) { - var start = m.start + a.length; - m = balanced(a, b, str.substr(start)); - if (m) { - m.start += start; - m.end += start; - m.pre = str.slice(0, start) + m.pre; - } - return m; - } -} - -},{}],4:[function(require,module,exports){ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (Array.isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -},{}]},{},[1])(1) -}); \ No newline at end of file diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/minimatch.js b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/minimatch.js deleted file mode 100644 index ec4c05c570c52e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/minimatch.js +++ /dev/null @@ -1,912 +0,0 @@ -module.exports = minimatch -minimatch.Minimatch = Minimatch - -var path = { sep: '/' } -try { - path = require('path') -} catch (er) {} - -var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} -var expand = require('brace-expansion') - -// any single thing other than / -// don't need to escape / when using new RegExp() -var qmark = '[^/]' - -// * => any number of characters -var star = qmark + '*?' - -// ** when dots are allowed. Anything goes, except .. and . -// not (^ or / followed by one or two dots followed by $ or /), -// followed by anything, any number of times. -var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' - -// not a ^ or / followed by a dot, -// followed by anything, any number of times. -var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' - -// characters that need to be escaped in RegExp. -var reSpecials = charSet('().*{}+?[]^$\\!') - -// "abc" -> { a:true, b:true, c:true } -function charSet (s) { - return s.split('').reduce(function (set, c) { - set[c] = true - return set - }, {}) -} - -// normalizes slashes. -var slashSplit = /\/+/ - -minimatch.filter = filter -function filter (pattern, options) { - options = options || {} - return function (p, i, list) { - return minimatch(p, pattern, options) - } -} - -function ext (a, b) { - a = a || {} - b = b || {} - var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) - Object.keys(a).forEach(function (k) { - t[k] = a[k] - }) - return t -} - -minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch - - var orig = minimatch - - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - } - - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - } - - return m -} - -Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch - return minimatch.defaults(def).Minimatch -} - -function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } - - if (!options) options = {} - - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - return false - } - - // "" only matches "" - if (pattern.trim() === '') return p === '' - - return new Minimatch(pattern, options).match(p) -} - -function Minimatch (pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) - } - - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } - - if (!options) options = {} - pattern = pattern.trim() - - // windows support: need to use /, not \ - if (path.sep !== '/') { - pattern = pattern.split(path.sep).join('/') - } - - this.options = options - this.set = [] - this.pattern = pattern - this.regexp = null - this.negate = false - this.comment = false - this.empty = false - - // make the set of regexps etc. - this.make() -} - -Minimatch.prototype.debug = function () {} - -Minimatch.prototype.make = make -function make () { - // don't do it more than once. - if (this._made) return - - var pattern = this.pattern - var options = this.options - - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - this.comment = true - return - } - if (!pattern) { - this.empty = true - return - } - - // step 1: figure out negation, etc. - this.parseNegate() - - // step 2: expand braces - var set = this.globSet = this.braceExpand() - - if (options.debug) this.debug = console.error - - this.debug(this.pattern, set) - - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }) - - this.debug(this.pattern, set) - - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) - - this.debug(this.pattern, set) - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }) - - this.debug(this.pattern, set) - - this.set = set -} - -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - var negate = false - var options = this.options - var negateOffset = 0 - - if (options.nonegate) return - - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate - negateOffset++ - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} - -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} - -Minimatch.prototype.braceExpand = braceExpand - -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options - } else { - options = {} - } - } - - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern - - if (typeof pattern === 'undefined') { - throw new Error('undefined pattern') - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) -} - -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - var options = this.options - - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' - - var re = '' - var hasMagic = !!options.nocase - var escaping = false - // ? => one single character - var patternListStack = [] - var negativeLists = [] - var plType - var stateChar - var inClass = false - var reClassStart = -1 - var classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)' - var self = this - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star - hasMagic = true - break - case '?': - re += qmark - hasMagic = true - break - default: - re += '\\' + stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } - } - - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c - escaping = false - continue - } - - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case '\\': - clearStateChar() - escaping = true - continue - - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === '!' && i === classStart + 1) c = '^' - re += c - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue - - case '(': - if (inClass) { - re += '(' - continue - } - - if (!stateChar) { - re += '\\(' - continue - } - - plType = stateChar - patternListStack.push({ - type: plType, - start: i - 1, - reStart: re.length - }) - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:' - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue - - case ')': - if (inClass || !patternListStack.length) { - re += '\\)' - continue - } - - clearStateChar() - hasMagic = true - re += ')' - var pl = patternListStack.pop() - plType = pl.type - // negation is (?:(?!js)[^/]*) - // The others are (?:) - switch (plType) { - case '!': - negativeLists.push(pl) - re += ')[^/]*?)' - pl.reEnd = re.length - break - case '?': - case '+': - case '*': - re += plType - break - case '@': break // the default anyway - } - continue - - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|' - escaping = false - continue - } - - clearStateChar() - re += '|' - continue - - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar() - - if (inClass) { - re += '\\' + c - continue - } - - inClass = true - classStart = i - reClassStart = re.length - re += c - continue - - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c - escaping = false - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - - // finish up the class. - hasMagic = true - inClass = false - re += c - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar() - - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\' - } - - re += c - - } // switch - } // for - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1) - sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] - hasMagic = hasMagic || sp[1] - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + 3) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\' - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }) - - this.debug('tail=%j\n %s', tail, tail) - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type - - hasMagic = true - re = re.slice(0, pl.reStart) + t + '\\(' + tail - } - - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += '\\\\' - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true - } - - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n] - - var nlBefore = re.slice(0, nl.reStart) - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) - var nlAfter = re.slice(nl.reEnd) - - nlLast += nlAfter - - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1 - var cleanAfter = nlAfter - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') - } - nlAfter = cleanAfter - - var dollar = '' - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$' - } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast - re = newRe - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re - } - - if (addPatternStart) { - re = patternStart + re - } - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? 'i' : '' - var regExp = new RegExp('^' + re + '$', flags) - - regExp._glob = pattern - regExp._src = re - - return regExp -} - -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} - -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set - - if (!set.length) { - this.regexp = false - return this.regexp - } - var options = this.options - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - var flags = options.nocase ? 'i' : '' - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|') - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$' - - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$' - - try { - this.regexp = new RegExp(re, flags) - } catch (ex) { - this.regexp = false - } - return this.regexp -} - -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} - -Minimatch.prototype.match = match -function match (f, partial) { - this.debug('match', f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' - - if (f === '/' && partial) return true - - var options = this.options - - // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/') - } - - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, 'split', f) - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set - this.debug(this.pattern, 'set', set) - - // Find the basename of the path by looking for the last non-empty segment - var filename - var i - for (i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } - - for (i = 0; i < set.length; i++) { - var pattern = set[i] - var file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate -} - -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options - - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }) - - this.debug('matchOne', file.length, pattern.length) - - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop') - var p = pattern[pi] - var f = file[fi] - - this.debug(pattern, p, f) - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - var pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr] - - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr) - break - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr++ - } - } - - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug('string match', p, f, hit) - } else { - hit = f.match(p) - this.debug('pattern match', p, f, hit) - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd - } - - // should be unreachable. - throw new Error('wtf?') -} - -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') -} - -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js deleted file mode 100644 index 60ecfc74d41618..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +++ /dev/null @@ -1,8 +0,0 @@ -var expand = require('./'); - -console.log(expand('http://any.org/archive{1996..1999}/vol{1..4}/part{a,b,c}.html')); -console.log(expand('http://www.numericals.com/file{1..100..10}.txt')); -console.log(expand('http://www.letters.com/file{a..z..2}.txt')); -console.log(expand('mkdir /usr/local/src/bash/{old,new,dist,bugs}')); -console.log(expand('chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}')); - diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore deleted file mode 100644 index fd4f2b066b339e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -.DS_Store diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml deleted file mode 100644 index 6e5919de39a312..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - "0.10" diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile deleted file mode 100644 index fa5da71a6d0d34..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +++ /dev/null @@ -1,6 +0,0 @@ - -test: - @node_modules/.bin/tape test/*.js - -.PHONY: test - diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js deleted file mode 100644 index c02ad348e69aec..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +++ /dev/null @@ -1,5 +0,0 @@ -var balanced = require('./'); - -console.log(balanced('{', '}', 'pre{in{nested}}post')); -console.log(balanced('{', '}', 'pre{first}between{second}post')); - diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js deleted file mode 100644 index f5e98e3f2a3240..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +++ /dev/null @@ -1,84 +0,0 @@ -var test = require('tape'); -var balanced = require('..'); - -test('balanced', function(t) { - t.deepEqual(balanced('{', '}', 'pre{in{nest}}post'), { - start: 3, - end: 12, - pre: 'pre', - body: 'in{nest}', - post: 'post' - }); - t.deepEqual(balanced('{', '}', '{{{{{{{{{in}post'), { - start: 8, - end: 11, - pre: '{{{{{{{{', - body: 'in', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre{body{in}post'), { - start: 8, - end: 11, - pre: 'pre{body', - body: 'in', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre}{in{nest}}post'), { - start: 4, - end: 13, - pre: 'pre}', - body: 'in{nest}', - post: 'post' - }); - t.deepEqual(balanced('{', '}', 'pre{body}between{body2}post'), { - start: 3, - end: 8, - pre: 'pre', - body: 'body', - post: 'between{body2}post' - }); - t.notOk(balanced('{', '}', 'nope'), 'should be notOk'); - t.deepEqual(balanced('', '', 'preinnestpost'), { - start: 3, - end: 19, - pre: 'pre', - body: 'innest', - post: 'post' - }); - t.deepEqual(balanced('', '', 'preinnestpost'), { - start: 7, - end: 23, - pre: 'pre', - body: 'innest', - post: 'post' - }); - t.deepEqual(balanced('{{', '}}', 'pre{{{in}}}post'), { - start: 3, - end: 9, - pre: 'pre', - body: '{in}', - post: 'post' - }); - t.deepEqual(balanced('{{{', '}}', 'pre{{{in}}}post'), { - start: 3, - end: 8, - pre: 'pre', - body: 'in', - post: '}post' - }); - t.deepEqual(balanced('{', '}', 'pre{{first}in{second}post'), { - start: 4, - end: 10, - pre: 'pre{', - body: 'first', - post: 'in{second}post' - }); - t.deepEqual(balanced('', 'prepost'), { - start: 3, - end: 4, - pre: 'pre', - body: '', - post: 'post' - }); - t.end(); -}); diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/package.json b/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/package.json deleted file mode 100644 index 3dc6beb49f684a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me" - }, - "name": "minimatch", - "description": "a glob matcher in javascript", - "version": "2.0.10", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/minimatch.git" - }, - "main": "minimatch.js", - "scripts": { - "posttest": "standard minimatch.js test/*.js", - "test": "tap test/*.js", - "prepublish": "browserify -o browser.js -e minimatch.js -s minimatch --bare" - }, - "engines": { - "node": "*" - }, - "dependencies": { - "brace-expansion": "^1.0.0" - }, - "devDependencies": { - "browserify": "^9.0.3", - "standard": "^3.7.2", - "tap": "^1.2.0" - }, - "license": "ISC", - "files": [ - "minimatch.js", - "browser.js" - ], - "gitHead": "6afb85f0c324b321f76a38df81891e562693e257", - "bugs": { - "url": "https://github.com/isaacs/minimatch/issues" - }, - "homepage": "https://github.com/isaacs/minimatch#readme", - "_id": "minimatch@2.0.10", - "_shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", - "_from": "minimatch@>=2.0.1 <3.0.0", - "_npmVersion": "3.1.0", - "_nodeVersion": "2.2.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "8d087c39c6b38c001b97fca7ce6d0e1e80afbac7", - "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/package.json b/deps/npm/node_modules/node-gyp/node_modules/glob/package.json deleted file mode 100644 index 434e4696f8fb15..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "name": "glob", - "description": "a little globber", - "version": "4.5.3", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-glob.git" - }, - "main": "glob.js", - "files": [ - "glob.js", - "sync.js", - "common.js" - ], - "engines": { - "node": "*" - }, - "dependencies": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" - }, - "devDependencies": { - "mkdirp": "0", - "rimraf": "^2.2.8", - "tap": "^0.5.0", - "tick": "0.0.6" - }, - "scripts": { - "prepublish": "npm run benchclean", - "profclean": "rm -f v8.log profile.txt", - "test": "npm run profclean && tap test/*.js", - "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js", - "bench": "bash benchmark.sh", - "prof": "bash prof.sh && cat profile.txt", - "benchclean": "bash benchclean.sh" - }, - "license": "ISC", - "gitHead": "a4e461ab59a837eee80a4d8dbdbf5ae1054a646f", - "bugs": { - "url": "https://github.com/isaacs/node-glob/issues" - }, - "homepage": "https://github.com/isaacs/node-glob", - "_id": "glob@4.5.3", - "_shasum": "c6cb73d3226c1efef04de3c56d012f03377ee15f", - "_from": "glob@>=3.0.0 <4.0.0||>=4.0.0 <5.0.0", - "_npmVersion": "2.7.1", - "_nodeVersion": "1.4.2", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "dist": { - "shasum": "c6cb73d3226c1efef04de3c56d012f03377ee15f", - "tarball": "http://registry.npmjs.org/glob/-/glob-4.5.3.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/sync.js b/deps/npm/node_modules/node-gyp/node_modules/glob/sync.js deleted file mode 100644 index f4f5e36d4beae3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/sync.js +++ /dev/null @@ -1,457 +0,0 @@ -module.exports = globSync -globSync.GlobSync = GlobSync - -var fs = require('fs') -var minimatch = require('minimatch') -var Minimatch = minimatch.Minimatch -var Glob = require('./glob.js').Glob -var util = require('util') -var path = require('path') -var assert = require('assert') -var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti -var isAbsolute = common.isAbsolute -var setopts = common.setopts -var ownProp = common.ownProp -var childrenIgnored = common.childrenIgnored - -function globSync (pattern, options) { - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - return new GlobSync(pattern, options).found -} - -function GlobSync (pattern, options) { - if (!pattern) - throw new Error('must provide pattern') - - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - if (!(this instanceof GlobSync)) - return new GlobSync(pattern, options) - - setopts(this, pattern, options) - - if (this.noprocess) - return this - - var n = this.minimatch.set.length - this.matches = new Array(n) - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false) - } - this._finish() -} - -GlobSync.prototype._finish = function () { - assert(this instanceof GlobSync) - if (this.realpath) { - var self = this - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null) - for (var p in matchset) { - try { - p = self._makeAbs(p) - var real = fs.realpathSync(p, this.realpathCache) - set[real] = true - } catch (er) { - if (er.syscall === 'stat') - set[self._makeAbs(p)] = true - else - throw er - } - } - }) - } - common.finish(this) -} - - -GlobSync.prototype._process = function (pattern, index, inGlobStar) { - assert(this instanceof GlobSync) - - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. - - // See if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index) - return - - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break - - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break - } - - var remain = pattern.slice(n) - - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix - - var abs = this._makeAbs(read) - - //if ignored, skip processing - if (childrenIgnored(this, read)) - return - - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar) -} - - -GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar) - - // if the abs isn't a dir, then nothing can match! - if (!entries) - return - - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' - - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) - } else { - m = e.match(pn) - } - if (m) - matchedEntries.push(e) - } - } - - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return - - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. - - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix.slice(-1) !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) - } - this.matches[index][e] = true - } - // This was the last one, and no stats were needed - return - } - - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) - newPattern = [prefix, e] - else - newPattern = [e] - this._process(newPattern.concat(remain), index, inGlobStar) - } -} - - -GlobSync.prototype._emitMatch = function (index, e) { - var abs = this._makeAbs(e) - if (this.mark) - e = this._mark(e) - - if (this.matches[index][e]) - return - - if (this.nodir) { - var c = this.cache[this._makeAbs(e)] - if (c === 'DIR' || Array.isArray(c)) - return - } - - this.matches[index][e] = true - if (this.stat) - this._stat(e) -} - - -GlobSync.prototype._readdirInGlobStar = function (abs) { - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false) - - var entries - var lstat - var stat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - // lstat failed, doesn't exist - return null - } - - var isSym = lstat.isSymbolicLink() - this.symlinks[abs] = isSym - - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && !lstat.isDirectory()) - this.cache[abs] = 'FILE' - else - entries = this._readdir(abs, false) - - return entries -} - -GlobSync.prototype._readdir = function (abs, inGlobStar) { - var entries - - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs) - - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return null - - if (Array.isArray(c)) - return c - } - - try { - return this._readdirEntries(abs, fs.readdirSync(abs)) - } catch (er) { - this._readdirError(abs, er) - return null - } -} - -GlobSync.prototype._readdirEntries = function (abs, entries) { - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } - - this.cache[abs] = entries - - // mark and cache dir-ness - return entries -} - -GlobSync.prototype._readdirError = function (f, er) { - // handle errors, and cache the information - switch (er.code) { - case 'ENOTDIR': // totally normal. means it *does* exist. - this.cache[this._makeAbs(f)] = 'FILE' - break - - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break - - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) throw er - if (!this.silent) console.error('glob error', er) - break - } -} - -GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - - var entries = this._readdir(abs, inGlobStar) - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return - - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) - - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false) - - var len = entries.length - var isSym = this.symlinks[abs] - - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return - - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue - - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true) - - var below = gspref.concat(entries[i], remain) - this._process(below, index, true) - } -} - -GlobSync.prototype._processSimple = function (prefix, index) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var exists = this._stat(prefix) - - if (!this.matches[index]) - this.matches[index] = Object.create(null) - - // If it doesn't exist, then just mark the lack of results - if (!exists) - return - - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' - } - } - - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') - - // Mark this as a match - this.matches[index][prefix] = true -} - -// Returns either 'DIR', 'FILE', or false -GlobSync.prototype._stat = function (f) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' - - if (f.length > this.maxLength) - return false - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] - - if (Array.isArray(c)) - c = 'DIR' - - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return c - - if (needDir && c === 'FILE') - return false - - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - - var exists - var stat = this.statCache[abs] - if (!stat) { - var lstat - try { - lstat = fs.lstatSync(abs) - } catch (er) { - return false - } - - if (lstat.isSymbolicLink()) { - try { - stat = fs.statSync(abs) - } catch (er) { - stat = lstat - } - } else { - stat = lstat - } - } - - this.statCache[abs] = stat - - var c = stat.isDirectory() ? 'DIR' : 'FILE' - this.cache[abs] = this.cache[abs] || c - - if (needDir && c !== 'DIR') - return false - - return c -} - -GlobSync.prototype._mark = function (p) { - return common.mark(this, p) -} - -GlobSync.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/minimatch/.npmignore deleted file mode 100644 index 3c3629e647f5dd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/minimatch/.travis.yml deleted file mode 100644 index fca8ef019405d5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.10 - - 0.11 diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/minimatch/LICENSE index 05a4010949cac3..19129e315fe593 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/LICENSE +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/LICENSE @@ -1,23 +1,15 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. +The ISC License -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: +Copyright (c) Isaac Z. Schlueter and Contributors -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/README.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/README.md index 5b3967ea998b01..ad72b8133eaf5e 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/README.md +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/README.md @@ -2,13 +2,11 @@ A minimal matching utility. -[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch) +[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.svg)](http://travis-ci.org/isaacs/minimatch) This is the matching library used internally by npm. -Eventually, it will replace the C binding in node-glob. - It works by converting glob expressions into JavaScript `RegExp` objects. @@ -39,7 +37,7 @@ See: ## Minimatch Class -Create a minimatch object by instanting the `minimatch.Minimatch` class. +Create a minimatch object by instantiating the `minimatch.Minimatch` class. ```javascript var Minimatch = require("minimatch").Minimatch @@ -84,13 +82,6 @@ var mm = new Minimatch(pattern, options) All other methods are internal, and will be called as necessary. -## Functions - -The top-level exported function has a `cache` property, which is an LRU -cache set to store 100 items. So, calling these methods repeatedly -with the same pattern and options will use the same Minimatch object, -saving the cost of parsing it multiple times. - ### minimatch(path, pattern, options) Main export. Tests a path against the pattern using the options. diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/minimatch.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/minimatch.js index 47617868b99902..830a27246cd6bd 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/minimatch.js +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/minimatch.js @@ -1,65 +1,36 @@ -;(function (require, exports, module, platform) { - -if (module) module.exports = minimatch -else exports.minimatch = minimatch - -if (!require) { - require = function (id) { - switch (id) { - case "sigmund": return function sigmund (obj) { - return JSON.stringify(obj) - } - case "path": return { basename: function (f) { - f = f.split(/[\/\\]/) - var e = f.pop() - if (!e) e = f.pop() - return e - }} - case "lru-cache": return function LRUCache () { - // not quite an LRU, but still space-limited. - var cache = {} - var cnt = 0 - this.set = function (k, v) { - cnt ++ - if (cnt >= 100) cache = {} - cache[k] = v - } - this.get = function (k) { return cache[k] } - } - } - } -} - +module.exports = minimatch minimatch.Minimatch = Minimatch -var LRU = require("lru-cache") - , cache = minimatch.cache = new LRU({max: 100}) - , GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} - , sigmund = require("sigmund") +var path = { sep: '/' } +try { + path = require('path') +} catch (er) {} + +var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} +var expand = require('brace-expansion') -var path = require("path") - // any single thing other than / - // don't need to escape / when using new RegExp() - , qmark = "[^/]" +// any single thing other than / +// don't need to escape / when using new RegExp() +var qmark = '[^/]' - // * => any number of characters - , star = qmark + "*?" +// * => any number of characters +var star = qmark + '*?' - // ** when dots are allowed. Anything goes, except .. and . - // not (^ or / followed by one or two dots followed by $ or /), - // followed by anything, any number of times. - , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?" +// ** when dots are allowed. Anything goes, except .. and . +// not (^ or / followed by one or two dots followed by $ or /), +// followed by anything, any number of times. +var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' - // not a ^ or / followed by a dot, - // followed by anything, any number of times. - , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?" +// not a ^ or / followed by a dot, +// followed by anything, any number of times. +var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' - // characters that need to be escaped in RegExp. - , reSpecials = charSet("().*{}+?[]^$\\!") +// characters that need to be escaped in RegExp. +var reSpecials = charSet('().*{}+?[]^$\\!') // "abc" -> { a:true, b:true, c:true } function charSet (s) { - return s.split("").reduce(function (set, c) { + return s.split('').reduce(function (set, c) { set[c] = true return set }, {}) @@ -110,51 +81,41 @@ Minimatch.defaults = function (def) { return minimatch.defaults(def).Minimatch } - function minimatch (p, pattern, options) { - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') } if (!options) options = {} // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { + if (!options.nocomment && pattern.charAt(0) === '#') { return false } // "" only matches "" - if (pattern.trim() === "") return p === "" + if (pattern.trim() === '') return p === '' return new Minimatch(pattern, options).match(p) } function Minimatch (pattern, options) { if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options, cache) + return new Minimatch(pattern, options) } - if (typeof pattern !== "string") { - throw new TypeError("glob pattern string required") + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') } if (!options) options = {} pattern = pattern.trim() - // windows: need to use /, not \ - // On other platforms, \ is a valid (albeit bad) filename char. - if (platform === "win32") { - pattern = pattern.split("\\").join("/") + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/') } - // lru storage. - // these things aren't particularly big, but walking down the string - // and turning it into a regexp can get pretty costly. - var cacheKey = pattern + "\n" + sigmund(options) - var cached = minimatch.cache.get(cacheKey) - if (cached) return cached - minimatch.cache.set(cacheKey, this) - this.options = options this.set = [] this.pattern = pattern @@ -167,7 +128,7 @@ function Minimatch (pattern, options) { this.make() } -Minimatch.prototype.debug = function() {} +Minimatch.prototype.debug = function () {} Minimatch.prototype.make = make function make () { @@ -178,7 +139,7 @@ function make () { var options = this.options // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === "#") { + if (!options.nocomment && pattern.charAt(0) === '#') { this.comment = true return } @@ -217,7 +178,7 @@ function make () { // filter out everything that didn't compile properly. set = set.filter(function (s) { - return -1 === s.indexOf(false) + return s.indexOf(false) === -1 }) this.debug(this.pattern, set) @@ -228,17 +189,17 @@ function make () { Minimatch.prototype.parseNegate = parseNegate function parseNegate () { var pattern = this.pattern - , negate = false - , options = this.options - , negateOffset = 0 + var negate = false + var options = this.options + var negateOffset = 0 if (options.nonegate) return - for ( var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === "!" - ; i ++) { + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { negate = !negate - negateOffset ++ + negateOffset++ } if (negateOffset) this.pattern = pattern.substr(negateOffset) @@ -256,213 +217,34 @@ function parseNegate () { // a{2..}b -> a{2..}b // a{b}c -> a{b}c minimatch.braceExpand = function (pattern, options) { - return new Minimatch(pattern, options).braceExpand() + return braceExpand(pattern, options) } Minimatch.prototype.braceExpand = braceExpand -function pad(n, width, z) { - z = z || '0'; - n = n + ''; - return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; -} - function braceExpand (pattern, options) { - options = options || this.options - pattern = typeof pattern === "undefined" + if (!options) { + if (this instanceof Minimatch) { + options = this.options + } else { + options = {} + } + } + + pattern = typeof pattern === 'undefined' ? this.pattern : pattern - if (typeof pattern === "undefined") { - throw new Error("undefined pattern") + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern') } if (options.nobrace || - !pattern.match(/\{.*\}/)) { + !pattern.match(/\{.*\}/)) { // shortcut. no need to expand. return [pattern] } - var escaping = false - - // examples and comments refer to this crazy pattern: - // a{b,c{d,e},{f,g}h}x{y,z} - // expected: - // abxy - // abxz - // acdxy - // acdxz - // acexy - // acexz - // afhxy - // afhxz - // aghxy - // aghxz - - // everything before the first \{ is just a prefix. - // So, we pluck that off, and work with the rest, - // and then prepend it to everything we find. - if (pattern.charAt(0) !== "{") { - this.debug(pattern) - var prefix = null - for (var i = 0, l = pattern.length; i < l; i ++) { - var c = pattern.charAt(i) - this.debug(i, c) - if (c === "\\") { - escaping = !escaping - } else if (c === "{" && !escaping) { - prefix = pattern.substr(0, i) - break - } - } - - // actually no sets, all { were escaped. - if (prefix === null) { - this.debug("no sets") - return [pattern] - } - - var tail = braceExpand.call(this, pattern.substr(i), options) - return tail.map(function (t) { - return prefix + t - }) - } - - // now we have something like: - // {b,c{d,e},{f,g}h}x{y,z} - // walk through the set, expanding each part, until - // the set ends. then, we'll expand the suffix. - // If the set only has a single member, then'll put the {} back - - // first, handle numeric sets, since they're easier - var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/) - if (numset) { - this.debug("numset", numset[1], numset[2]) - var suf = braceExpand.call(this, pattern.substr(numset[0].length), options) - , start = +numset[1] - , needPadding = numset[1][0] === '0' - , startWidth = numset[1].length - , padded - , end = +numset[2] - , inc = start > end ? -1 : 1 - , set = [] - - for (var i = start; i != (end + inc); i += inc) { - padded = needPadding ? pad(i, startWidth) : i + '' - // append all the suffixes - for (var ii = 0, ll = suf.length; ii < ll; ii ++) { - set.push(padded + suf[ii]) - } - } - return set - } - - // ok, walk through the set - // We hope, somewhat optimistically, that there - // will be a } at the end. - // If the closing brace isn't found, then the pattern is - // interpreted as braceExpand("\\" + pattern) so that - // the leading \{ will be interpreted literally. - var i = 1 // skip the \{ - , depth = 1 - , set = [] - , member = "" - , sawEnd = false - , escaping = false - - function addMember () { - set.push(member) - member = "" - } - - this.debug("Entering for") - FOR: for (i = 1, l = pattern.length; i < l; i ++) { - var c = pattern.charAt(i) - this.debug("", i, c) - - if (escaping) { - escaping = false - member += "\\" + c - } else { - switch (c) { - case "\\": - escaping = true - continue - - case "{": - depth ++ - member += "{" - continue - - case "}": - depth -- - // if this closes the actual set, then we're done - if (depth === 0) { - addMember() - // pluck off the close-brace - i ++ - break FOR - } else { - member += c - continue - } - - case ",": - if (depth === 1) { - addMember() - } else { - member += c - } - continue - - default: - member += c - continue - } // switch - } // else - } // for - - // now we've either finished the set, and the suffix is - // pattern.substr(i), or we have *not* closed the set, - // and need to escape the leading brace - if (depth !== 0) { - this.debug("didn't close", pattern) - return braceExpand.call(this, "\\" + pattern, options) - } - - // x{y,z} -> ["xy", "xz"] - this.debug("set", set) - this.debug("suffix", pattern.substr(i)) - var suf = braceExpand.call(this, pattern.substr(i), options) - // ["b", "c{d,e}","{f,g}h"] -> - // [["b"], ["cd", "ce"], ["fh", "gh"]] - var addBraces = set.length === 1 - this.debug("set pre-expanded", set) - set = set.map(function (p) { - return braceExpand.call(this, p, options) - }, this) - this.debug("set expanded", set) - - - // [["b"], ["cd", "ce"], ["fh", "gh"]] -> - // ["b", "cd", "ce", "fh", "gh"] - set = set.reduce(function (l, r) { - return l.concat(r) - }) - - if (addBraces) { - set = set.map(function (s) { - return "{" + s + "}" - }) - } - - // now attach the suffixes. - var ret = [] - for (var i = 0, l = set.length; i < l; i ++) { - for (var ii = 0, ll = suf.length; ii < ll; ii ++) { - ret.push(set[i] + suf[ii]) - } - } - return ret + return expand(pattern) } // parse a component of the expanded set. @@ -479,90 +261,94 @@ function braceExpand (pattern, options) { Minimatch.prototype.parse = parse var SUBPARSE = {} function parse (pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long') + } + var options = this.options // shortcuts - if (!options.noglobstar && pattern === "**") return GLOBSTAR - if (pattern === "") return "" - - var re = "" - , hasMagic = !!options.nocase - , escaping = false - // ? => one single character - , patternListStack = [] - , plType - , stateChar - , inClass = false - , reClassStart = -1 - , classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - , patternStart = pattern.charAt(0) === "." ? "" // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))" - : "(?!\\.)" - , self = this + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = '' + var hasMagic = !!options.nocase + var escaping = false + // ? => one single character + var patternListStack = [] + var negativeLists = [] + var plType + var stateChar + var inClass = false + var reClassStart = -1 + var classStart = -1 + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)' + var self = this function clearStateChar () { if (stateChar) { // we had some state-tracking character // that wasn't consumed by this pass. switch (stateChar) { - case "*": + case '*': re += star hasMagic = true - break - case "?": + break + case '?': re += qmark hasMagic = true - break + break default: - re += "\\"+stateChar - break + re += '\\' + stateChar + break } self.debug('clearStateChar %j %j', stateChar, re) stateChar = false } } - for ( var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i ++ ) { - - this.debug("%s\t%s %s %j", pattern, i, re, c) + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c) // skip over any that are escaped. if (escaping && reSpecials[c]) { - re += "\\" + c + re += '\\' + c escaping = false continue } - SWITCH: switch (c) { - case "/": + switch (c) { + case '/': // completely not allowed, even escaped. // Should already be path-split by now. return false - case "\\": + case '\\': clearStateChar() escaping = true - continue + continue // the various stateChar values // for the "extglob" stuff. - case "?": - case "*": - case "+": - case "@": - case "!": - this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c) + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) // all of those are literals inside a class, except that // the glob [!a] means [^a] in regexp if (inClass) { this.debug(' in class') - if (c === "!" && i === classStart + 1) c = "^" + if (c === '!' && i === classStart + 1) c = '^' re += c continue } @@ -577,70 +363,77 @@ function parse (pattern, isSub) { // just clear the statechar *now*, rather than even diving into // the patternList stuff. if (options.noext) clearStateChar() - continue + continue - case "(": + case '(': if (inClass) { - re += "(" + re += '(' continue } if (!stateChar) { - re += "\\(" + re += '\\(' continue } plType = stateChar - patternListStack.push({ type: plType - , start: i - 1 - , reStart: re.length }) + patternListStack.push({ + type: plType, + start: i - 1, + reStart: re.length + }) // negation is (?:(?!js)[^/]*) - re += stateChar === "!" ? "(?:(?!" : "(?:" + re += stateChar === '!' ? '(?:(?!(?:' : '(?:' this.debug('plType %j %j', stateChar, re) stateChar = false - continue + continue - case ")": + case ')': if (inClass || !patternListStack.length) { - re += "\\)" + re += '\\)' continue } clearStateChar() hasMagic = true - re += ")" - plType = patternListStack.pop().type + re += ')' + var pl = patternListStack.pop() + plType = pl.type // negation is (?:(?!js)[^/]*) // The others are (?:) switch (plType) { - case "!": - re += "[^/]*?)" + case '!': + negativeLists.push(pl) + re += ')[^/]*?)' + pl.reEnd = re.length break - case "?": - case "+": - case "*": re += plType - case "@": break // the default anyway + case '?': + case '+': + case '*': + re += plType + break + case '@': break // the default anyway } - continue + continue - case "|": + case '|': if (inClass || !patternListStack.length || escaping) { - re += "\\|" + re += '\\|' escaping = false continue } clearStateChar() - re += "|" - continue + re += '|' + continue // these are mostly the same in regexp and glob - case "[": + case '[': // swallow any state-tracking char before the [ clearStateChar() if (inClass) { - re += "\\" + c + re += '\\' + c continue } @@ -648,24 +441,47 @@ function parse (pattern, isSub) { classStart = i reClassStart = re.length re += c - continue + continue - case "]": + case ']': // a right bracket shall lose its special // meaning and represent itself in // a bracket expression if it occurs // first in the list. -- POSIX.2 2.8.3.2 if (i === classStart + 1 || !inClass) { - re += "\\" + c + re += '\\' + c escaping = false continue } + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue + } + } + // finish up the class. hasMagic = true inClass = false re += c - continue + continue default: // swallow any state char that wasn't consumed @@ -675,8 +491,8 @@ function parse (pattern, isSub) { // no need escaping = false } else if (reSpecials[c] - && !(c === "^" && inClass)) { - re += "\\" + && !(c === '^' && inClass)) { + re += '\\' } re += c @@ -684,7 +500,6 @@ function parse (pattern, isSub) { } // switch } // for - // handle the case where we left a class open. // "[abc" is valid, equivalent to "\[abc" if (inClass) { @@ -692,9 +507,9 @@ function parse (pattern, isSub) { // this is a huge pita. We now have to re-walk // the contents of the would-be class to re-translate // any characters that were passed through as-is - var cs = pattern.substr(classStart + 1) - , sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + "\\[" + sp[0] + cs = pattern.substr(classStart + 1) + sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] hasMagic = hasMagic || sp[1] } @@ -704,14 +519,13 @@ function parse (pattern, isSub) { // and escape any | chars that were passed through as-is for the regexp. // Go through and escape them, taking care not to double-escape any // | chars that were already escaped. - var pl - while (pl = patternListStack.pop()) { + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { var tail = re.slice(pl.reStart + 3) // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { if (!$2) { // the | isn't already escaped, so escape it. - $2 = "\\" + $2 = '\\' } // need to escape all those slashes *again*, without escaping the @@ -720,46 +534,81 @@ function parse (pattern, isSub) { // it exactly after itself. That's why this trick works. // // I am sorry that you have to see this. - return $1 + $1 + $2 + "|" + return $1 + $1 + $2 + '|' }) - this.debug("tail=%j\n %s", tail, tail) - var t = pl.type === "*" ? star - : pl.type === "?" ? qmark - : "\\" + pl.type + this.debug('tail=%j\n %s', tail, tail) + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type hasMagic = true - re = re.slice(0, pl.reStart) - + t + "\\(" - + tail + re = re.slice(0, pl.reStart) + t + '\\(' + tail } // handle trailing things that only matter at the very end. clearStateChar() if (escaping) { // trailing \\ - re += "\\\\" + re += '\\\\' } // only need to apply the nodot start if the re starts with // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case ".": - case "[": - case "(": addPatternStart = true + case '.': + case '[': + case '(': addPatternStart = true + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n] + + var nlBefore = re.slice(0, nl.reStart) + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + var nlAfter = re.slice(nl.reEnd) + + nlLast += nlAfter + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1 + var cleanAfter = nlAfter + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') + } + nlAfter = cleanAfter + + var dollar = '' + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$' + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast + re = newRe } // if the re is not "" at this point, then we need to make sure // it doesn't match against an empty path part. // Otherwise a/* will match a/, which it should not. - if (re !== "" && hasMagic) re = "(?=.)" + re + if (re !== '' && hasMagic) { + re = '(?=.)' + re + } - if (addPatternStart) re = patternStart + re + if (addPatternStart) { + re = patternStart + re + } // parsing just a piece of a larger pattern. if (isSub === SUBPARSE) { - return [ re, hasMagic ] + return [re, hasMagic] } // skip the regexp for non-magical patterns @@ -769,8 +618,16 @@ function parse (pattern, isSub) { return globUnescape(pattern) } - var flags = options.nocase ? "i" : "" - , regExp = new RegExp("^" + re + "$", flags) + var flags = options.nocase ? 'i' : '' + try { + var regExp = new RegExp('^' + re + '$', flags) + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.') + } regExp._glob = pattern regExp._src = re @@ -794,34 +651,38 @@ function makeRe () { // when you just want to work with a regex. var set = this.set - if (!set.length) return this.regexp = false + if (!set.length) { + this.regexp = false + return this.regexp + } var options = this.options var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - , flags = options.nocase ? "i" : "" + : options.dot ? twoStarDot + : twoStarNoDot + var flags = options.nocase ? 'i' : '' var re = set.map(function (pattern) { return pattern.map(function (p) { return (p === GLOBSTAR) ? twoStar - : (typeof p === "string") ? regExpEscape(p) - : p._src - }).join("\\\/") - }).join("|") + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|') // must match entire pattern // ending in a * or ** will make it less strict. - re = "^(?:" + re + ")$" + re = '^(?:' + re + ')$' // can match anything, as long as it's not this. - if (this.negate) re = "^(?!" + re + ").*$" + if (this.negate) re = '^(?!' + re + ').*$' try { - return this.regexp = new RegExp(re, flags) + this.regexp = new RegExp(re, flags) } catch (ex) { - return this.regexp = false + this.regexp = false } + return this.regexp } minimatch.match = function (list, pattern, options) { @@ -838,25 +699,24 @@ minimatch.match = function (list, pattern, options) { Minimatch.prototype.match = match function match (f, partial) { - this.debug("match", f, this.pattern) + this.debug('match', f, this.pattern) // short-circuit in the case of busted things. // comments, etc. if (this.comment) return false - if (this.empty) return f === "" + if (this.empty) return f === '' - if (f === "/" && partial) return true + if (f === '/' && partial) return true var options = this.options // windows: need to use /, not \ - // On other platforms, \ is a valid (albeit bad) filename char. - if (platform === "win32") { - f = f.split("\\").join("/") + if (path.sep !== '/') { + f = f.split(path.sep).join('/') } // treat the test path as a set of pathparts. f = f.split(slashSplit) - this.debug(this.pattern, "split", f) + this.debug(this.pattern, 'split', f) // just ONE of the pattern sets in this.set needs to match // in order for it to be valid. If negating, then just one @@ -864,17 +724,19 @@ function match (f, partial) { // Either way, return on the first hit. var set = this.set - this.debug(this.pattern, "set", set) + this.debug(this.pattern, 'set', set) // Find the basename of the path by looking for the last non-empty segment - var filename; - for (var i = f.length - 1; i >= 0; i--) { + var filename + var i + for (i = f.length - 1; i >= 0; i--) { filename = f[i] if (filename) break } - for (var i = 0, l = set.length; i < l; i ++) { - var pattern = set[i], file = f + for (i = 0; i < set.length; i++) { + var pattern = set[i] + var file = f if (options.matchBase && pattern.length === 1) { file = [filename] } @@ -899,23 +761,20 @@ function match (f, partial) { Minimatch.prototype.matchOne = function (file, pattern, partial) { var options = this.options - this.debug("matchOne", - { "this": this - , file: file - , pattern: pattern }) + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }) - this.debug("matchOne", file.length, pattern.length) + this.debug('matchOne', file.length, pattern.length) - for ( var fi = 0 - , pi = 0 - , fl = file.length - , pl = pattern.length + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length ; (fi < fl) && (pi < pl) - ; fi ++, pi ++ ) { - - this.debug("matchOne loop") + ; fi++, pi++) { + this.debug('matchOne loop') var p = pattern[pi] - , f = file[fi] + var f = file[fi] this.debug(pattern, p, f) @@ -949,7 +808,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // - matchOne(z/c, c) -> no // - matchOne(c, c) yes, hit var fr = fi - , pr = pi + 1 + var pr = pi + 1 if (pr === pl) { this.debug('** at the end') // a ** at the end will just swallow the rest. @@ -958,19 +817,18 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // options.dot is set. // . and .. are *never* matched by **, for explosively // exponential reasons. - for ( ; fi < fl; fi ++) { - if (file[fi] === "." || file[fi] === ".." || - (!options.dot && file[fi].charAt(0) === ".")) return false + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false } return true } // ok, let's see if we can swallow whatever we can. - WHILE: while (fr < fl) { + while (fr < fl) { var swallowee = file[fr] - this.debug('\nglobstar while', - file, fr, pattern, pr, swallowee) + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) // XXX remove this slice. Just pass the start index. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { @@ -980,23 +838,24 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { } else { // can't swallow "." or ".." ever. // can only swallow ".foo" when explicitly asked. - if (swallowee === "." || swallowee === ".." || - (!options.dot && swallowee.charAt(0) === ".")) { - this.debug("dot detected!", file, fr, pattern, pr) - break WHILE + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr) + break } // ** swallows a segment, and continue. this.debug('globstar swallow a segment, and continue') - fr ++ + fr++ } } + // no match was found. // However, in partial mode, we can't say this is necessarily over. // If there's more *pattern* left, then if (partial) { // ran out of file - this.debug("\n>>> no match, partial?", file, fr, pattern, pr) + this.debug('\n>>> no match, partial?', file, fr, pattern, pr) if (fr === fl) return true } return false @@ -1006,16 +865,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // non-magic patterns just have to match exactly // patterns with magic have been turned into regexps. var hit - if (typeof p === "string") { + if (typeof p === 'string') { if (options.nocase) { hit = f.toLowerCase() === p.toLowerCase() } else { hit = f === p } - this.debug("string match", p, f, hit) + this.debug('string match', p, f, hit) } else { hit = f.match(p) - this.debug("pattern match", p, f, hit) + this.debug('pattern match', p, f, hit) } if (!hit) return false @@ -1047,27 +906,19 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // this is only acceptable if we're on the very last // empty segment of a file with a trailing slash. // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === "") + var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') return emptyFileEnd } // should be unreachable. - throw new Error("wtf?") + throw new Error('wtf?') } - // replace stuff like \* with * function globUnescape (s) { - return s.replace(/\\(.)/g, "$1") + return s.replace(/\\(.)/g, '$1') } - function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') } - -})( typeof require === "function" ? require : null, - this, - typeof module === "object" ? module : null, - typeof process === "object" ? process.platform : "win32" - ) diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/README.md similarity index 99% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/README.md index 179392978d30fe..b0d793ed5d9016 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/README.md @@ -1,6 +1,6 @@ # brace-expansion -[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), +[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), as known from sh/bash, in JavaScript. [![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion) diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/index.js similarity index 99% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/index.js index 932718f9287173..abe535df327354 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/index.js @@ -188,4 +188,3 @@ function expand(str, isTop) { return expansions; } - diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore similarity index 58% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore index 353546af2368e1..ae5d8c36ac6522 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore @@ -1,3 +1,5 @@ test .gitignore .travis.yml +Makefile +example.js diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md similarity index 94% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md index 421f3aa5f951a2..d6880b2f36e72b 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md @@ -1,6 +1,6 @@ # balanced-match -Match balanced string pairs, like `{` and `}` or `` and ``. +Match balanced string pairs, like `{` and `}` or `` and ``. Supports regular expressions as well! [![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match) [![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match) @@ -16,6 +16,7 @@ var balanced = require('balanced-match'); console.log(balanced('{', '}', 'pre{in{nested}}post')); console.log(balanced('{', '}', 'pre{first}between{second}post')); +console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); ``` The matches are: @@ -28,6 +29,7 @@ $ node example.js pre: 'pre', body: 'first', post: 'between{second}post' } +{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' } ``` ## API diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js similarity index 83% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js index 75f3d71cba90bc..4670f7f79f4d2a 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js @@ -1,5 +1,8 @@ module.exports = balanced; function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); + var r = range(a, b, str); return r && { @@ -11,6 +14,11 @@ function balanced(a, b, str) { }; } +function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; +} + balanced.range = range; function range(a, b, str) { var begs, beg, left, right, result; diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json similarity index 69% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json index 7eb345779f877e..ee083b2368b43f 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json @@ -1,7 +1,7 @@ { "name": "balanced-match", "description": "Match balanced character pairs, like \"{\" and \"}\"", - "version": "0.3.0", + "version": "0.4.1", "repository": { "type": "git", "url": "git://github.com/juliangruber/balanced-match.git" @@ -13,7 +13,7 @@ }, "dependencies": {}, "devDependencies": { - "tape": "~4.2.2" + "tape": "~4.5.0" }, "keywords": [ "match", @@ -44,22 +44,22 @@ "android-browser/4.2..latest" ] }, - "gitHead": "a7114b0986554787e90b7ac595a043ca75ea77e5", + "gitHead": "7004b289baaaab6a832f4901735e29d37cc2a863", "bugs": { "url": "https://github.com/juliangruber/balanced-match/issues" }, - "_id": "balanced-match@0.3.0", - "_shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", - "_from": "balanced-match@>=0.3.0 <0.4.0", - "_npmVersion": "2.14.7", - "_nodeVersion": "4.2.1", + "_id": "balanced-match@0.4.1", + "_shasum": "19053e2e0748eadb379da6c09d455cf5e1039335", + "_from": "balanced-match@>=0.4.1 <0.5.0", + "_npmVersion": "3.8.6", + "_nodeVersion": "6.0.0", "_npmUser": { "name": "juliangruber", "email": "julian@juliangruber.com" }, "dist": { - "shasum": "a91cdd1ebef1a86659e70ff4def01625fc2d6756", - "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" + "shasum": "19053e2e0748eadb379da6c09d455cf5e1039335", + "tarball": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.1.tgz" }, "maintainers": [ { @@ -67,7 +67,11 @@ "email": "julian@juliangruber.com" } ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/balanced-match-0.4.1.tgz_1462129663650_0.39764496590942144" + }, "directories": {}, - "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz", + "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js diff --git a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/package.json similarity index 72% rename from deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json rename to deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/package.json index b471be30b4e331..221689b9fd9a05 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/brace-expansion/package.json @@ -1,7 +1,7 @@ { "name": "brace-expansion", "description": "Brace expansion as known from sh/bash", - "version": "1.1.3", + "version": "1.1.5", "repository": { "type": "git", "url": "git://github.com/juliangruber/brace-expansion.git" @@ -13,11 +13,11 @@ "gentest": "bash test/generate.sh" }, "dependencies": { - "balanced-match": "^0.3.0", + "balanced-match": "^0.4.1", "concat-map": "0.0.1" }, "devDependencies": { - "tape": "4.4.0" + "tape": "4.5.1" }, "keywords": [], "author": { @@ -42,22 +42,22 @@ "android-browser/4.2..latest" ] }, - "gitHead": "f0da1bb668e655f67b6b2d660c6e1c19e2a6f231", + "gitHead": "ff31acab078f1bb696ac4c55ca56ea24e6495fb6", "bugs": { "url": "https://github.com/juliangruber/brace-expansion/issues" }, - "_id": "brace-expansion@1.1.3", - "_shasum": "46bff50115d47fc9ab89854abb87d98078a10991", + "_id": "brace-expansion@1.1.5", + "_shasum": "f5b4ad574e2cb7ccc1eb83e6fe79b8ecadf7a526", "_from": "brace-expansion@>=1.0.0 <2.0.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.5.0", + "_npmVersion": "2.15.5", + "_nodeVersion": "4.4.5", "_npmUser": { "name": "juliangruber", "email": "julian@juliangruber.com" }, "dist": { - "shasum": "46bff50115d47fc9ab89854abb87d98078a10991", - "tarball": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz" + "shasum": "f5b4ad574e2cb7ccc1eb83e6fe79b8ecadf7a526", + "tarball": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.5.tgz" }, "maintainers": [ { @@ -70,10 +70,10 @@ } ], "_npmOperationalInternal": { - "host": "packages-6-west.internal.npmjs.com", - "tmp": "tmp/brace-expansion-1.1.3.tgz_1455216688668_0.948847763473168" + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/brace-expansion-1.1.5.tgz_1465989660138_0.34528115345165133" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.3.tgz", + "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.5.tgz", "readme": "ERROR: No README data found!" } diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.npmignore deleted file mode 100644 index 07e6e472cc75fa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.npmignore +++ /dev/null @@ -1 +0,0 @@ -/node_modules diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.travis.yml deleted file mode 100644 index 4af02b3d17e64c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js -node_js: - - '0.8' - - '0.10' - - '0.12' - - 'iojs' -before_install: - - npm install -g npm@latest diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS deleted file mode 100644 index 4a0bc5033a06e7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +++ /dev/null @@ -1,14 +0,0 @@ -# Authors, sorted by whether or not they are me -Isaac Z. Schlueter -Brian Cottingham -Carlos Brito Lage -Jesse Dailey -Kevin O'Hara -Marco Rogers -Mark Cavage -Marko Mikulicic -Nathan Rajlich -Satheesh Natesan -Trent Mick -ashleybrener -n4kz diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/LICENSE deleted file mode 100644 index 19129e315fe593..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/README.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/README.md deleted file mode 100644 index c06814e0414d56..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/README.md +++ /dev/null @@ -1,137 +0,0 @@ -# lru cache - -A cache object that deletes the least-recently-used items. - -## Usage: - -```javascript -var LRU = require("lru-cache") - , options = { max: 500 - , length: function (n) { return n * 2 } - , dispose: function (key, n) { n.close() } - , maxAge: 1000 * 60 * 60 } - , cache = LRU(options) - , otherCache = LRU(50) // sets just the max size - -cache.set("key", "value") -cache.get("key") // "value" - -cache.reset() // empty the cache -``` - -If you put more stuff in it, then items will fall out. - -If you try to put an oversized thing in it, then it'll fall out right -away. - -## Keys should always be Strings or Numbers - -Note: this module will print warnings to `console.error` if you use a -key that is not a String or Number. Because items are stored in an -object, which coerces keys to a string, it won't go well for you if -you try to use a key that is not a unique string, it'll cause surprise -collisions. For example: - -```JavaScript -// Bad Example! Dont' do this! -var cache = LRU() -var a = {} -var b = {} -cache.set(a, 'this is a') -cache.set(b, 'this is b') -console.log(cache.get(a)) // prints: 'this is b' -``` - -## Options - -* `max` The maximum size of the cache, checked by applying the length - function to all values in the cache. Not setting this is kind of - silly, since that's the whole purpose of this lib, but it defaults - to `Infinity`. -* `maxAge` Maximum age in ms. Items are not pro-actively pruned out - as they age, but if you try to get an item that is too old, it'll - drop it and return undefined instead of giving it to you. -* `length` Function that is used to calculate the length of stored - items. If you're storing strings or buffers, then you probably want - to do something like `function(n){return n.length}`. The default is - `function(n){return 1}`, which is fine if you want to store `max` - like-sized things. -* `dispose` Function that is called on items when they are dropped - from the cache. This can be handy if you want to close file - descriptors or do other cleanup tasks when items are no longer - accessible. Called with `key, value`. It's called *before* - actually removing the item from the internal cache, so if you want - to immediately put it back in, you'll have to do that in a - `nextTick` or `setTimeout` callback or it won't do anything. -* `stale` By default, if you set a `maxAge`, it'll only actually pull - stale items out of the cache when you `get(key)`. (That is, it's - not pre-emptively doing a `setTimeout` or anything.) If you set - `stale:true`, it'll return the stale value before deleting it. If - you don't set this, then it'll return `undefined` when you try to - get a stale entry, as if it had already been deleted. - -## API - -* `set(key, value, maxAge)` -* `get(key) => value` - - Both of these will update the "recently used"-ness of the key. - They do what you think. `max` is optional and overrides the - cache `max` option if provided. - -* `peek(key)` - - Returns the key value (or `undefined` if not found) without - updating the "recently used"-ness of the key. - - (If you find yourself using this a lot, you *might* be using the - wrong sort of data structure, but there are some use cases where - it's handy.) - -* `del(key)` - - Deletes a key out of the cache. - -* `reset()` - - Clear the cache entirely, throwing away all values. - -* `has(key)` - - Check if a key is in the cache, without updating the recent-ness - or deleting it for being stale. - -* `forEach(function(value,key,cache), [thisp])` - - Just like `Array.prototype.forEach`. Iterates over all the keys - in the cache, in order of recent-ness. (Ie, more recently used - items are iterated over first.) - -* `keys()` - - Return an array of the keys in the cache. - -* `values()` - - Return an array of the values in the cache. - -* `length()` - - Return total length of objects in cache taking into account - `length` options function. - -* `itemCount` - - Return total quantity of objects currently in cache. Note, that - `stale` (see options) items are returned as part of this item - count. - -* `dump()` - - Return an array of the cache entries ready for serialization and usage - with 'destinationCache.load(arr)`. - -* `load(cacheEntriesArray)` - - Loads another cache entries array, obtained with `sourceCache.dump()`, - into the cache. The destination cache is reset before loading new entries diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js deleted file mode 100644 index 2bbe653be8ad08..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +++ /dev/null @@ -1,334 +0,0 @@ -;(function () { // closure for web browsers - -if (typeof module === 'object' && module.exports) { - module.exports = LRUCache -} else { - // just set the global for non-node platforms. - this.LRUCache = LRUCache -} - -function hOP (obj, key) { - return Object.prototype.hasOwnProperty.call(obj, key) -} - -function naiveLength () { return 1 } - -var didTypeWarning = false -function typeCheckKey(key) { - if (!didTypeWarning && typeof key !== 'string' && typeof key !== 'number') { - didTypeWarning = true - console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! " + typeof key).stack) - } -} - -function LRUCache (options) { - if (!(this instanceof LRUCache)) - return new LRUCache(options) - - if (typeof options === 'number') - options = { max: options } - - if (!options) - options = {} - - this._max = options.max - // Kind of weird to have a default max of Infinity, but oh well. - if (!this._max || !(typeof this._max === "number") || this._max <= 0 ) - this._max = Infinity - - this._lengthCalculator = options.length || naiveLength - if (typeof this._lengthCalculator !== "function") - this._lengthCalculator = naiveLength - - this._allowStale = options.stale || false - this._maxAge = options.maxAge || null - this._dispose = options.dispose - this.reset() -} - -// resize the cache when the max changes. -Object.defineProperty(LRUCache.prototype, "max", - { set : function (mL) { - if (!mL || !(typeof mL === "number") || mL <= 0 ) mL = Infinity - this._max = mL - if (this._length > this._max) trim(this) - } - , get : function () { return this._max } - , enumerable : true - }) - -// resize the cache when the lengthCalculator changes. -Object.defineProperty(LRUCache.prototype, "lengthCalculator", - { set : function (lC) { - if (typeof lC !== "function") { - this._lengthCalculator = naiveLength - this._length = this._itemCount - for (var key in this._cache) { - this._cache[key].length = 1 - } - } else { - this._lengthCalculator = lC - this._length = 0 - for (var key in this._cache) { - this._cache[key].length = this._lengthCalculator(this._cache[key].value) - this._length += this._cache[key].length - } - } - - if (this._length > this._max) trim(this) - } - , get : function () { return this._lengthCalculator } - , enumerable : true - }) - -Object.defineProperty(LRUCache.prototype, "length", - { get : function () { return this._length } - , enumerable : true - }) - - -Object.defineProperty(LRUCache.prototype, "itemCount", - { get : function () { return this._itemCount } - , enumerable : true - }) - -LRUCache.prototype.forEach = function (fn, thisp) { - thisp = thisp || this - var i = 0 - var itemCount = this._itemCount - - for (var k = this._mru - 1; k >= 0 && i < itemCount; k--) if (this._lruList[k]) { - i++ - var hit = this._lruList[k] - if (isStale(this, hit)) { - del(this, hit) - if (!this._allowStale) hit = undefined - } - if (hit) { - fn.call(thisp, hit.value, hit.key, this) - } - } -} - -LRUCache.prototype.keys = function () { - var keys = new Array(this._itemCount) - var i = 0 - for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { - var hit = this._lruList[k] - keys[i++] = hit.key - } - return keys -} - -LRUCache.prototype.values = function () { - var values = new Array(this._itemCount) - var i = 0 - for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { - var hit = this._lruList[k] - values[i++] = hit.value - } - return values -} - -LRUCache.prototype.reset = function () { - if (this._dispose && this._cache) { - for (var k in this._cache) { - this._dispose(k, this._cache[k].value) - } - } - - this._cache = Object.create(null) // hash of items by key - this._lruList = Object.create(null) // list of items in order of use recency - this._mru = 0 // most recently used - this._lru = 0 // least recently used - this._length = 0 // number of items in the list - this._itemCount = 0 -} - -LRUCache.prototype.dump = function () { - var arr = [] - var i = 0 - - for (var k = this._mru - 1; k >= 0 && i < this._itemCount; k--) if (this._lruList[k]) { - var hit = this._lruList[k] - if (!isStale(this, hit)) { - //Do not store staled hits - ++i - arr.push({ - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }); - } - } - //arr has the most read first - return arr -} - -LRUCache.prototype.dumpLru = function () { - return this._lruList -} - -LRUCache.prototype.set = function (key, value, maxAge) { - maxAge = maxAge || this._maxAge - typeCheckKey(key) - - var now = maxAge ? Date.now() : 0 - var len = this._lengthCalculator(value) - - if (hOP(this._cache, key)) { - if (len > this._max) { - del(this, this._cache[key]) - return false - } - // dispose of the old one before overwriting - if (this._dispose) - this._dispose(key, this._cache[key].value) - - this._cache[key].now = now - this._cache[key].maxAge = maxAge - this._cache[key].value = value - this._length += (len - this._cache[key].length) - this._cache[key].length = len - this.get(key) - - if (this._length > this._max) - trim(this) - - return true - } - - var hit = new Entry(key, value, this._mru++, len, now, maxAge) - - // oversized objects fall out of cache automatically. - if (hit.length > this._max) { - if (this._dispose) this._dispose(key, value) - return false - } - - this._length += hit.length - this._lruList[hit.lu] = this._cache[key] = hit - this._itemCount ++ - - if (this._length > this._max) - trim(this) - - return true -} - -LRUCache.prototype.has = function (key) { - typeCheckKey(key) - if (!hOP(this._cache, key)) return false - var hit = this._cache[key] - if (isStale(this, hit)) { - return false - } - return true -} - -LRUCache.prototype.get = function (key) { - typeCheckKey(key) - return get(this, key, true) -} - -LRUCache.prototype.peek = function (key) { - typeCheckKey(key) - return get(this, key, false) -} - -LRUCache.prototype.pop = function () { - var hit = this._lruList[this._lru] - del(this, hit) - return hit || null -} - -LRUCache.prototype.del = function (key) { - typeCheckKey(key) - del(this, this._cache[key]) -} - -LRUCache.prototype.load = function (arr) { - //reset the cache - this.reset(); - - var now = Date.now() - //A previous serialized cache has the most recent items first - for (var l = arr.length - 1; l >= 0; l-- ) { - var hit = arr[l] - typeCheckKey(hit.k) - var expiresAt = hit.e || 0 - if (expiresAt === 0) { - //the item was created without expiration in a non aged cache - this.set(hit.k, hit.v) - } else { - var maxAge = expiresAt - now - //dont add already expired items - if (maxAge > 0) this.set(hit.k, hit.v, maxAge) - } - } -} - -function get (self, key, doUse) { - typeCheckKey(key) - var hit = self._cache[key] - if (hit) { - if (isStale(self, hit)) { - del(self, hit) - if (!self._allowStale) hit = undefined - } else { - if (doUse) use(self, hit) - } - if (hit) hit = hit.value - } - return hit -} - -function isStale(self, hit) { - if (!hit || (!hit.maxAge && !self._maxAge)) return false - var stale = false; - var diff = Date.now() - hit.now - if (hit.maxAge) { - stale = diff > hit.maxAge - } else { - stale = self._maxAge && (diff > self._maxAge) - } - return stale; -} - -function use (self, hit) { - shiftLU(self, hit) - hit.lu = self._mru ++ - self._lruList[hit.lu] = hit -} - -function trim (self) { - while (self._lru < self._mru && self._length > self._max) - del(self, self._lruList[self._lru]) -} - -function shiftLU (self, hit) { - delete self._lruList[ hit.lu ] - while (self._lru < self._mru && !self._lruList[self._lru]) self._lru ++ -} - -function del (self, hit) { - if (hit) { - if (self._dispose) self._dispose(hit.key, hit.value) - self._length -= hit.length - self._itemCount -- - delete self._cache[ hit.key ] - shiftLU(self, hit) - } -} - -// classy, since V8 prefers predictable objects. -function Entry (key, value, lu, length, now, maxAge) { - this.key = key - this.value = value - this.lu = lu - this.length = length - this.now = now - if (maxAge) this.maxAge = maxAge -} - -})() diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/package.json deleted file mode 100644 index b6ef0521242474..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "lru-cache", - "description": "A cache object that deletes the least-recently-used items.", - "version": "2.7.3", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me" - }, - "keywords": [ - "mru", - "lru", - "cache" - ], - "scripts": { - "test": "tap test --gc" - }, - "main": "lib/lru-cache.js", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-lru-cache.git" - }, - "devDependencies": { - "tap": "^1.2.0", - "weak": "" - }, - "license": "ISC", - "gitHead": "292048199f6d28b77fbe584279a1898e25e4c714", - "bugs": { - "url": "https://github.com/isaacs/node-lru-cache/issues" - }, - "homepage": "https://github.com/isaacs/node-lru-cache#readme", - "_id": "lru-cache@2.7.3", - "_shasum": "6d4524e8b955f95d4f5b58851ce21dd72fb4e952", - "_from": "lru-cache@>=2.0.0 <3.0.0", - "_npmVersion": "3.3.2", - "_nodeVersion": "4.0.0", - "_npmUser": { - "name": "isaacs", - "email": "i@izs.me" - }, - "dist": { - "shasum": "6d4524e8b955f95d4f5b58851ce21dd72fb4e952", - "tarball": "http://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "directories": {}, - "_resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/basic.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/basic.js deleted file mode 100644 index b47225f109891f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/basic.js +++ /dev/null @@ -1,396 +0,0 @@ -var test = require("tap").test - , LRU = require("../") - -test("basic", function (t) { - var cache = new LRU({max: 10}) - cache.set("key", "value") - t.equal(cache.get("key"), "value") - t.equal(cache.get("nada"), undefined) - t.equal(cache.length, 1) - t.equal(cache.max, 10) - t.end() -}) - -test("least recently set", function (t) { - var cache = new LRU(2) - cache.set("a", "A") - cache.set("b", "B") - cache.set("c", "C") - t.equal(cache.get("c"), "C") - t.equal(cache.get("b"), "B") - t.equal(cache.get("a"), undefined) - t.end() -}) - -test("lru recently gotten", function (t) { - var cache = new LRU(2) - cache.set("a", "A") - cache.set("b", "B") - cache.get("a") - cache.set("c", "C") - t.equal(cache.get("c"), "C") - t.equal(cache.get("b"), undefined) - t.equal(cache.get("a"), "A") - t.end() -}) - -test("del", function (t) { - var cache = new LRU(2) - cache.set("a", "A") - cache.del("a") - t.equal(cache.get("a"), undefined) - t.end() -}) - -test("max", function (t) { - var cache = new LRU(3) - - // test changing the max, verify that the LRU items get dropped. - cache.max = 100 - for (var i = 0; i < 100; i ++) cache.set(i, i) - t.equal(cache.length, 100) - for (var i = 0; i < 100; i ++) { - t.equal(cache.get(i), i) - } - cache.max = 3 - t.equal(cache.length, 3) - for (var i = 0; i < 97; i ++) { - t.equal(cache.get(i), undefined) - } - for (var i = 98; i < 100; i ++) { - t.equal(cache.get(i), i) - } - - // now remove the max restriction, and try again. - cache.max = "hello" - for (var i = 0; i < 100; i ++) cache.set(i, i) - t.equal(cache.length, 100) - for (var i = 0; i < 100; i ++) { - t.equal(cache.get(i), i) - } - // should trigger an immediate resize - cache.max = 3 - t.equal(cache.length, 3) - for (var i = 0; i < 97; i ++) { - t.equal(cache.get(i), undefined) - } - for (var i = 98; i < 100; i ++) { - t.equal(cache.get(i), i) - } - t.end() -}) - -test("reset", function (t) { - var cache = new LRU(10) - cache.set("a", "A") - cache.set("b", "B") - cache.reset() - t.equal(cache.length, 0) - t.equal(cache.max, 10) - t.equal(cache.get("a"), undefined) - t.equal(cache.get("b"), undefined) - t.end() -}) - - -test("basic with weighed length", function (t) { - var cache = new LRU({ - max: 100, - length: function (item) { return item.size } - }) - cache.set("key", {val: "value", size: 50}) - t.equal(cache.get("key").val, "value") - t.equal(cache.get("nada"), undefined) - t.equal(cache.lengthCalculator(cache.get("key")), 50) - t.equal(cache.length, 50) - t.equal(cache.max, 100) - t.end() -}) - - -test("weighed length item too large", function (t) { - var cache = new LRU({ - max: 10, - length: function (item) { return item.size } - }) - t.equal(cache.max, 10) - - // should fall out immediately - cache.set("key", {val: "value", size: 50}) - - t.equal(cache.length, 0) - t.equal(cache.get("key"), undefined) - t.end() -}) - -test("least recently set with weighed length", function (t) { - var cache = new LRU({ - max:8, - length: function (item) { return item.length } - }) - cache.set("a", "A") - cache.set("b", "BB") - cache.set("c", "CCC") - cache.set("d", "DDDD") - t.equal(cache.get("d"), "DDDD") - t.equal(cache.get("c"), "CCC") - t.equal(cache.get("b"), undefined) - t.equal(cache.get("a"), undefined) - t.end() -}) - -test("lru recently gotten with weighed length", function (t) { - var cache = new LRU({ - max: 8, - length: function (item) { return item.length } - }) - cache.set("a", "A") - cache.set("b", "BB") - cache.set("c", "CCC") - cache.get("a") - cache.get("b") - cache.set("d", "DDDD") - t.equal(cache.get("c"), undefined) - t.equal(cache.get("d"), "DDDD") - t.equal(cache.get("b"), "BB") - t.equal(cache.get("a"), "A") - t.end() -}) - -test("lru recently updated with weighed length", function (t) { - var cache = new LRU({ - max: 8, - length: function (item) { return item.length } - }) - cache.set("a", "A") - cache.set("b", "BB") - cache.set("c", "CCC") - t.equal(cache.length, 6) //CCC BB A - cache.set("a", "+A") - t.equal(cache.length, 7) //+A CCC BB - cache.set("b", "++BB") - t.equal(cache.length, 6) //++BB +A - t.equal(cache.get("c"), undefined) - - cache.set("c", "oversized") - t.equal(cache.length, 6) //++BB +A - t.equal(cache.get("c"), undefined) - - cache.set("a", "oversized") - t.equal(cache.length, 4) //++BB - t.equal(cache.get("a"), undefined) - t.equal(cache.get("b"), "++BB") - t.end() -}) - -test("set returns proper booleans", function(t) { - var cache = new LRU({ - max: 5, - length: function (item) { return item.length } - }) - - t.equal(cache.set("a", "A"), true) - - // should return false for max exceeded - t.equal(cache.set("b", "donuts"), false) - - t.equal(cache.set("b", "B"), true) - t.equal(cache.set("c", "CCCC"), true) - t.end() -}) - -test("drop the old items", function(t) { - var cache = new LRU({ - max: 5, - maxAge: 50 - }) - - cache.set("a", "A") - - setTimeout(function () { - cache.set("b", "b") - t.equal(cache.get("a"), "A") - }, 25) - - setTimeout(function () { - cache.set("c", "C") - // timed out - t.notOk(cache.get("a")) - }, 60 + 25) - - setTimeout(function () { - t.notOk(cache.get("b")) - t.equal(cache.get("c"), "C") - }, 90) - - setTimeout(function () { - t.notOk(cache.get("c")) - t.end() - }, 155) -}) - -test("individual item can have it's own maxAge", function(t) { - var cache = new LRU({ - max: 5, - maxAge: 50 - }) - - cache.set("a", "A", 20) - setTimeout(function () { - t.notOk(cache.get("a")) - t.end() - }, 25) -}) - -test("individual item can have it's own maxAge > cache's", function(t) { - var cache = new LRU({ - max: 5, - maxAge: 20 - }) - - cache.set("a", "A", 50) - setTimeout(function () { - t.equal(cache.get("a"), "A") - t.end() - }, 25) -}) - -test("disposal function", function(t) { - var disposed = false - var cache = new LRU({ - max: 1, - dispose: function (k, n) { - disposed = n - } - }) - - cache.set(1, 1) - cache.set(2, 2) - t.equal(disposed, 1) - cache.set(3, 3) - t.equal(disposed, 2) - cache.reset() - t.equal(disposed, 3) - t.end() -}) - -test("disposal function on too big of item", function(t) { - var disposed = false - var cache = new LRU({ - max: 1, - length: function (k) { - return k.length - }, - dispose: function (k, n) { - disposed = n - } - }) - var obj = [ 1, 2 ] - - t.equal(disposed, false) - cache.set("obj", obj) - t.equal(disposed, obj) - t.end() -}) - -test("has()", function(t) { - var cache = new LRU({ - max: 1, - maxAge: 10 - }) - - cache.set('foo', 'bar') - t.equal(cache.has('foo'), true) - cache.set('blu', 'baz') - t.equal(cache.has('foo'), false) - t.equal(cache.has('blu'), true) - setTimeout(function() { - t.equal(cache.has('blu'), false) - t.end() - }, 15) -}) - -test("stale", function(t) { - var cache = new LRU({ - maxAge: 10, - stale: true - }) - - cache.set('foo', 'bar') - t.equal(cache.get('foo'), 'bar') - t.equal(cache.has('foo'), true) - setTimeout(function() { - t.equal(cache.has('foo'), false) - t.equal(cache.get('foo'), 'bar') - t.equal(cache.get('foo'), undefined) - t.end() - }, 15) -}) - -test("lru update via set", function(t) { - var cache = LRU({ max: 2 }); - - cache.set('foo', 1); - cache.set('bar', 2); - cache.del('bar'); - cache.set('baz', 3); - cache.set('qux', 4); - - t.equal(cache.get('foo'), undefined) - t.equal(cache.get('bar'), undefined) - t.equal(cache.get('baz'), 3) - t.equal(cache.get('qux'), 4) - t.end() -}) - -test("least recently set w/ peek", function (t) { - var cache = new LRU(2) - cache.set("a", "A") - cache.set("b", "B") - t.equal(cache.peek("a"), "A") - cache.set("c", "C") - t.equal(cache.get("c"), "C") - t.equal(cache.get("b"), "B") - t.equal(cache.get("a"), undefined) - t.end() -}) - -test("pop the least used item", function (t) { - var cache = new LRU(3) - , last - - cache.set("a", "A") - cache.set("b", "B") - cache.set("c", "C") - - t.equal(cache.length, 3) - t.equal(cache.max, 3) - - // Ensure we pop a, c, b - cache.get("b", "B") - - last = cache.pop() - t.equal(last.key, "a") - t.equal(last.value, "A") - t.equal(cache.length, 2) - t.equal(cache.max, 3) - - last = cache.pop() - t.equal(last.key, "c") - t.equal(last.value, "C") - t.equal(cache.length, 1) - t.equal(cache.max, 3) - - last = cache.pop() - t.equal(last.key, "b") - t.equal(last.value, "B") - t.equal(cache.length, 0) - t.equal(cache.max, 3) - - last = cache.pop() - t.equal(last, null) - t.equal(cache.length, 0) - t.equal(cache.max, 3) - - t.end() -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/foreach.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/foreach.js deleted file mode 100644 index 4190417cbc61d8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +++ /dev/null @@ -1,120 +0,0 @@ -var test = require('tap').test -var LRU = require('../') - -test('forEach', function (t) { - var l = new LRU(5) - for (var i = 0; i < 10; i ++) { - l.set(i.toString(), i.toString(2)) - } - - var i = 9 - l.forEach(function (val, key, cache) { - t.equal(cache, l) - t.equal(key, i.toString()) - t.equal(val, i.toString(2)) - i -= 1 - }) - - // get in order of most recently used - l.get(6) - l.get(8) - - var order = [ 8, 6, 9, 7, 5 ] - var i = 0 - - l.forEach(function (val, key, cache) { - var j = order[i ++] - t.equal(cache, l) - t.equal(key, j.toString()) - t.equal(val, j.toString(2)) - }) - t.equal(i, order.length); - - t.end() -}) - -test('keys() and values()', function (t) { - var l = new LRU(5) - for (var i = 0; i < 10; i ++) { - l.set(i.toString(), i.toString(2)) - } - - t.similar(l.keys(), ['9', '8', '7', '6', '5']) - t.similar(l.values(), ['1001', '1000', '111', '110', '101']) - - // get in order of most recently used - l.get(6) - l.get(8) - - t.similar(l.keys(), ['8', '6', '9', '7', '5']) - t.similar(l.values(), ['1000', '110', '1001', '111', '101']) - - t.end() -}) - -test('all entries are iterated over', function(t) { - var l = new LRU(5) - for (var i = 0; i < 10; i ++) { - l.set(i.toString(), i.toString(2)) - } - - var i = 0 - l.forEach(function (val, key, cache) { - if (i > 0) { - cache.del(key) - } - i += 1 - }) - - t.equal(i, 5) - t.equal(l.keys().length, 1) - - t.end() -}) - -test('all stale entries are removed', function(t) { - var l = new LRU({ max: 5, maxAge: -5, stale: true }) - for (var i = 0; i < 10; i ++) { - l.set(i.toString(), i.toString(2)) - } - - var i = 0 - l.forEach(function () { - i += 1 - }) - - t.equal(i, 5) - t.equal(l.keys().length, 0) - - t.end() -}) - -test('expires', function (t) { - var l = new LRU({ - max: 10, - maxAge: 50 - }) - for (var i = 0; i < 10; i++) { - l.set(i.toString(), i.toString(2), ((i % 2) ? 25 : undefined)) - } - - var i = 0 - var order = [ 8, 6, 4, 2, 0 ] - setTimeout(function () { - l.forEach(function (val, key, cache) { - var j = order[i++] - t.equal(cache, l) - t.equal(key, j.toString()) - t.equal(val, j.toString(2)) - }) - t.equal(i, order.length); - - setTimeout(function () { - var count = 0; - l.forEach(function (val, key, cache) { count++; }) - t.equal(0, count); - t.end() - }, 25) - - }, 26) -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js deleted file mode 100644 index b5912f6f168e5e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node --expose_gc - - -var weak = require('weak'); -var test = require('tap').test -var LRU = require('../') -var l = new LRU({ max: 10 }) -var refs = 0 -function X() { - refs ++ - weak(this, deref) -} - -function deref() { - refs -- -} - -test('no leaks', function (t) { - // fill up the cache - for (var i = 0; i < 100; i++) { - l.set(i, new X); - // throw some gets in there, too. - if (i % 2 === 0) - l.get(i / 2) - } - - gc() - - var start = process.memoryUsage() - - // capture the memory - var startRefs = refs - - // do it again, but more - for (var i = 0; i < 10000; i++) { - l.set(i, new X); - // throw some gets in there, too. - if (i % 2 === 0) - l.get(i / 2) - } - - gc() - - var end = process.memoryUsage() - t.equal(refs, startRefs, 'no leaky refs') - - console.error('start: %j\n' + - 'end: %j', start, end); - t.pass(); - t.end(); -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/serialize.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/serialize.js deleted file mode 100644 index 5fe5dc3d371f1e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/lru-cache/test/serialize.js +++ /dev/null @@ -1,215 +0,0 @@ -var test = require('tap').test -var LRU = require('../') - -test('dump', function (t) { - var cache = new LRU() - - t.equal(cache.dump().length, 0, "nothing in dump for empty cache") - - cache.set("a", "A") - cache.set("b", "B") - t.deepEqual(cache.dump(), [ - { k: "b", v: "B", e: 0 }, - { k: "a", v: "A", e: 0 } - ]) - - cache.set("a", "A"); - t.deepEqual(cache.dump(), [ - { k: "a", v: "A", e: 0 }, - { k: "b", v: "B", e: 0 } - ]) - - cache.get("b"); - t.deepEqual(cache.dump(), [ - { k: "b", v: "B", e: 0 }, - { k: "a", v: "A", e: 0 } - ]) - - cache.del("a"); - t.deepEqual(cache.dump(), [ - { k: "b", v: "B", e: 0 } - ]) - - t.end() -}) - -test("do not dump stale items", function(t) { - var cache = new LRU({ - max: 5, - maxAge: 50 - }) - - //expires at 50 - cache.set("a", "A") - - setTimeout(function () { - //expires at 75 - cache.set("b", "B") - var s = cache.dump() - t.equal(s.length, 2) - t.equal(s[0].k, "b") - t.equal(s[1].k, "a") - }, 25) - - setTimeout(function () { - //expires at 110 - cache.set("c", "C") - var s = cache.dump() - t.equal(s.length, 2) - t.equal(s[0].k, "c") - t.equal(s[1].k, "b") - }, 60) - - setTimeout(function () { - //expires at 130 - cache.set("d", "D", 40) - var s = cache.dump() - t.equal(s.length, 2) - t.equal(s[0].k, "d") - t.equal(s[1].k, "c") - }, 90) - - setTimeout(function () { - var s = cache.dump() - t.equal(s.length, 1) - t.equal(s[0].k, "d") - }, 120) - - setTimeout(function () { - var s = cache.dump() - t.deepEqual(s, []) - t.end() - }, 155) -}) - -test("load basic cache", function(t) { - var cache = new LRU(), - copy = new LRU() - - cache.set("a", "A") - cache.set("b", "B") - - copy.load(cache.dump()) - t.deepEquals(cache.dump(), copy.dump()) - - t.end() -}) - - -test("load staled cache", function(t) { - var cache = new LRU({maxAge: 50}), - copy = new LRU({maxAge: 50}), - arr - - //expires at 50 - cache.set("a", "A") - setTimeout(function () { - //expires at 80 - cache.set("b", "B") - arr = cache.dump() - t.equal(arr.length, 2) - }, 30) - - setTimeout(function () { - copy.load(arr) - t.equal(copy.get("a"), undefined) - t.equal(copy.get("b"), "B") - }, 60) - - setTimeout(function () { - t.equal(copy.get("b"), undefined) - t.end() - }, 90) -}) - -test("load to other size cache", function(t) { - var cache = new LRU({max: 2}), - copy = new LRU({max: 1}) - - cache.set("a", "A") - cache.set("b", "B") - - copy.load(cache.dump()) - t.equal(copy.get("a"), undefined) - t.equal(copy.get("b"), "B") - - //update the last read from original cache - cache.get("a") - copy.load(cache.dump()) - t.equal(copy.get("a"), "A") - t.equal(copy.get("b"), undefined) - - t.end() -}) - - -test("load to other age cache", function(t) { - var cache = new LRU({maxAge: 50}), - aged = new LRU({maxAge: 100}), - simple = new LRU(), - arr, - expired - - //created at 0 - //a would be valid till 0 + 50 - cache.set("a", "A") - setTimeout(function () { - //created at 20 - //b would be valid till 20 + 50 - cache.set("b", "B") - //b would be valid till 20 + 70 - cache.set("c", "C", 70) - arr = cache.dump() - t.equal(arr.length, 3) - }, 20) - - setTimeout(function () { - t.equal(cache.get("a"), undefined) - t.equal(cache.get("b"), "B") - t.equal(cache.get("c"), "C") - - aged.load(arr) - t.equal(aged.get("a"), undefined) - t.equal(aged.get("b"), "B") - t.equal(aged.get("c"), "C") - - simple.load(arr) - t.equal(simple.get("a"), undefined) - t.equal(simple.get("b"), "B") - t.equal(simple.get("c"), "C") - }, 60) - - setTimeout(function () { - t.equal(cache.get("a"), undefined) - t.equal(cache.get("b"), undefined) - t.equal(cache.get("c"), "C") - - aged.load(arr) - t.equal(aged.get("a"), undefined) - t.equal(aged.get("b"), undefined) - t.equal(aged.get("c"), "C") - - simple.load(arr) - t.equal(simple.get("a"), undefined) - t.equal(simple.get("b"), undefined) - t.equal(simple.get("c"), "C") - }, 80) - - setTimeout(function () { - t.equal(cache.get("a"), undefined) - t.equal(cache.get("b"), undefined) - t.equal(cache.get("c"), undefined) - - aged.load(arr) - t.equal(aged.get("a"), undefined) - t.equal(aged.get("b"), undefined) - t.equal(aged.get("c"), undefined) - - simple.load(arr) - t.equal(simple.get("a"), undefined) - t.equal(simple.get("b"), undefined) - t.equal(simple.get("c"), undefined) - t.end() - }, 100) - -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/LICENSE deleted file mode 100644 index 19129e315fe593..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/README.md b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/README.md deleted file mode 100644 index 25a38a53fe2fea..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# sigmund - -Quick and dirty signatures for Objects. - -This is like a much faster `deepEquals` comparison, which returns a -string key suitable for caches and the like. - -## Usage - -```javascript -function doSomething (someObj) { - var key = sigmund(someObj, maxDepth) // max depth defaults to 10 - var cached = cache.get(key) - if (cached) return cached - - var result = expensiveCalculation(someObj) - cache.set(key, result) - return result -} -``` - -The resulting key will be as unique and reproducible as calling -`JSON.stringify` or `util.inspect` on the object, but is much faster. -In order to achieve this speed, some differences are glossed over. -For example, the object `{0:'foo'}` will be treated identically to the -array `['foo']`. - -Also, just as there is no way to summon the soul from the scribblings -of a cocaine-addled psychoanalyst, there is no way to revive the object -from the signature string that sigmund gives you. In fact, it's -barely even readable. - -As with `util.inspect` and `JSON.stringify`, larger objects will -produce larger signature strings. - -Because sigmund is a bit less strict than the more thorough -alternatives, the strings will be shorter, and also there is a -slightly higher chance for collisions. For example, these objects -have the same signature: - - var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]} - var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']} - -Like a good Freudian, sigmund is most effective when you already have -some understanding of what you're looking for. It can help you help -yourself, but you must be willing to do some work as well. - -Cycles are handled, and cyclical objects are silently omitted (though -the key is included in the signature output.) - -The second argument is the maximum depth, which defaults to 10, -because that is the maximum object traversal depth covered by most -insurance carriers. diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/bench.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/bench.js deleted file mode 100644 index 5acfd6d90de377..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/bench.js +++ /dev/null @@ -1,283 +0,0 @@ -// different ways to id objects -// use a req/res pair, since it's crazy deep and cyclical - -// sparseFE10 and sigmund are usually pretty close, which is to be expected, -// since they are essentially the same algorithm, except that sigmund handles -// regular expression objects properly. - - -var http = require('http') -var util = require('util') -var sigmund = require('./sigmund.js') -var sreq, sres, creq, cres, test - -http.createServer(function (q, s) { - sreq = q - sres = s - sres.end('ok') - this.close(function () { setTimeout(function () { - start() - }, 200) }) -}).listen(1337, function () { - creq = http.get({ port: 1337 }) - creq.on('response', function (s) { cres = s }) -}) - -function start () { - test = [sreq, sres, creq, cres] - // test = sreq - // sreq.sres = sres - // sreq.creq = creq - // sreq.cres = cres - - for (var i in exports.compare) { - console.log(i) - var hash = exports.compare[i]() - console.log(hash) - console.log(hash.length) - console.log('') - } - - require('bench').runMain() -} - -function customWs (obj, md, d) { - d = d || 0 - var to = typeof obj - if (to === 'undefined' || to === 'function' || to === null) return '' - if (d > md || !obj || to !== 'object') return ('' + obj).replace(/[\n ]+/g, '') - - if (Array.isArray(obj)) { - return obj.map(function (i, _, __) { - return customWs(i, md, d + 1) - }).reduce(function (a, b) { return a + b }, '') - } - - var keys = Object.keys(obj) - return keys.map(function (k, _, __) { - return k + ':' + customWs(obj[k], md, d + 1) - }).reduce(function (a, b) { return a + b }, '') -} - -function custom (obj, md, d) { - d = d || 0 - var to = typeof obj - if (to === 'undefined' || to === 'function' || to === null) return '' - if (d > md || !obj || to !== 'object') return '' + obj - - if (Array.isArray(obj)) { - return obj.map(function (i, _, __) { - return custom(i, md, d + 1) - }).reduce(function (a, b) { return a + b }, '') - } - - var keys = Object.keys(obj) - return keys.map(function (k, _, __) { - return k + ':' + custom(obj[k], md, d + 1) - }).reduce(function (a, b) { return a + b }, '') -} - -function sparseFE2 (obj, maxDepth) { - var seen = [] - var soFar = '' - function ch (v, depth) { - if (depth > maxDepth) return - if (typeof v === 'function' || typeof v === 'undefined') return - if (typeof v !== 'object' || !v) { - soFar += v - return - } - if (seen.indexOf(v) !== -1 || depth === maxDepth) return - seen.push(v) - soFar += '{' - Object.keys(v).forEach(function (k, _, __) { - // pseudo-private values. skip those. - if (k.charAt(0) === '_') return - var to = typeof v[k] - if (to === 'function' || to === 'undefined') return - soFar += k + ':' - ch(v[k], depth + 1) - }) - soFar += '}' - } - ch(obj, 0) - return soFar -} - -function sparseFE (obj, maxDepth) { - var seen = [] - var soFar = '' - function ch (v, depth) { - if (depth > maxDepth) return - if (typeof v === 'function' || typeof v === 'undefined') return - if (typeof v !== 'object' || !v) { - soFar += v - return - } - if (seen.indexOf(v) !== -1 || depth === maxDepth) return - seen.push(v) - soFar += '{' - Object.keys(v).forEach(function (k, _, __) { - // pseudo-private values. skip those. - if (k.charAt(0) === '_') return - var to = typeof v[k] - if (to === 'function' || to === 'undefined') return - soFar += k - ch(v[k], depth + 1) - }) - } - ch(obj, 0) - return soFar -} - -function sparse (obj, maxDepth) { - var seen = [] - var soFar = '' - function ch (v, depth) { - if (depth > maxDepth) return - if (typeof v === 'function' || typeof v === 'undefined') return - if (typeof v !== 'object' || !v) { - soFar += v - return - } - if (seen.indexOf(v) !== -1 || depth === maxDepth) return - seen.push(v) - soFar += '{' - for (var k in v) { - // pseudo-private values. skip those. - if (k.charAt(0) === '_') continue - var to = typeof v[k] - if (to === 'function' || to === 'undefined') continue - soFar += k - ch(v[k], depth + 1) - } - } - ch(obj, 0) - return soFar -} - -function noCommas (obj, maxDepth) { - var seen = [] - var soFar = '' - function ch (v, depth) { - if (depth > maxDepth) return - if (typeof v === 'function' || typeof v === 'undefined') return - if (typeof v !== 'object' || !v) { - soFar += v - return - } - if (seen.indexOf(v) !== -1 || depth === maxDepth) return - seen.push(v) - soFar += '{' - for (var k in v) { - // pseudo-private values. skip those. - if (k.charAt(0) === '_') continue - var to = typeof v[k] - if (to === 'function' || to === 'undefined') continue - soFar += k + ':' - ch(v[k], depth + 1) - } - soFar += '}' - } - ch(obj, 0) - return soFar -} - - -function flatten (obj, maxDepth) { - var seen = [] - var soFar = '' - function ch (v, depth) { - if (depth > maxDepth) return - if (typeof v === 'function' || typeof v === 'undefined') return - if (typeof v !== 'object' || !v) { - soFar += v - return - } - if (seen.indexOf(v) !== -1 || depth === maxDepth) return - seen.push(v) - soFar += '{' - for (var k in v) { - // pseudo-private values. skip those. - if (k.charAt(0) === '_') continue - var to = typeof v[k] - if (to === 'function' || to === 'undefined') continue - soFar += k + ':' - ch(v[k], depth + 1) - soFar += ',' - } - soFar += '}' - } - ch(obj, 0) - return soFar -} - -exports.compare = -{ - // 'custom 2': function () { - // return custom(test, 2, 0) - // }, - // 'customWs 2': function () { - // return customWs(test, 2, 0) - // }, - 'JSON.stringify (guarded)': function () { - var seen = [] - return JSON.stringify(test, function (k, v) { - if (typeof v !== 'object' || !v) return v - if (seen.indexOf(v) !== -1) return undefined - seen.push(v) - return v - }) - }, - - 'flatten 10': function () { - return flatten(test, 10) - }, - - // 'flattenFE 10': function () { - // return flattenFE(test, 10) - // }, - - 'noCommas 10': function () { - return noCommas(test, 10) - }, - - 'sparse 10': function () { - return sparse(test, 10) - }, - - 'sparseFE 10': function () { - return sparseFE(test, 10) - }, - - 'sparseFE2 10': function () { - return sparseFE2(test, 10) - }, - - sigmund: function() { - return sigmund(test, 10) - }, - - - // 'util.inspect 1': function () { - // return util.inspect(test, false, 1, false) - // }, - // 'util.inspect undefined': function () { - // util.inspect(test) - // }, - // 'util.inspect 2': function () { - // util.inspect(test, false, 2, false) - // }, - // 'util.inspect 3': function () { - // util.inspect(test, false, 3, false) - // }, - // 'util.inspect 4': function () { - // util.inspect(test, false, 4, false) - // }, - // 'util.inspect Infinity': function () { - // util.inspect(test, false, Infinity, false) - // } -} - -/** results -**/ diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/package.json deleted file mode 100644 index 4255e77a933eed..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "sigmund", - "version": "1.0.1", - "description": "Quick and dirty signatures for Objects.", - "main": "sigmund.js", - "directories": { - "test": "test" - }, - "dependencies": {}, - "devDependencies": { - "tap": "~0.3.0" - }, - "scripts": { - "test": "tap test/*.js", - "bench": "node bench.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/isaacs/sigmund.git" - }, - "keywords": [ - "object", - "signature", - "key", - "data", - "psychoanalysis" - ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "license": "ISC", - "gitHead": "527f97aa5bb253d927348698c0cd3bb267d098c6", - "bugs": { - "url": "https://github.com/isaacs/sigmund/issues" - }, - "homepage": "https://github.com/isaacs/sigmund#readme", - "_id": "sigmund@1.0.1", - "_shasum": "3ff21f198cad2175f9f3b781853fd94d0d19b590", - "_from": "sigmund@>=1.0.0 <1.1.0", - "_npmVersion": "2.10.0", - "_nodeVersion": "2.0.1", - "_npmUser": { - "name": "isaacs", - "email": "isaacs@npmjs.com" - }, - "dist": { - "shasum": "3ff21f198cad2175f9f3b781853fd94d0d19b590", - "tarball": "http://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - } - ], - "_resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/sigmund.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/sigmund.js deleted file mode 100644 index 82c7ab8ce995b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/sigmund.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = sigmund -function sigmund (subject, maxSessions) { - maxSessions = maxSessions || 10; - var notes = []; - var analysis = ''; - var RE = RegExp; - - function psychoAnalyze (subject, session) { - if (session > maxSessions) return; - - if (typeof subject === 'function' || - typeof subject === 'undefined') { - return; - } - - if (typeof subject !== 'object' || !subject || - (subject instanceof RE)) { - analysis += subject; - return; - } - - if (notes.indexOf(subject) !== -1 || session === maxSessions) return; - - notes.push(subject); - analysis += '{'; - Object.keys(subject).forEach(function (issue, _, __) { - // pseudo-private values. skip those. - if (issue.charAt(0) === '_') return; - var to = typeof subject[issue]; - if (to === 'function' || to === 'undefined') return; - analysis += issue; - psychoAnalyze(subject[issue], session + 1); - }); - } - psychoAnalyze(subject, 0); - return analysis; -} - -// vim: set softtabstop=4 shiftwidth=4: diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/test/basic.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/test/basic.js deleted file mode 100644 index 50c53a13e98d0e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/node_modules/sigmund/test/basic.js +++ /dev/null @@ -1,24 +0,0 @@ -var test = require('tap').test -var sigmund = require('../sigmund.js') - - -// occasionally there are duplicates -// that's an acceptable edge-case. JSON.stringify and util.inspect -// have some collision potential as well, though less, and collision -// detection is expensive. -var hash = '{abc/def/g{0h1i2{jkl' -var obj1 = {a:'b',c:/def/,g:['h','i',{j:'',k:'l'}]} -var obj2 = {a:'b',c:'/def/',g:['h','i','{jkl']} - -var obj3 = JSON.parse(JSON.stringify(obj1)) -obj3.c = /def/ -obj3.g[2].cycle = obj3 -var cycleHash = '{abc/def/g{0h1i2{jklcycle' - -test('basic', function (t) { - t.equal(sigmund(obj1), hash) - t.equal(sigmund(obj2), hash) - t.equal(sigmund(obj3), cycleHash) - t.end() -}) - diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/package.json b/deps/npm/node_modules/node-gyp/node_modules/minimatch/package.json index 8bf46ccae0c4f6..db541aec5b3604 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/minimatch/package.json @@ -6,53 +6,59 @@ }, "name": "minimatch", "description": "a glob matcher in javascript", - "version": "1.0.0", + "version": "3.0.2", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" }, "main": "minimatch.js", "scripts": { + "posttest": "standard minimatch.js test/*.js", "test": "tap test/*.js" }, "engines": { "node": "*" }, "dependencies": { - "lru-cache": "2", - "sigmund": "~1.0.0" + "brace-expansion": "^1.0.0" }, "devDependencies": { - "tap": "" + "standard": "^3.7.2", + "tap": "^5.6.0" }, - "license": { - "type": "MIT", - "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" - }, - "gitHead": "b374a643976eb55cdc19c60b6dd51ebe9bcc607a", + "license": "ISC", + "files": [ + "minimatch.js" + ], + "gitHead": "81edb7c763abd31ba981c87ec5e835f178786be0", "bugs": { "url": "https://github.com/isaacs/minimatch/issues" }, - "homepage": "https://github.com/isaacs/minimatch", - "_id": "minimatch@1.0.0", - "_shasum": "e0dd2120b49e1b724ce8d714c520822a9438576d", - "_from": "minimatch@>=1.0.0 <2.0.0", - "_npmVersion": "1.4.21", + "homepage": "https://github.com/isaacs/minimatch#readme", + "_id": "minimatch@3.0.2", + "_shasum": "0f398a7300ea441e9c348c83d98ab8c9dbf9c40a", + "_from": "minimatch@>=3.0.2 <4.0.0", + "_npmVersion": "3.9.1", + "_nodeVersion": "4.4.4", "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, + "dist": { + "shasum": "0f398a7300ea441e9c348c83d98ab8c9dbf9c40a", + "tarball": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz" + }, "maintainers": [ { "name": "isaacs", "email": "i@izs.me" } ], - "dist": { - "shasum": "e0dd2120b49e1b724ce8d714c520822a9438576d", - "tarball": "http://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz" + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/minimatch-3.0.2.tgz_1466194379770_0.11417287751100957" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-1.0.0.tgz", + "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz", "readme": "ERROR: No README data found!" } diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/basic.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/basic.js deleted file mode 100644 index ae7ac73c775edb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/basic.js +++ /dev/null @@ -1,399 +0,0 @@ -// http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test -// -// TODO: Some of these tests do very bad things with backslashes, and will -// most likely fail badly on windows. They should probably be skipped. - -var tap = require("tap") - , globalBefore = Object.keys(global) - , mm = require("../") - , files = [ "a", "b", "c", "d", "abc" - , "abd", "abe", "bb", "bcd" - , "ca", "cb", "dd", "de" - , "bdir/", "bdir/cfile"] - , next = files.concat([ "a-b", "aXb" - , ".x", ".y" ]) - - -var patterns = - [ "http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test" - , ["a*", ["a", "abc", "abd", "abe"]] - , ["X*", ["X*"], {nonull: true}] - - // allow null glob expansion - , ["X*", []] - - // isaacs: Slightly different than bash/sh/ksh - // \\* is not un-escaped to literal "*" in a failed match, - // but it does make it get treated as a literal star - , ["\\*", ["\\*"], {nonull: true}] - , ["\\**", ["\\**"], {nonull: true}] - , ["\\*\\*", ["\\*\\*"], {nonull: true}] - - , ["b*/", ["bdir/"]] - , ["c*", ["c", "ca", "cb"]] - , ["**", files] - - , ["\\.\\./*/", ["\\.\\./*/"], {nonull: true}] - , ["s/\\..*//", ["s/\\..*//"], {nonull: true}] - - , "legendary larry crashes bashes" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"], {nonull: true}] - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"], {nonull: true}] - - , "character classes" - , ["[a-c]b*", ["abc", "abd", "abe", "bb", "cb"]] - , ["[a-y]*[^c]", ["abd", "abe", "bb", "bcd", - "bdir/", "ca", "cb", "dd", "de"]] - , ["a*[^c]", ["abd", "abe"]] - , function () { files.push("a-b", "aXb") } - , ["a[X-]b", ["a-b", "aXb"]] - , function () { files.push(".x", ".y") } - , ["[^a-c]*", ["d", "dd", "de"]] - , function () { files.push("a*b/", "a*b/ooo") } - , ["a\\*b/*", ["a*b/ooo"]] - , ["a\\*?/*", ["a*b/ooo"]] - , ["*\\\\!*", [], {null: true}, ["echo !7"]] - , ["*\\!*", ["echo !7"], null, ["echo !7"]] - , ["*.\\*", ["r.*"], null, ["r.*"]] - , ["a[b]c", ["abc"]] - , ["a[\\b]c", ["abc"]] - , ["a?c", ["abc"]] - , ["a\\*c", [], {null: true}, ["abc"]] - , ["", [""], { null: true }, [""]] - - , "http://www.opensource.apple.com/source/bash/bash-23/" + - "bash/tests/glob-test" - , function () { files.push("man/", "man/man1/", "man/man1/bash.1") } - , ["*/man*/bash.*", ["man/man1/bash.1"]] - , ["man/man1/bash.1", ["man/man1/bash.1"]] - , ["a***c", ["abc"], null, ["abc"]] - , ["a*****?c", ["abc"], null, ["abc"]] - , ["?*****??", ["abc"], null, ["abc"]] - , ["*****??", ["abc"], null, ["abc"]] - , ["?*****?c", ["abc"], null, ["abc"]] - , ["?***?****c", ["abc"], null, ["abc"]] - , ["?***?****?", ["abc"], null, ["abc"]] - , ["?***?****", ["abc"], null, ["abc"]] - , ["*******c", ["abc"], null, ["abc"]] - , ["*******?", ["abc"], null, ["abc"]] - , ["a*cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??k***", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??***k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??***k**", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a****c**?**??*****", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["[-abc]", ["-"], null, ["-"]] - , ["[abc-]", ["-"], null, ["-"]] - , ["\\", ["\\"], null, ["\\"]] - , ["[\\\\]", ["\\"], null, ["\\"]] - , ["[[]", ["["], null, ["["]] - , ["[", ["["], null, ["["]] - , ["[*", ["[abc"], null, ["[abc"]] - , "a right bracket shall lose its special meaning and\n" + - "represent itself in a bracket expression if it occurs\n" + - "first in the list. -- POSIX.2 2.8.3.2" - , ["[]]", ["]"], null, ["]"]] - , ["[]-]", ["]"], null, ["]"]] - , ["[a-\z]", ["p"], null, ["p"]] - , ["??**********?****?", [], { null: true }, ["abc"]] - , ["??**********?****c", [], { null: true }, ["abc"]] - , ["?************c****?****", [], { null: true }, ["abc"]] - , ["*c*?**", [], { null: true }, ["abc"]] - , ["a*****c*?**", [], { null: true }, ["abc"]] - , ["a********???*******", [], { null: true }, ["abc"]] - , ["[]", [], { null: true }, ["a"]] - , ["[abc", [], { null: true }, ["["]] - - , "nocase tests" - , ["XYZ", ["xYz"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - , ["ab*", ["ABC"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - , ["[ia]?[ck]", ["ABC", "IjK"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - - // [ pattern, [matches], MM opts, files, TAP opts] - , "onestar/twostar" - , ["{/*,*}", [], {null: true}, ["/asdf/asdf/asdf"]] - , ["{/?,*}", ["/a", "bb"], {null: true} - , ["/a", "/b/b", "/a/b/c", "bb"]] - - , "dots should not match unless requested" - , ["**", ["a/b"], {}, ["a/b", "a/.d", ".a/.d"]] - - // .. and . can only match patterns starting with ., - // even when options.dot is set. - , function () { - files = ["a/./b", "a/../b", "a/c/b", "a/.d/b"] - } - , ["a/*/b", ["a/c/b", "a/.d/b"], {dot: true}] - , ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: true}] - , ["a/*/b", ["a/c/b"], {dot:false}] - , ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: false}] - - - // this also tests that changing the options needs - // to change the cache key, even if the pattern is - // the same! - , ["**", ["a/b","a/.d",".a/.d"], { dot: true } - , [ ".a/.d", "a/.d", "a/b"]] - - , "paren sets cannot contain slashes" - , ["*(a/b)", ["*(a/b)"], {nonull: true}, ["a/b"]] - - // brace sets trump all else. - // - // invalid glob pattern. fails on bash4 and bsdglob. - // however, in this implementation, it's easier just - // to do the intuitive thing, and let brace-expansion - // actually come before parsing any extglob patterns, - // like the documentation seems to say. - // - // XXX: if anyone complains about this, either fix it - // or tell them to grow up and stop complaining. - // - // bash/bsdglob says this: - // , ["*(a|{b),c)}", ["*(a|{b),c)}"], {}, ["a", "ab", "ac", "ad"]] - // but we do this instead: - , ["*(a|{b),c)}", ["a", "ab", "ac"], {}, ["a", "ab", "ac", "ad"]] - - // test partial parsing in the presence of comment/negation chars - , ["[!a*", ["[!ab"], {}, ["[!ab", "[ab"]] - , ["[#a*", ["[#ab"], {}, ["[#ab", "[ab"]] - - // like: {a,b|c\\,d\\\|e} except it's unclosed, so it has to be escaped. - , ["+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g" - , ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g"] - , {} - , ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g", "a", "b\\c"]] - - - // crazy nested {,,} and *(||) tests. - , function () { - files = [ "a", "b", "c", "d" - , "ab", "ac", "ad" - , "bc", "cb" - , "bc,d", "c,db", "c,d" - , "d)", "(b|c", "*(b|c" - , "b|c", "b|cc", "cb|c" - , "x(a|b|c)", "x(a|c)" - , "(a|b|c)", "(a|c)"] - } - , ["*(a|{b,c})", ["a", "b", "c", "ab", "ac"]] - , ["{a,*(b|c,d)}", ["a","(b|c", "*(b|c", "d)"]] - // a - // *(b|c) - // *(b|d) - , ["{a,*(b|{c,d})}", ["a","b", "bc", "cb", "c", "d"]] - , ["*(a|{b|c,c})", ["a", "b", "c", "ab", "ac", "bc", "cb"]] - - - // test various flag settings. - , [ "*(a|{b|c,c})", ["x(a|b|c)", "x(a|c)", "(a|b|c)", "(a|c)"] - , { noext: true } ] - , ["a?b", ["x/y/acb", "acb/"], {matchBase: true} - , ["x/y/acb", "acb/", "acb/d/e", "x/y/acb/d"] ] - , ["#*", ["#a", "#b"], {nocomment: true}, ["#a", "#b", "c#d"]] - - - // begin channelling Boole and deMorgan... - , "negation tests" - , function () { - files = ["d", "e", "!ab", "!abc", "a!b", "\\!a"] - } - - // anything that is NOT a* matches. - , ["!a*", ["\\!a", "d", "e", "!ab", "!abc"]] - - // anything that IS !a* matches. - , ["!a*", ["!ab", "!abc"], {nonegate: true}] - - // anything that IS a* matches - , ["!!a*", ["a!b"]] - - // anything that is NOT !a* matches - , ["!\\!a*", ["a!b", "d", "e", "\\!a"]] - - // negation nestled within a pattern - , function () { - files = [ "foo.js" - , "foo.bar" - // can't match this one without negative lookbehind. - , "foo.js.js" - , "blar.js" - , "foo." - , "boo.js.boo" ] - } - , ["*.!(js)", ["foo.bar", "foo.", "boo.js.boo"] ] - - // https://github.com/isaacs/minimatch/issues/5 - , function () { - files = [ 'a/b/.x/c' - , 'a/b/.x/c/d' - , 'a/b/.x/c/d/e' - , 'a/b/.x' - , 'a/b/.x/' - , 'a/.x/b' - , '.x' - , '.x/' - , '.x/a' - , '.x/a/b' - , 'a/.x/b/.x/c' - , '.x/.x' ] - } - , ["**/.x/**", [ '.x/' - , '.x/a' - , '.x/a/b' - , 'a/.x/b' - , 'a/b/.x/' - , 'a/b/.x/c' - , 'a/b/.x/c/d' - , 'a/b/.x/c/d/e' ] ] - - ] - -var regexps = - [ '/^(?:(?=.)a[^/]*?)$/', - '/^(?:(?=.)X[^/]*?)$/', - '/^(?:(?=.)X[^/]*?)$/', - '/^(?:\\*)$/', - '/^(?:(?=.)\\*[^/]*?)$/', - '/^(?:\\*\\*)$/', - '/^(?:(?=.)b[^/]*?\\/)$/', - '/^(?:(?=.)c[^/]*?)$/', - '/^(?:(?:(?!(?:\\/|^)\\.).)*?)$/', - '/^(?:\\.\\.\\/(?!\\.)(?=.)[^/]*?\\/)$/', - '/^(?:s\\/(?=.)\\.\\.[^/]*?\\/)$/', - '/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/1\\/)$/', - '/^(?:\\/\\^root:\\/\\{s\\/(?=.)\\^[^:][^/]*?:[^:][^/]*?:\\([^:]\\)[^/]*?\\.[^/]*?\\$\\/\u0001\\/)$/', - '/^(?:(?!\\.)(?=.)[a-c]b[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[a-y][^/]*?[^c])$/', - '/^(?:(?=.)a[^/]*?[^c])$/', - '/^(?:(?=.)a[X-]b)$/', - '/^(?:(?!\\.)(?=.)[^a-c][^/]*?)$/', - '/^(?:a\\*b\\/(?!\\.)(?=.)[^/]*?)$/', - '/^(?:(?=.)a\\*[^/]\\/(?!\\.)(?=.)[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\\\\\![^/]*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\![^/]*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\.\\*)$/', - '/^(?:(?=.)a[b]c)$/', - '/^(?:(?=.)a[b]c)$/', - '/^(?:(?=.)a[^/]c)$/', - '/^(?:a\\*c)$/', - 'false', - '/^(?:(?!\\.)(?=.)[^/]*?\\/(?=.)man[^/]*?\\/(?=.)bash\\.[^/]*?)$/', - '/^(?:man\\/man1\\/bash\\.1)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?c)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]c)$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/])$/', - '/^(?:(?!\\.)(?=.)[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/])$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]c)$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?c)$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/])$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?c)$/', - '/^(?:(?!\\.)(?=.)[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/])$/', - '/^(?:(?=.)a[^/]*?cd[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/]k)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/][^/]*?[^/]*?cd[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/]k)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/][^/]*?[^/]*?cd[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/]k[^/]*?[^/]*?[^/]*?)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/][^/]*?[^/]*?cd[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/][^/]*?[^/]*?[^/]*?k)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/][^/]*?[^/]*?cd[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/][^/]*?[^/]*?[^/]*?k[^/]*?[^/]*?)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?c[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[-abc])$/', - '/^(?:(?!\\.)(?=.)[abc-])$/', - '/^(?:\\\\)$/', - '/^(?:(?!\\.)(?=.)[\\\\])$/', - '/^(?:(?!\\.)(?=.)[\\[])$/', - '/^(?:\\[)$/', - '/^(?:(?=.)\\[(?!\\.)(?=.)[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[\\]])$/', - '/^(?:(?!\\.)(?=.)[\\]-])$/', - '/^(?:(?!\\.)(?=.)[a-z])$/', - '/^(?:(?!\\.)(?=.)[^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/])$/', - '/^(?:(?!\\.)(?=.)[^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?c)$/', - '/^(?:(?!\\.)(?=.)[^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?c[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/]*?[^/]*?[^/]*?[^/]*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?c[^/]*?[^/][^/]*?[^/]*?)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?c[^/]*?[^/][^/]*?[^/]*?)$/', - '/^(?:(?=.)a[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/][^/][^/][^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?[^/]*?)$/', - '/^(?:\\[\\])$/', - '/^(?:\\[abc)$/', - '/^(?:(?=.)XYZ)$/i', - '/^(?:(?=.)ab[^/]*?)$/i', - '/^(?:(?!\\.)(?=.)[ia][^/][ck])$/i', - '/^(?:\\/(?!\\.)(?=.)[^/]*?|(?!\\.)(?=.)[^/]*?)$/', - '/^(?:\\/(?!\\.)(?=.)[^/]|(?!\\.)(?=.)[^/]*?)$/', - '/^(?:(?:(?!(?:\\/|^)\\.).)*?)$/', - '/^(?:a\\/(?!(?:^|\\/)\\.{1,2}(?:$|\\/))(?=.)[^/]*?\\/b)$/', - '/^(?:a\\/(?=.)\\.[^/]*?\\/b)$/', - '/^(?:a\\/(?!\\.)(?=.)[^/]*?\\/b)$/', - '/^(?:a\\/(?=.)\\.[^/]*?\\/b)$/', - '/^(?:(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?)$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\(a\\/b\\))$/', - '/^(?:(?!\\.)(?=.)(?:a|b)*|(?!\\.)(?=.)(?:a|c)*)$/', - '/^(?:(?=.)\\[(?=.)\\!a[^/]*?)$/', - '/^(?:(?=.)\\[(?=.)#a[^/]*?)$/', - '/^(?:(?=.)\\+\\(a\\|[^/]*?\\|c\\\\\\\\\\|d\\\\\\\\\\|e\\\\\\\\\\\\\\\\\\|f\\\\\\\\\\\\\\\\\\|g)$/', - '/^(?:(?!\\.)(?=.)(?:a|b)*|(?!\\.)(?=.)(?:a|c)*)$/', - '/^(?:a|(?!\\.)(?=.)[^/]*?\\(b\\|c|d\\))$/', - '/^(?:a|(?!\\.)(?=.)(?:b|c)*|(?!\\.)(?=.)(?:b|d)*)$/', - '/^(?:(?!\\.)(?=.)(?:a|b|c)*|(?!\\.)(?=.)(?:a|c)*)$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\(a\\|b\\|c\\)|(?!\\.)(?=.)[^/]*?\\(a\\|c\\))$/', - '/^(?:(?=.)a[^/]b)$/', - '/^(?:(?=.)#[^/]*?)$/', - '/^(?!^(?:(?=.)a[^/]*?)$).*$/', - '/^(?:(?=.)\\!a[^/]*?)$/', - '/^(?:(?=.)a[^/]*?)$/', - '/^(?!^(?:(?=.)\\!a[^/]*?)$).*$/', - '/^(?:(?!\\.)(?=.)[^/]*?\\.(?:(?!js)[^/]*?))$/', - '/^(?:(?:(?!(?:\\/|^)\\.).)*?\\/\\.x\\/(?:(?!(?:\\/|^)\\.).)*?)$/' ] -var re = 0; - -tap.test("basic tests", function (t) { - var start = Date.now() - - // [ pattern, [matches], MM opts, files, TAP opts] - patterns.forEach(function (c) { - if (typeof c === "function") return c() - if (typeof c === "string") return t.comment(c) - - var pattern = c[0] - , expect = c[1].sort(alpha) - , options = c[2] || {} - , f = c[3] || files - , tapOpts = c[4] || {} - - // options.debug = true - var m = new mm.Minimatch(pattern, options) - var r = m.makeRe() - var expectRe = regexps[re++] - tapOpts.re = String(r) || JSON.stringify(r) - tapOpts.files = JSON.stringify(f) - tapOpts.pattern = pattern - tapOpts.set = m.set - tapOpts.negated = m.negate - - var actual = mm.match(f, pattern, options) - actual.sort(alpha) - - t.equivalent( actual, expect - , JSON.stringify(pattern) + " " + JSON.stringify(expect) - , tapOpts ) - - t.equal(tapOpts.re, expectRe, tapOpts) - }) - - t.comment("time=" + (Date.now() - start) + "ms") - t.end() -}) - -tap.test("global leak test", function (t) { - var globalAfter = Object.keys(global) - t.equivalent(globalAfter, globalBefore, "no new globals, please") - t.end() -}) - -function alpha (a, b) { - return a > b ? 1 : -1 -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/brace-expand.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/brace-expand.js deleted file mode 100644 index e63d3f60c80e82..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/brace-expand.js +++ /dev/null @@ -1,40 +0,0 @@ -var tap = require("tap") - , minimatch = require("../") - -tap.test("brace expansion", function (t) { - // [ pattern, [expanded] ] - ; [ [ "a{b,c{d,e},{f,g}h}x{y,z}" - , [ "abxy" - , "abxz" - , "acdxy" - , "acdxz" - , "acexy" - , "acexz" - , "afhxy" - , "afhxz" - , "aghxy" - , "aghxz" ] ] - , [ "a{1..5}b" - , [ "a1b" - , "a2b" - , "a3b" - , "a4b" - , "a5b" ] ] - , [ "a{b}c", ["a{b}c"] ] - , [ "a{00..05}b" - , ["a00b" - ,"a01b" - ,"a02b" - ,"a03b" - ,"a04b" - ,"a05b" ] ] - ].forEach(function (tc) { - var p = tc[0] - , expect = tc[1] - t.equivalent(minimatch.braceExpand(p), expect, p) - }) - console.error("ending") - t.end() -}) - - diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/caching.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/caching.js deleted file mode 100644 index 0fec4b0fad0bf8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/caching.js +++ /dev/null @@ -1,14 +0,0 @@ -var Minimatch = require("../minimatch.js").Minimatch -var tap = require("tap") -tap.test("cache test", function (t) { - var mm1 = new Minimatch("a?b") - var mm2 = new Minimatch("a?b") - t.equal(mm1, mm2, "should get the same object") - // the lru should drop it after 100 entries - for (var i = 0; i < 100; i ++) { - new Minimatch("a"+i) - } - mm2 = new Minimatch("a?b") - t.notEqual(mm1, mm2, "cache should have dropped") - t.end() -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/defaults.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/defaults.js deleted file mode 100644 index 75e05712d4c841..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/defaults.js +++ /dev/null @@ -1,274 +0,0 @@ -// http://www.bashcookbook.com/bashinfo/source/bash-1.14.7/tests/glob-test -// -// TODO: Some of these tests do very bad things with backslashes, and will -// most likely fail badly on windows. They should probably be skipped. - -var tap = require("tap") - , globalBefore = Object.keys(global) - , mm = require("../") - , files = [ "a", "b", "c", "d", "abc" - , "abd", "abe", "bb", "bcd" - , "ca", "cb", "dd", "de" - , "bdir/", "bdir/cfile"] - , next = files.concat([ "a-b", "aXb" - , ".x", ".y" ]) - -tap.test("basic tests", function (t) { - var start = Date.now() - - // [ pattern, [matches], MM opts, files, TAP opts] - ; [ "http://www.bashcookbook.com/bashinfo" + - "/source/bash-1.14.7/tests/glob-test" - , ["a*", ["a", "abc", "abd", "abe"]] - , ["X*", ["X*"], {nonull: true}] - - // allow null glob expansion - , ["X*", []] - - // isaacs: Slightly different than bash/sh/ksh - // \\* is not un-escaped to literal "*" in a failed match, - // but it does make it get treated as a literal star - , ["\\*", ["\\*"], {nonull: true}] - , ["\\**", ["\\**"], {nonull: true}] - , ["\\*\\*", ["\\*\\*"], {nonull: true}] - - , ["b*/", ["bdir/"]] - , ["c*", ["c", "ca", "cb"]] - , ["**", files] - - , ["\\.\\./*/", ["\\.\\./*/"], {nonull: true}] - , ["s/\\..*//", ["s/\\..*//"], {nonull: true}] - - , "legendary larry crashes bashes" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\\1/"], {nonull: true}] - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/" - , ["/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/"], {nonull: true}] - - , "character classes" - , ["[a-c]b*", ["abc", "abd", "abe", "bb", "cb"]] - , ["[a-y]*[^c]", ["abd", "abe", "bb", "bcd", - "bdir/", "ca", "cb", "dd", "de"]] - , ["a*[^c]", ["abd", "abe"]] - , function () { files.push("a-b", "aXb") } - , ["a[X-]b", ["a-b", "aXb"]] - , function () { files.push(".x", ".y") } - , ["[^a-c]*", ["d", "dd", "de"]] - , function () { files.push("a*b/", "a*b/ooo") } - , ["a\\*b/*", ["a*b/ooo"]] - , ["a\\*?/*", ["a*b/ooo"]] - , ["*\\\\!*", [], {null: true}, ["echo !7"]] - , ["*\\!*", ["echo !7"], null, ["echo !7"]] - , ["*.\\*", ["r.*"], null, ["r.*"]] - , ["a[b]c", ["abc"]] - , ["a[\\b]c", ["abc"]] - , ["a?c", ["abc"]] - , ["a\\*c", [], {null: true}, ["abc"]] - , ["", [""], { null: true }, [""]] - - , "http://www.opensource.apple.com/source/bash/bash-23/" + - "bash/tests/glob-test" - , function () { files.push("man/", "man/man1/", "man/man1/bash.1") } - , ["*/man*/bash.*", ["man/man1/bash.1"]] - , ["man/man1/bash.1", ["man/man1/bash.1"]] - , ["a***c", ["abc"], null, ["abc"]] - , ["a*****?c", ["abc"], null, ["abc"]] - , ["?*****??", ["abc"], null, ["abc"]] - , ["*****??", ["abc"], null, ["abc"]] - , ["?*****?c", ["abc"], null, ["abc"]] - , ["?***?****c", ["abc"], null, ["abc"]] - , ["?***?****?", ["abc"], null, ["abc"]] - , ["?***?****", ["abc"], null, ["abc"]] - , ["*******c", ["abc"], null, ["abc"]] - , ["*******?", ["abc"], null, ["abc"]] - , ["a*cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??k***", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??***k", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a**?**cd**?**??***k**", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["a****c**?**??*****", ["abcdecdhjk"], null, ["abcdecdhjk"]] - , ["[-abc]", ["-"], null, ["-"]] - , ["[abc-]", ["-"], null, ["-"]] - , ["\\", ["\\"], null, ["\\"]] - , ["[\\\\]", ["\\"], null, ["\\"]] - , ["[[]", ["["], null, ["["]] - , ["[", ["["], null, ["["]] - , ["[*", ["[abc"], null, ["[abc"]] - , "a right bracket shall lose its special meaning and\n" + - "represent itself in a bracket expression if it occurs\n" + - "first in the list. -- POSIX.2 2.8.3.2" - , ["[]]", ["]"], null, ["]"]] - , ["[]-]", ["]"], null, ["]"]] - , ["[a-\z]", ["p"], null, ["p"]] - , ["??**********?****?", [], { null: true }, ["abc"]] - , ["??**********?****c", [], { null: true }, ["abc"]] - , ["?************c****?****", [], { null: true }, ["abc"]] - , ["*c*?**", [], { null: true }, ["abc"]] - , ["a*****c*?**", [], { null: true }, ["abc"]] - , ["a********???*******", [], { null: true }, ["abc"]] - , ["[]", [], { null: true }, ["a"]] - , ["[abc", [], { null: true }, ["["]] - - , "nocase tests" - , ["XYZ", ["xYz"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - , ["ab*", ["ABC"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - , ["[ia]?[ck]", ["ABC", "IjK"], { nocase: true, null: true } - , ["xYz", "ABC", "IjK"]] - - // [ pattern, [matches], MM opts, files, TAP opts] - , "onestar/twostar" - , ["{/*,*}", [], {null: true}, ["/asdf/asdf/asdf"]] - , ["{/?,*}", ["/a", "bb"], {null: true} - , ["/a", "/b/b", "/a/b/c", "bb"]] - - , "dots should not match unless requested" - , ["**", ["a/b"], {}, ["a/b", "a/.d", ".a/.d"]] - - // .. and . can only match patterns starting with ., - // even when options.dot is set. - , function () { - files = ["a/./b", "a/../b", "a/c/b", "a/.d/b"] - } - , ["a/*/b", ["a/c/b", "a/.d/b"], {dot: true}] - , ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: true}] - , ["a/*/b", ["a/c/b"], {dot:false}] - , ["a/.*/b", ["a/./b", "a/../b", "a/.d/b"], {dot: false}] - - - // this also tests that changing the options needs - // to change the cache key, even if the pattern is - // the same! - , ["**", ["a/b","a/.d",".a/.d"], { dot: true } - , [ ".a/.d", "a/.d", "a/b"]] - - , "paren sets cannot contain slashes" - , ["*(a/b)", ["*(a/b)"], {nonull: true}, ["a/b"]] - - // brace sets trump all else. - // - // invalid glob pattern. fails on bash4 and bsdglob. - // however, in this implementation, it's easier just - // to do the intuitive thing, and let brace-expansion - // actually come before parsing any extglob patterns, - // like the documentation seems to say. - // - // XXX: if anyone complains about this, either fix it - // or tell them to grow up and stop complaining. - // - // bash/bsdglob says this: - // , ["*(a|{b),c)}", ["*(a|{b),c)}"], {}, ["a", "ab", "ac", "ad"]] - // but we do this instead: - , ["*(a|{b),c)}", ["a", "ab", "ac"], {}, ["a", "ab", "ac", "ad"]] - - // test partial parsing in the presence of comment/negation chars - , ["[!a*", ["[!ab"], {}, ["[!ab", "[ab"]] - , ["[#a*", ["[#ab"], {}, ["[#ab", "[ab"]] - - // like: {a,b|c\\,d\\\|e} except it's unclosed, so it has to be escaped. - , ["+(a|*\\|c\\\\|d\\\\\\|e\\\\\\\\|f\\\\\\\\\\|g" - , ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g"] - , {} - , ["+(a|b\\|c\\\\|d\\\\|e\\\\\\\\|f\\\\\\\\|g", "a", "b\\c"]] - - - // crazy nested {,,} and *(||) tests. - , function () { - files = [ "a", "b", "c", "d" - , "ab", "ac", "ad" - , "bc", "cb" - , "bc,d", "c,db", "c,d" - , "d)", "(b|c", "*(b|c" - , "b|c", "b|cc", "cb|c" - , "x(a|b|c)", "x(a|c)" - , "(a|b|c)", "(a|c)"] - } - , ["*(a|{b,c})", ["a", "b", "c", "ab", "ac"]] - , ["{a,*(b|c,d)}", ["a","(b|c", "*(b|c", "d)"]] - // a - // *(b|c) - // *(b|d) - , ["{a,*(b|{c,d})}", ["a","b", "bc", "cb", "c", "d"]] - , ["*(a|{b|c,c})", ["a", "b", "c", "ab", "ac", "bc", "cb"]] - - - // test various flag settings. - , [ "*(a|{b|c,c})", ["x(a|b|c)", "x(a|c)", "(a|b|c)", "(a|c)"] - , { noext: true } ] - , ["a?b", ["x/y/acb", "acb/"], {matchBase: true} - , ["x/y/acb", "acb/", "acb/d/e", "x/y/acb/d"] ] - , ["#*", ["#a", "#b"], {nocomment: true}, ["#a", "#b", "c#d"]] - - - // begin channelling Boole and deMorgan... - , "negation tests" - , function () { - files = ["d", "e", "!ab", "!abc", "a!b", "\\!a"] - } - - // anything that is NOT a* matches. - , ["!a*", ["\\!a", "d", "e", "!ab", "!abc"]] - - // anything that IS !a* matches. - , ["!a*", ["!ab", "!abc"], {nonegate: true}] - - // anything that IS a* matches - , ["!!a*", ["a!b"]] - - // anything that is NOT !a* matches - , ["!\\!a*", ["a!b", "d", "e", "\\!a"]] - - // negation nestled within a pattern - , function () { - files = [ "foo.js" - , "foo.bar" - // can't match this one without negative lookbehind. - , "foo.js.js" - , "blar.js" - , "foo." - , "boo.js.boo" ] - } - , ["*.!(js)", ["foo.bar", "foo.", "boo.js.boo"] ] - - ].forEach(function (c) { - if (typeof c === "function") return c() - if (typeof c === "string") return t.comment(c) - - var pattern = c[0] - , expect = c[1].sort(alpha) - , options = c[2] - , f = c[3] || files - , tapOpts = c[4] || {} - - // options.debug = true - var Class = mm.defaults(options).Minimatch - var m = new Class(pattern, {}) - var r = m.makeRe() - tapOpts.re = String(r) || JSON.stringify(r) - tapOpts.files = JSON.stringify(f) - tapOpts.pattern = pattern - tapOpts.set = m.set - tapOpts.negated = m.negate - - var actual = mm.match(f, pattern, options) - actual.sort(alpha) - - t.equivalent( actual, expect - , JSON.stringify(pattern) + " " + JSON.stringify(expect) - , tapOpts ) - }) - - t.comment("time=" + (Date.now() - start) + "ms") - t.end() -}) - -tap.test("global leak test", function (t) { - var globalAfter = Object.keys(global) - t.equivalent(globalAfter, globalBefore, "no new globals, please") - t.end() -}) - -function alpha (a, b) { - return a > b ? 1 : -1 -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/extglob-ending-with-state-char.js b/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/extglob-ending-with-state-char.js deleted file mode 100644 index 6676e2629a7e99..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/minimatch/test/extglob-ending-with-state-char.js +++ /dev/null @@ -1,8 +0,0 @@ -var test = require('tap').test -var minimatch = require('../') - -test('extglob ending with statechar', function(t) { - t.notOk(minimatch('ax', 'a?(b*)')) - t.ok(minimatch('ax', '?(a*|b)')) - t.end() -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json index 253335e6234907..e36489efb5bbb2 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json @@ -40,7 +40,7 @@ ], "dist": { "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "http://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json index 687bfd6a946c67..40adf87cf05212 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json @@ -65,7 +65,7 @@ ], "dist": { "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "http://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" }, "directories": {}, "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml index 6830765b567773..0b1f5e4ae340b6 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml @@ -4,6 +4,7 @@ node_js: - 0.12 - v4 - v5 + - v6 notifications: email: diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES index cbedd4244bc8b6..6aebe74ada9f65 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES @@ -1,3 +1,9 @@ +v3.1.0 -- 2016.05.17 +* Fix internals of symbol detection +* Ensure Symbol.prototype[Symbol.toPrimitive] in all cases returns primitive value + (fixes Node v6 support) +* Create native symbols whenver possible + v3.0.2 -- 2015.12.12 * Fix definition flow, so uneven state of Symbol implementation doesn't crash initialization of polyfill. See #13 diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js index 53759f32124b1c..93629d2f84768a 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js @@ -1,18 +1,17 @@ 'use strict'; +var validTypes = { object: true, symbol: true }; + module.exports = function () { var symbol; if (typeof Symbol !== 'function') return false; symbol = Symbol('test symbol'); try { String(symbol); } catch (e) { return false; } - if (typeof Symbol.iterator === 'symbol') return true; - // Return 'true' for polyfills - if (typeof Symbol.isConcatSpreadable !== 'object') return false; - if (typeof Symbol.iterator !== 'object') return false; - if (typeof Symbol.toPrimitive !== 'object') return false; - if (typeof Symbol.toStringTag !== 'object') return false; - if (typeof Symbol.unscopables !== 'object') return false; + // Return 'true' also for polyfills + if (!validTypes[typeof Symbol.iterator]) return false; + if (!validTypes[typeof Symbol.toPrimitive]) return false; + if (!validTypes[typeof Symbol.toStringTag]) return false; return true; }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js index a8cb8b8681ee69..5f073a19cab7c8 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js @@ -4,5 +4,5 @@ module.exports = (function () { if (typeof Symbol !== 'function') return false; - return (typeof Symbol.iterator === 'symbol'); + return (typeof Symbol() === 'symbol'); }()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js index beeba2cb4fa23f..074cb07fb575c2 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js @@ -1,5 +1,9 @@ 'use strict'; module.exports = function (x) { - return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; + if (!x) return false; + if (typeof x === 'symbol') return true; + if (!x.constructor) return false; + if (x.constructor.name !== 'Symbol') return false; + return (x[x.constructor.toStringTag] === 'Symbol'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.lint b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.lint new file mode 100644 index 00000000000000..df1e53cd5f547e --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.lint @@ -0,0 +1,15 @@ +@root + +module + +tabs +indent 2 +maxlen 100 + +ass +nomen +plusplus +newcap +vars + +predef+ Symbol diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.npmignore new file mode 100644 index 00000000000000..155e41f69142ef --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.npmignore @@ -0,0 +1,4 @@ +.DS_Store +/node_modules +/npm-debug.log +/.lintcache diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml new file mode 100644 index 00000000000000..6830765b567773 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/.travis.yml @@ -0,0 +1,10 @@ +sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ +language: node_js +node_js: + - 0.12 + - v4 + - v5 + +notifications: + email: + - medikoo+es6-symbol@medikoo.com diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/CHANGES new file mode 100644 index 00000000000000..cbedd4244bc8b6 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/CHANGES @@ -0,0 +1,46 @@ +v3.0.2 -- 2015.12.12 +* Fix definition flow, so uneven state of Symbol implementation doesn't crash initialization of + polyfill. See #13 + +v3.0.1 -- 2015.10.22 +* Workaround for IE11 bug (reported in #12) + +v3.0.0 -- 2015.10.02 +* Reuse native symbols (e.g. iterator, toStringTag etc.) in a polyfill if they're available + Otherwise polyfill symbols may not be recognized by other functions +* Improve documentation + +v2.0.1 -- 2015.01.28 +* Fix Symbol.prototype[Symbol.isPrimitive] implementation +* Improve validation within Symbol.prototype.toString and + Symbol.prototype.valueOf + +v2.0.0 -- 2015.01.28 +* Update up to changes in specification: + * Implement `for` and `keyFor` + * Remove `Symbol.create` and `Symbol.isRegExp` + * Add `Symbol.match`, `Symbol.replace`, `Symbol.search`, `Symbol.species` and + `Symbol.split` +* Rename `validSymbol` to `validateSymbol` +* Improve documentation +* Remove dead test modules + +v1.0.0 -- 2015.01.26 +* Fix enumerability for symbol properties set normally (e.g. obj[symbol] = value) +* Introduce initialization via hidden constructor +* Fix isSymbol handling of polyfill values when native Symbol is present +* Fix spelling of LICENSE +* Configure lint scripts + +v0.1.1 -- 2014.10.07 +* Fix isImplemented, so it returns true in case of polyfill +* Improve documentations + +v0.1.0 -- 2014.04.28 +* Assure strictly npm dependencies +* Update to use latest versions of dependencies +* Fix implementation detection so it doesn't crash on `String(symbol)` +* throw on `new Symbol()` (as decided by TC39) + +v0.0.0 -- 2013.11.15 +* Initial (dev) version \ No newline at end of file diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/LICENSE new file mode 100644 index 00000000000000..04724a3ab1b70b --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/README.md new file mode 100644 index 00000000000000..0fa8978450cb4f --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/README.md @@ -0,0 +1,71 @@ +# es6-symbol +## ECMAScript 6 Symbol polyfill + +For more information about symbols see following links +- [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html) +- [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) +- [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor) + +### Limitations + +Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely. + +### Usage + +It’s safest to use *es6-symbol* as a [ponyfill](http://kikobeats.com/polyfill-ponyfill-and-prollyfill/) – a polyfill which doesn’t touch global objects: + +```javascript +var Symbol = require('es6-symbol'); +``` + +If you want to make sure your environment implements `Symbol` globally, do: + +```javascript +require('es6-symbol/implement'); +``` + +If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do: + +```javascript +var Symbol = require('es6-symbol/polyfill'); +``` + +#### API + +Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples: + +```javascript +var Symbol = require('es6-symbol'); + +var symbol = Symbol('My custom symbol'); +var x = {}; + +x[symbol] = 'foo'; +console.log(x[symbol]); 'foo' + +// Detect iterable: +var iterator, result; +if (possiblyIterable[Symbol.iterator]) { + iterator = possiblyIterable[Symbol.iterator](); + result = iterator.next(); + while(!result.done) { + console.log(result.value); + result = iterator.next(); + } +} +``` + +### Installation +#### NPM + +In your project path: + + $ npm install es6-symbol + +##### Browser + +To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) + +## Tests [![Build Status](https://travis-ci.org/medikoo/es6-symbol.png)](https://travis-ci.org/medikoo/es6-symbol) + + $ npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/implement.js new file mode 100644 index 00000000000000..153edacdbedf9b --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/implement.js @@ -0,0 +1,7 @@ +'use strict'; + +if (!require('./is-implemented')()) { + Object.defineProperty(require('es5-ext/global'), 'Symbol', + { value: require('./polyfill'), configurable: true, enumerable: false, + writable: true }); +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/index.js new file mode 100644 index 00000000000000..609f1faf551164 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js new file mode 100644 index 00000000000000..53759f32124b1c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-implemented.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function () { + var symbol; + if (typeof Symbol !== 'function') return false; + symbol = Symbol('test symbol'); + try { String(symbol); } catch (e) { return false; } + if (typeof Symbol.iterator === 'symbol') return true; + + // Return 'true' for polyfills + if (typeof Symbol.isConcatSpreadable !== 'object') return false; + if (typeof Symbol.iterator !== 'object') return false; + if (typeof Symbol.toPrimitive !== 'object') return false; + if (typeof Symbol.toStringTag !== 'object') return false; + if (typeof Symbol.unscopables !== 'object') return false; + + return true; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js new file mode 100644 index 00000000000000..a8cb8b8681ee69 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-native-implemented.js @@ -0,0 +1,8 @@ +// Exports true if environment provides native `Symbol` implementation + +'use strict'; + +module.exports = (function () { + if (typeof Symbol !== 'function') return false; + return (typeof Symbol.iterator === 'symbol'); +}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js new file mode 100644 index 00000000000000..beeba2cb4fa23f --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/is-symbol.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function (x) { + return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/package.json new file mode 100644 index 00000000000000..6c2dcc65e8cb30 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/package.json @@ -0,0 +1,66 @@ +{ + "name": "es6-symbol", + "version": "3.0.2", + "description": "ECMAScript 6 Symbol polyfill", + "author": { + "name": "Mariusz Nowak", + "email": "medyk@medikoo.com", + "url": "http://www.medikoo.com/" + }, + "keywords": [ + "symbol", + "private", + "property", + "es6", + "ecmascript", + "harmony", + "ponyfill", + "polyfill" + ], + "repository": { + "type": "git", + "url": "git://github.com/medikoo/es6-symbol.git" + }, + "dependencies": { + "d": "~0.1.1", + "es5-ext": "~0.10.10" + }, + "devDependencies": { + "tad": "~0.2.4", + "xlint": "~0.2.2", + "xlint-jslint-medikoo": "~0.1.4" + }, + "scripts": { + "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", + "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", + "test": "node ./node_modules/tad/bin/tad" + }, + "license": "MIT", + "gitHead": "b7da6b926c44e3745de69b17c98c00a5c84b4ebe", + "bugs": { + "url": "https://github.com/medikoo/es6-symbol/issues" + }, + "homepage": "https://github.com/medikoo/es6-symbol#readme", + "_id": "es6-symbol@3.0.2", + "_shasum": "1e928878c6f5e63541625b4bb4df4af07d154219", + "_from": "es6-symbol@>=3.0.2 <3.1.0", + "_npmVersion": "3.3.12", + "_nodeVersion": "5.2.0", + "_npmUser": { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + }, + "dist": { + "shasum": "1e928878c6f5e63541625b4bb4df4af07d154219", + "tarball": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-3.0.2.tgz" + }, + "maintainers": [ + { + "name": "medikoo", + "email": "medikoo+npm@medikoo.com" + } + ], + "directories": {}, + "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.0.2.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js new file mode 100644 index 00000000000000..7c3c8fe90025ca --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/polyfill.js @@ -0,0 +1,107 @@ +// ES2015 Symbol polyfill for environments that do not support it (or partially support it_ + +'use strict'; + +var d = require('d') + , validateSymbol = require('./validate-symbol') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty, objPrototype = Object.prototype + , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null); + +if (typeof Symbol === 'function') NativeSymbol = Symbol; + +var generateName = (function () { + var created = create(null); + return function (desc) { + var postfix = 0, name, ie11BugWorkaround; + while (created[desc + (postfix || '')]) ++postfix; + desc += (postfix || ''); + created[desc] = true; + name = '@@' + desc; + defineProperty(objPrototype, name, d.gs(null, function (value) { + // For IE11 issue see: + // https://connect.microsoft.com/IE/feedbackdetail/view/1928508/ + // ie11-broken-getters-on-dom-objects + // https://github.com/medikoo/es6-symbol/issues/12 + if (ie11BugWorkaround) return; + ie11BugWorkaround = true; + defineProperty(this, name, d(value)); + ie11BugWorkaround = false; + })); + return name; + }; +}()); + +// Internal constructor (not one exposed) for creating Symbol instances. +// This one is used to ensure that `someSymbol instanceof Symbol` always return false +HiddenSymbol = function Symbol(description) { + if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); + return SymbolPolyfill(description); +}; + +// Exposed `Symbol` constructor +// (returns instances of HiddenSymbol) +module.exports = SymbolPolyfill = function Symbol(description) { + var symbol; + if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); + symbol = create(HiddenSymbol.prototype); + description = (description === undefined ? '' : String(description)); + return defineProperties(symbol, { + __description__: d('', description), + __name__: d('', generateName(description)) + }); +}; +defineProperties(SymbolPolyfill, { + for: d(function (key) { + if (globalSymbols[key]) return globalSymbols[key]; + return (globalSymbols[key] = SymbolPolyfill(String(key))); + }), + keyFor: d(function (s) { + var key; + validateSymbol(s); + for (key in globalSymbols) if (globalSymbols[key] === s) return key; + }), + + // If there's native implementation of given symbol, let's fallback to it + // to ensure proper interoperability with other native functions e.g. Array.from + hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')), + isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) || + SymbolPolyfill('isConcatSpreadable')), + iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')), + match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')), + replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')), + search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')), + species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')), + split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')), + toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')), + toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')), + unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables')) +}); + +// Internal tweaks for real symbol producer +defineProperties(HiddenSymbol.prototype, { + constructor: d(SymbolPolyfill), + toString: d('', function () { return this.__name__; }) +}); + +// Proper implementation of methods exposed on Symbol.prototype +// They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype +defineProperties(SymbolPolyfill.prototype, { + toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), + valueOf: d(function () { return validateSymbol(this); }) +}); +defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', + function () { return validateSymbol(this); })); +defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol')); + +// Proper implementaton of toPrimitive and toStringTag for returned symbol instances +defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag, + d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])); + +// Note: It's important to define `toPrimitive` as last one, as some implementations +// implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols) +// And that may invoke error in definition flow: +// See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149 +defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive, + d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive])); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js new file mode 100644 index 00000000000000..eb35c3018835c7 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/implement.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof Symbol, 'function'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/index.js new file mode 100644 index 00000000000000..62b3296df6fc5e --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/index.js @@ -0,0 +1,12 @@ +'use strict'; + +var d = require('d') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js new file mode 100644 index 00000000000000..bb0d64536ebbae --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-implemented.js @@ -0,0 +1,14 @@ +'use strict'; + +var global = require('es5-ext/global') + , polyfill = require('../polyfill'); + +module.exports = function (t, a) { + var cache; + a(typeof t(), 'boolean'); + cache = global.Symbol; + global.Symbol = polyfill; + a(t(), true); + if (cache === undefined) delete global.Symbol; + else global.Symbol = cache; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js new file mode 100644 index 00000000000000..df8ba0323f0cad --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-native-implemented.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js new file mode 100644 index 00000000000000..ac24b9abbff4e6 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/is-symbol.js @@ -0,0 +1,16 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + a(t(undefined), false, "Undefined"); + a(t(null), false, "Null"); + a(t(true), false, "Primitive"); + a(t('raz'), false, "String"); + a(t({}), false, "Object"); + a(t([]), false, "Array"); + if (typeof Symbol !== 'undefined') { + a(t(Symbol()), true, "Native"); + } + a(t(SymbolPoly()), true, "Polyfill"); +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js new file mode 100644 index 00000000000000..83fb5e9253677b --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/polyfill.js @@ -0,0 +1,27 @@ +'use strict'; + +var d = require('d') + , isSymbol = require('../is-symbol') + + , defineProperty = Object.defineProperty; + +module.exports = function (T, a) { + var symbol = T('test'), x = {}; + defineProperty(x, symbol, d('foo')); + a(x.test, undefined, "Name"); + a(x[symbol], 'foo', "Get"); + a(x instanceof T, false); + + a(isSymbol(symbol), true, "Symbol"); + a(isSymbol(T.iterator), true, "iterator"); + a(isSymbol(T.toStringTag), true, "toStringTag"); + + x = {}; + x[symbol] = 'foo'; + a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, + value: 'foo', writable: true }); + symbol = T.for('marko'); + a(isSymbol(symbol), true); + a(T.for('marko'), symbol); + a(T.keyFor(symbol), 'marko'); +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js new file mode 100644 index 00000000000000..2c8f84c8239b6e --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/test/validate-symbol.js @@ -0,0 +1,19 @@ +'use strict'; + +var SymbolPoly = require('../polyfill'); + +module.exports = function (t, a) { + var symbol; + a.throws(function () { t(undefined); }, TypeError, "Undefined"); + a.throws(function () { t(null); }, TypeError, "Null"); + a.throws(function () { t(true); }, TypeError, "Primitive"); + a.throws(function () { t('raz'); }, TypeError, "String"); + a.throws(function () { t({}); }, TypeError, "Object"); + a.throws(function () { t([]); }, TypeError, "Array"); + if (typeof Symbol !== 'undefined') { + symbol = Symbol(); + a(t(symbol), symbol, "Native"); + } + symbol = SymbolPoly(); + a(t(symbol), symbol, "Polyfill"); +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js new file mode 100644 index 00000000000000..42750043d4271c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-symbol/validate-symbol.js @@ -0,0 +1,8 @@ +'use strict'; + +var isSymbol = require('./is-symbol'); + +module.exports = function (value) { + if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); + return value; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json index bb756e709bda71..0548e810658e8a 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json @@ -51,7 +51,7 @@ "homepage": "https://github.com/medikoo/es5-ext#readme", "_id": "es5-ext@0.10.11", "_shasum": "8184c3e705a820948c2dbe043849379b1dbd0c45", - "_from": "es5-ext@>=0.10.10 <0.11.0", + "_from": "es5-ext@>=0.10.11 <0.11.0", "_npmVersion": "2.14.7", "_nodeVersion": "4.2.3", "_npmUser": { diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json index 6c17838e0ffe1c..6b99c4c36b843c 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json @@ -1,6 +1,6 @@ { "name": "es6-symbol", - "version": "3.0.2", + "version": "3.1.0", "description": "ECMAScript 6 Symbol polyfill", "author": { "name": "Mariusz Nowak", @@ -23,7 +23,7 @@ }, "dependencies": { "d": "~0.1.1", - "es5-ext": "~0.10.10" + "es5-ext": "~0.10.11" }, "devDependencies": { "tad": "~0.2.4", @@ -36,23 +36,23 @@ "test": "node ./node_modules/tad/bin/tad" }, "license": "MIT", - "gitHead": "b7da6b926c44e3745de69b17c98c00a5c84b4ebe", + "gitHead": "f84175053e9cad6a1230f3b7cc13e078c3fcc12f", "bugs": { "url": "https://github.com/medikoo/es6-symbol/issues" }, "homepage": "https://github.com/medikoo/es6-symbol#readme", - "_id": "es6-symbol@3.0.2", - "_shasum": "1e928878c6f5e63541625b4bb4df4af07d154219", + "_id": "es6-symbol@3.1.0", + "_shasum": "94481c655e7a7cad82eba832d97d5433496d7ffa", "_from": "es6-symbol@>=3.0.2 <4.0.0", - "_npmVersion": "3.3.12", - "_nodeVersion": "5.2.0", + "_npmVersion": "2.15.5", + "_nodeVersion": "4.4.5", "_npmUser": { "name": "medikoo", "email": "medikoo+npm@medikoo.com" }, "dist": { - "shasum": "1e928878c6f5e63541625b4bb4df4af07d154219", - "tarball": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-3.0.2.tgz" + "shasum": "94481c655e7a7cad82eba832d97d5433496d7ffa", + "tarball": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" }, "maintainers": [ { @@ -60,7 +60,11 @@ "email": "medikoo+npm@medikoo.com" } ], + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/es6-symbol-3.1.0.tgz_1464960261964_0.3645231726113707" + }, "directories": {}, - "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.0.2.tgz", + "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz", "readme": "ERROR: No README data found!" } diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js index 7c3c8fe90025ca..48832a5f36f59e 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js @@ -1,4 +1,4 @@ -// ES2015 Symbol polyfill for environments that do not support it (or partially support it_ +// ES2015 Symbol polyfill for environments that do not support it (or partially support it) 'use strict'; @@ -7,9 +7,16 @@ var d = require('d') , create = Object.create, defineProperties = Object.defineProperties , defineProperty = Object.defineProperty, objPrototype = Object.prototype - , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null); + , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null) + , isNativeSafe; -if (typeof Symbol === 'function') NativeSymbol = Symbol; +if (typeof Symbol === 'function') { + NativeSymbol = Symbol; + try { + String(NativeSymbol()); + isNativeSafe = true; + } catch (ignore) {} +} var generateName = (function () { var created = create(null); @@ -45,6 +52,7 @@ HiddenSymbol = function Symbol(description) { module.exports = SymbolPolyfill = function Symbol(description) { var symbol; if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); + if (isNativeSafe) return NativeSymbol(description); symbol = create(HiddenSymbol.prototype); description = (description === undefined ? '' : String(description)); return defineProperties(symbol, { @@ -91,8 +99,11 @@ defineProperties(SymbolPolyfill.prototype, { toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), valueOf: d(function () { return validateSymbol(this); }) }); -defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', - function () { return validateSymbol(this); })); +defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function () { + var symbol = validateSymbol(this); + if (typeof symbol === 'symbol') return symbol; + return symbol.toString(); +})); defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol')); // Proper implementaton of toPrimitive and toStringTag for returned symbol instances diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js index 83fb5e9253677b..8b657905de57d7 100644 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js +++ b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js @@ -18,8 +18,10 @@ module.exports = function (T, a) { x = {}; x[symbol] = 'foo'; - a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, - value: 'foo', writable: true }); + if (typeof symbol !== 'symbol') { + a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, + value: 'foo', writable: true }); + } symbol = T.for('marko'); a(isSymbol(symbol), true); a(T.for('marko'), symbol); diff --git a/deps/npm/node_modules/node-gyp/package.json b/deps/npm/node_modules/node-gyp/package.json index aedb6ce63dbf42..7f74a8f64fb983 100644 --- a/deps/npm/node_modules/node-gyp/package.json +++ b/deps/npm/node_modules/node-gyp/package.json @@ -11,7 +11,7 @@ "bindings", "gyp" ], - "version": "3.3.1", + "version": "3.4.0", "installVersion": 9, "author": { "name": "Nathan Rajlich", @@ -29,12 +29,12 @@ "main": "./lib/node-gyp.js", "dependencies": { "fstream": "^1.0.0", - "glob": "3 || 4", + "glob": "^7.0.3", "graceful-fs": "^4.1.2", - "minimatch": "1", + "minimatch": "^3.0.2", "mkdirp": "^0.5.0", "nopt": "2 || 3", - "npmlog": "0 || 1 || 2", + "npmlog": "0 || 1 || 2 || 3", "osenv": "0", "path-array": "^1.0.0", "request": "2", @@ -47,24 +47,27 @@ "node": ">= 0.8.0" }, "devDependencies": { - "tape": "~4.2.0" + "tape": "~4.2.0", + "bindings": "~1.2.1", + "nan": "^2.0.0", + "require-inject": "~1.3.0" }, "scripts": { "test": "tape test/test-*" }, - "gitHead": "1dcf356ca7b658789447108b29a985c00ffcf0f5", + "gitHead": "d460084b241c427655497a1de4ed351a13ffb47f", "bugs": { "url": "https://github.com/nodejs/node-gyp/issues" }, "homepage": "https://github.com/nodejs/node-gyp#readme", - "_id": "node-gyp@3.3.1", - "_shasum": "80f7b6d7c2f9c0495ba42c518a670c99bdf6e4a0", - "_from": "node-gyp@3.3.1", - "_npmVersion": "3.3.12", - "_nodeVersion": "6.0.0-pre", + "_id": "node-gyp@3.4.0", + "_shasum": "dda558393b3ecbbe24c9e6b8703c71194c63fa36", + "_from": "node-gyp@latest", + "_npmVersion": "3.9.3", + "_nodeVersion": "6.2.1", "_npmUser": { - "name": "bnoordhuis", - "email": "info@bnoordhuis.nl" + "name": "rvagg", + "email": "rod@vagg.org" }, "maintainers": [ { @@ -93,13 +96,14 @@ } ], "dist": { - "shasum": "80f7b6d7c2f9c0495ba42c518a670c99bdf6e4a0", - "tarball": "http://registry.npmjs.org/node-gyp/-/node-gyp-3.3.1.tgz" + "shasum": "dda558393b3ecbbe24c9e6b8703c71194c63fa36", + "tarball": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.4.0.tgz" }, "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/node-gyp-3.3.1.tgz_1457115144174_0.4018901875242591" + "tmp": "tmp/node-gyp-3.4.0.tgz_1467079381888_0.1804589256644249" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.3.1.tgz" + "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.4.0.tgz", + "readme": "ERROR: No README data found!" } diff --git a/deps/npm/node_modules/node-gyp/src/win_delay_load_hook.c b/deps/npm/node_modules/node-gyp/src/win_delay_load_hook.cc similarity index 92% rename from deps/npm/node_modules/node-gyp/src/win_delay_load_hook.c rename to deps/npm/node_modules/node-gyp/src/win_delay_load_hook.cc index b1e170aa13bd95..e75954b605101a 100644 --- a/deps/npm/node_modules/node-gyp/src/win_delay_load_hook.c +++ b/deps/npm/node_modules/node-gyp/src/win_delay_load_hook.cc @@ -31,6 +31,6 @@ static FARPROC WINAPI load_exe_hook(unsigned int event, DelayLoadInfo* info) { return (FARPROC) m; } -PfnDliHook __pfnDliNotifyHook2 = load_exe_hook; +decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = load_exe_hook; #endif diff --git a/deps/npm/node_modules/node-gyp/test/test-addon.js b/deps/npm/node_modules/node-gyp/test/test-addon.js new file mode 100644 index 00000000000000..c2a71f44985fda --- /dev/null +++ b/deps/npm/node_modules/node-gyp/test/test-addon.js @@ -0,0 +1,28 @@ +'use strict' + +var test = require('tape') +var execFile = require('child_process').execFile +var path = require('path') +var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world') +var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js') + +test('build simple addon', function (t) { + t.plan(3) + + // Set the loglevel otherwise the output disappears when run via 'npm test' + var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] + var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { + var logLines = stderr.toString().trim().split(/\r?\n/) + var lastLine = logLines[logLines.length-1] + t.strictEqual(err, null) + t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') + try { + var binding = require('hello_world') + t.strictEqual(binding.hello(), 'world') + } catch (error) { + t.error(error, 'load module') + } + }) + proc.stdout.setEncoding('utf-8') + proc.stderr.setEncoding('utf-8') +}) diff --git a/deps/npm/node_modules/node-gyp/test/test-find-accessible-sync.js b/deps/npm/node_modules/node-gyp/test/test-find-accessible-sync.js new file mode 100644 index 00000000000000..d336243dd0d7b7 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/test/test-find-accessible-sync.js @@ -0,0 +1,86 @@ +'use strict' + +var test = require('tape') +var path = require('path') +var requireInject = require('require-inject') +var configure = requireInject('../lib/configure', { + 'graceful-fs': { + 'closeSync': function (fd) { return undefined }, + 'openSync': function (path) { + if (readableFiles.some(function (f) { return f === path} )) { + return 0 + } else { + var error = new Error('ENOENT - not found') + throw error + } + } + } +}) + +var dir = path.sep + 'testdir' +var readableFile = 'readable_file' +var anotherReadableFile = 'another_readable_file' +var readableFileInDir = 'somedir' + path.sep + readableFile +var readableFiles = [ + path.resolve(dir, readableFile), + path.resolve(dir, anotherReadableFile), + path.resolve(dir, readableFileInDir) +] + +test('find accessible - empty array', function (t) { + t.plan(1) + + var candidates = [] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, undefined) +}) + +test('find accessible - single item array, readable', function (t) { + t.plan(1) + + var candidates = [ readableFile ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, path.resolve(dir, readableFile)) +}) + +test('find accessible - single item array, readable in subdir', function (t) { + t.plan(1) + + var candidates = [ readableFileInDir ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, path.resolve(dir, readableFileInDir)) +}) + +test('find accessible - single item array, unreadable', function (t) { + t.plan(1) + + var candidates = [ 'unreadable_file' ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, undefined) +}) + + +test('find accessible - multi item array, no matches', function (t) { + t.plan(1) + + var candidates = [ 'non_existent_file', 'unreadable_file' ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, undefined) +}) + + +test('find accessible - multi item array, single match', function (t) { + t.plan(1) + + var candidates = [ 'non_existent_file', readableFile ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, path.resolve(dir, readableFile)) +}) + +test('find accessible - multi item array, return first match', function (t) { + t.plan(1) + + var candidates = [ 'non_existent_file', anotherReadableFile, readableFile ] + var found = configure.test.findAccessibleSync('test', dir, candidates) + t.strictEqual(found, path.resolve(dir, anotherReadableFile)) +}) diff --git a/deps/npm/package.json b/deps/npm/package.json index a509afa6d5127e..2e7e6226655a4a 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "2.15.8", + "version": "2.15.9", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -62,7 +62,7 @@ "lru-cache": "~4.0.1", "minimatch": "~3.0.0", "mkdirp": "~0.5.1", - "node-gyp": "~3.3.1", + "node-gyp": "~3.4.0", "nopt": "~3.0.6", "normalize-git-url": "~3.0.2", "normalize-package-data": "~2.3.5", @@ -188,9 +188,12 @@ "dumpconf": "env | grep npm | sort | uniq", "prepublish": "node bin/npm-cli.js prune --prefix=. --no-global && rimraf test/*/*/node_modules && make doc-clean && make -j4 doc", "preversion": "bash scripts/update-authors.sh && git add AUTHORS && git commit -m \"update AUTHORS\" || true", - "tap": "tap --timeout 240", + "tap": "tap --reporter=classic --timeout 300", + "tap-cover": "tap --coverage --reporter=classic --timeout 600", "test": "npm run test-tap", - "test-tap": "npm run tap -- \"test/tap/*.js\"" + "test-coverage": "npm run tap-cover -- \"test/tap/*.js\"", + "test-tap": "npm run tap -- \"test/tap/*.js\"", + "test-node": "\"$NODE\" \"node_modules/.bin/tap\" --timeout 240 \"test/tap/*.js\"" }, "license": "Artistic-2.0" } From 9a8acad6ff0619f6d3cc2db1630f61c068fc98bd Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 29 May 2016 03:06:56 -0400 Subject: [PATCH 258/261] test: use random ports where possible This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis Reviewed-By: Matteo Collina Reviewed-By: Rod Vagg --- .../test-async-wrap-check-providers.js | 13 +- ...st-async-wrap-disabled-propagate-parent.js | 6 +- .../test-async-wrap-propagate-parent.js | 6 +- test/parallel/test-beforeexit-event.js | 4 +- .../parallel/test-child-process-disconnect.js | 10 +- .../parallel/test-child-process-fork-dgram.js | 4 +- test/parallel/test-child-process-fork-net.js | 2 +- test/parallel/test-child-process-fork-net2.js | 4 +- .../test-child-process-fork-regr-gh-2847.js | 4 +- .../test-child-process-recv-handle.js | 2 +- test/parallel/test-crypto-verify-failure.js | 4 +- test/parallel/test-dgram-address.js | 12 +- .../test-dgram-bind-default-address.js | 12 +- test/parallel/test-dgram-empty-packet.js | 39 ++--- .../test-dgram-error-message-address.js | 12 +- test/parallel/test-dgram-implicit-bind.js | 9 +- test/parallel/test-dgram-multicast-setTTL.js | 4 +- .../test-dgram-send-callback-recursive.js | 8 +- test/parallel/test-dgram-send-empty-buffer.js | 22 +-- test/parallel/test-dgram-setTTL.js | 4 +- test/parallel/test-dgram-udp4.js | 9 +- .../parallel/test-domain-abort-on-uncaught.js | 4 +- test/parallel/test-domain-http-server.js | 9 +- test/parallel/test-domain-multi.js | 32 ++-- test/parallel/test-http-1.0-keep-alive.js | 12 +- test/parallel/test-http-1.0.js | 7 +- test/parallel/test-http-abort-before-end.js | 10 +- test/parallel/test-http-abort-client.js | 7 +- test/parallel/test-http-abort-queued.js | 4 +- test/parallel/test-http-after-connect.js | 8 +- .../test-http-agent-destroyed-socket.js | 138 +++++++++--------- .../parallel/test-http-agent-error-on-idle.js | 52 +++---- test/parallel/test-http-agent-keepalive.js | 9 +- ...test-http-agent-maxsockets-regress-4050.js | 6 +- test/parallel/test-http-agent-maxsockets.js | 6 +- test/parallel/test-http-agent-no-protocol.js | 6 +- test/parallel/test-http-agent-null.js | 4 +- test/parallel/test-http-agent.js | 7 +- .../test-http-allow-req-after-204-res.js | 6 +- test/parallel/test-http-automatic-headers.js | 8 +- test/parallel/test-http-bind-twice.js | 19 ++- test/parallel/test-http-blank-header.js | 6 +- test/parallel/test-http-buffer-sanity.js | 6 +- test/parallel/test-http-byteswritten.js | 6 +- .../test-http-catch-uncaughtexception.js | 4 +- test/parallel/test-http-chunk-problem.js | 8 +- test/parallel/test-http-chunked-304.js | 4 +- test/parallel/test-http-chunked.js | 6 +- test/parallel/test-http-client-abort-event.js | 6 +- test/parallel/test-http-client-abort.js | 6 +- test/parallel/test-http-client-abort2.js | 6 +- test/parallel/test-http-client-agent.js | 9 +- .../test-http-client-default-headers-exist.js | 6 +- test/parallel/test-http-client-encoding.js | 6 +- test/parallel/test-http-client-get-url.js | 6 +- test/parallel/test-http-client-parse-error.js | 6 +- test/parallel/test-http-client-race-2.js | 8 +- test/parallel/test-http-client-race.js | 8 +- ...ient-reject-chunked-with-content-length.js | 4 +- .../test-http-client-reject-cr-no-lf.js | 4 +- .../test-http-client-timeout-agent.js | 7 +- .../test-http-client-timeout-event.js | 5 +- .../test-http-client-timeout-with-data.js | 5 +- test/parallel/test-http-client-timeout.js | 7 +- test/parallel/test-http-client-upload-buf.js | 6 +- test/parallel/test-http-client-upload.js | 6 +- test/parallel/test-http-conn-reset.js | 7 +- test/parallel/test-http-connect-req-res.js | 6 +- test/parallel/test-http-connect.js | 8 +- test/parallel/test-http-content-length.js | 10 +- test/parallel/test-http-contentLength0.js | 6 +- test/parallel/test-http-createConnection.js | 6 +- test/parallel/test-http-date-header.js | 6 +- test/parallel/test-http-default-encoding.js | 6 +- test/parallel/test-http-default-port.js | 18 +-- .../test-http-destroyed-socket-write2.js | 4 +- .../test-http-double-content-length.js | 4 +- .../test-http-end-throw-socket-handling.js | 4 +- test/parallel/test-http-eof-on-connect.js | 6 +- test/parallel/test-http-exceptions.js | 6 +- test/parallel/test-http-expect-continue.js | 6 +- test/parallel/test-http-extra-response.js | 6 +- test/parallel/test-http-flush-headers.js | 6 +- .../test-http-flush-response-headers.js | 4 +- test/parallel/test-http-flush.js | 6 +- test/parallel/test-http-full-response.js | 4 +- .../test-http-get-pipeline-problem.js | 4 +- test/parallel/test-http-head-request.js | 10 +- ...test-http-head-response-has-no-body-end.js | 6 +- .../test-http-head-response-has-no-body.js | 6 +- test/parallel/test-http-header-obstext.js | 4 +- test/parallel/test-http-header-read.js | 6 +- .../test-http-header-response-splitting.js | 5 +- test/parallel/test-http-hex-write.js | 6 +- .../test-http-host-header-ipv6-fail.js | 5 +- test/parallel/test-http-host-headers.js | 20 ++- ...-http-incoming-pipelined-socket-destroy.js | 8 +- .../test-http-keep-alive-close-on-header.js | 12 +- test/parallel/test-http-keep-alive.js | 13 +- test/parallel/test-http-keepalive-client.js | 9 +- .../test-http-keepalive-maxsockets.js | 124 ++++++++-------- test/parallel/test-http-keepalive-request.js | 9 +- test/parallel/test-http-legacy.js | 6 +- .../test-http-localaddress-bind-error.js | 6 +- test/parallel/test-http-localaddress.js | 4 +- test/parallel/test-http-malformed-request.js | 6 +- .../test-http-many-ended-pipelines.js | 22 +-- test/parallel/test-http-max-headers-count.js | 6 +- test/parallel/test-http-multi-line-headers.js | 6 +- test/parallel/test-http-mutable-headers.js | 6 +- test/parallel/test-http-no-content-length.js | 6 +- test/parallel/test-http-outgoing-finish.js | 6 +- test/parallel/test-http-parser-free.js | 6 +- .../test-http-pause-resume-one-end.js | 6 +- test/parallel/test-http-pause.js | 6 +- test/parallel/test-http-pipe-fs.js | 4 +- test/parallel/test-http-pipeline-flood.js | 10 +- test/parallel/test-http-pipeline-regr-2639.js | 6 +- test/parallel/test-http-pipeline-regr-3332.js | 6 +- test/parallel/test-http-pipeline-regr-3508.js | 6 +- test/parallel/test-http-proxy.js | 13 +- test/parallel/test-http-raw-headers.js | 15 +- test/parallel/test-http-regr-gh-2821.js | 6 +- .../test-http-remove-header-stays-removed.js | 6 +- ...test-http-request-dont-override-options.js | 64 ++++---- test/parallel/test-http-request-end-twice.js | 6 +- test/parallel/test-http-request-end.js | 6 +- test/parallel/test-http-request-methods.js | 8 +- .../parallel/test-http-res-write-after-end.js | 6 +- ...test-http-res-write-end-dont-take-array.js | 8 +- test/parallel/test-http-response-close.js | 6 +- ...test-http-response-multi-content-length.js | 4 +- .../parallel/test-http-response-no-headers.js | 6 +- test/parallel/test-http-response-readable.js | 6 +- test/parallel/test-http-response-splitting.js | 4 +- .../test-http-response-status-message.js | 9 +- .../test-http-server-consumed-timeout.js | 4 +- .../parallel/test-http-server-multiheaders.js | 6 +- .../test-http-server-multiheaders2.js | 6 +- ...rver-reject-chunked-with-content-length.js | 4 +- .../test-http-server-reject-cr-no-lf.js | 4 +- test/parallel/test-http-server-stale-close.js | 10 +- test/parallel/test-http-server-unconsume.js | 6 +- test/parallel/test-http-server.js | 6 +- test/parallel/test-http-set-cookies.js | 8 +- test/parallel/test-http-set-timeout.js | 6 +- test/parallel/test-http-set-trailers.js | 12 +- test/parallel/test-http-should-keep-alive.js | 6 +- test/parallel/test-http-status-code.js | 6 +- test/parallel/test-http-status-message.js | 6 +- test/parallel/test-http-timeout-overflow.js | 7 +- test/parallel/test-http-timeout.js | 8 +- test/parallel/test-http-upgrade-advertise.js | 4 +- test/parallel/test-http-upgrade-agent.js | 4 +- test/parallel/test-http-upgrade-client.js | 4 +- test/parallel/test-http-upgrade-client2.js | 9 +- test/parallel/test-http-upgrade-server.js | 25 ++-- test/parallel/test-http-upgrade-server2.js | 6 +- ...p-url.parse-auth-with-header-in-request.js | 18 +-- test/parallel/test-http-url.parse-auth.js | 11 +- test/parallel/test-http-url.parse-basic.js | 8 +- .../test-http-url.parse-https.request.js | 8 +- test/parallel/test-http-url.parse-path.js | 8 +- test/parallel/test-http-url.parse-post.js | 10 +- test/parallel/test-http-url.parse-search.js | 9 +- test/parallel/test-http-wget.js | 6 +- test/parallel/test-http-write-callbacks.js | 6 +- test/parallel/test-http-write-empty-string.js | 6 +- test/parallel/test-http-write-head.js | 6 +- test/parallel/test-http-zero-length-write.js | 6 +- test/parallel/test-http.js | 10 +- test/parallel/test-https-agent-servername.js | 4 +- .../test-https-agent-session-eviction.js | 17 ++- .../test-https-agent-session-reuse.js | 14 +- test/parallel/test-https-agent-sni.js | 4 +- test/parallel/test-https-agent.js | 4 +- test/parallel/test-https-byteswritten.js | 4 +- .../test-https-client-checkServerIdentity.js | 6 +- test/parallel/test-https-client-get-url.js | 4 +- test/parallel/test-https-client-reject.js | 8 +- test/parallel/test-https-client-resume.js | 6 +- test/parallel/test-https-close.js | 4 +- .../test-https-connect-address-family.js | 4 +- .../parallel/test-https-connecting-to-http.js | 4 +- test/parallel/test-https-drain.js | 4 +- test/parallel/test-https-eof-for-eom.js | 4 +- test/parallel/test-https-foafssl.js | 4 +- test/parallel/test-https-host-headers.js | 20 +-- .../test-https-localaddress-bind-error.js | 4 +- test/parallel/test-https-localaddress.js | 4 +- test/parallel/test-https-pfx.js | 5 +- test/parallel/test-https-req-split.js | 4 +- .../parallel/test-https-resume-after-renew.js | 2 +- .../parallel/test-https-set-timeout-server.js | 102 +++++++------ test/parallel/test-https-simple.js | 6 +- test/parallel/test-https-socket-options.js | 8 +- test/parallel/test-https-strict.js | 19 ++- test/parallel/test-https-timeout-server-2.js | 4 +- test/parallel/test-https-timeout-server.js | 4 +- test/parallel/test-https-timeout.js | 4 +- test/parallel/test-https-truncate.js | 6 +- test/parallel/test-listen-fd-cluster.js | 12 +- .../test-listen-fd-detached-inherit.js | 11 +- test/parallel/test-listen-fd-detached.js | 9 +- test/parallel/test-listen-fd-server.js | 12 +- test/parallel/test-net-after-close.js | 6 +- test/parallel/test-net-binary.js | 6 +- test/parallel/test-net-bind-twice.js | 18 +-- test/parallel/test-net-buffersize.js | 6 +- test/parallel/test-net-bytes-read.js | 4 +- test/parallel/test-net-bytes-stats.js | 9 +- test/parallel/test-net-can-reset-timeout.js | 6 +- test/parallel/test-net-connect-buffer.js | 7 +- .../parallel/test-net-connect-options-ipv6.js | 4 +- test/parallel/test-net-connect-options.js | 6 +- .../test-net-connect-paused-connection.js | 14 +- test/parallel/test-net-create-connection.js | 27 ++-- test/parallel/test-net-dns-custom-lookup.js | 4 +- test/parallel/test-net-dns-lookup-skip.js | 4 +- test/parallel/test-net-dns-lookup.js | 17 ++- test/parallel/test-net-during-close.js | 6 +- test/parallel/test-net-eaddrinuse.js | 13 +- test/parallel/test-net-error-twice.js | 6 +- test/parallel/test-net-keepalive.js | 4 +- test/parallel/test-net-large-string.js | 6 +- ...n-close-server-callback-is-not-function.js | 4 +- test/parallel/test-net-listen-close-server.js | 4 +- test/parallel/test-net-listen-port-option.js | 4 +- test/parallel/test-net-local-address-port.js | 8 +- test/parallel/test-net-localport.js | 10 +- .../test-net-pause-resume-connecting.js | 87 ++++++----- .../parallel/test-net-persistent-keepalive.js | 6 +- test/parallel/test-net-persistent-nodelay.js | 6 +- .../parallel/test-net-persistent-ref-unref.js | 6 +- test/parallel/test-net-pingpong.js | 12 +- test/parallel/test-net-reconnect.js | 8 +- test/parallel/test-net-remote-address-port.js | 12 +- test/parallel/test-net-server-close.js | 8 +- .../test-net-server-listen-remove-callback.js | 6 +- ...-connections-close-makes-more-available.js | 6 +- .../test-net-server-max-connections.js | 6 +- .../test-net-server-pause-on-connect.js | 8 +- test/parallel/test-net-server-try-ports.js | 8 +- test/parallel/test-net-server-unref.js | 4 +- test/parallel/test-net-settimeout.js | 32 ++-- .../parallel/test-net-socket-local-address.js | 4 +- .../parallel/test-net-socket-timeout-unref.js | 4 +- test/parallel/test-net-socket-timeout.js | 4 +- test/parallel/test-net-stream.js | 7 +- test/parallel/test-net-sync-cork.js | 6 +- test/parallel/test-net-write-after-close.js | 6 +- test/parallel/test-net-write-connect-write.js | 6 +- test/parallel/test-net-write-slow.js | 6 +- test/parallel/test-pipe-file-to-http.js | 4 +- .../parallel/test-process-getactivehandles.js | 6 +- test/parallel/test-regress-GH-1531.js | 4 +- test/parallel/test-regress-GH-4948.js | 22 +-- test/parallel/test-regress-GH-746.js | 6 +- test/parallel/test-repl-require.js | 3 +- test/parallel/test-repl.js | 4 +- .../test-socket-write-after-fin-error.js | 48 +++--- test/parallel/test-socket-write-after-fin.js | 42 +++--- .../test-stream2-httpclient-response-end.js | 6 +- test/parallel/test-tcp-wrap-connect.js | 6 +- test/parallel/test-tcp-wrap-listen.js | 9 +- test/parallel/test-tcp-wrap.js | 10 +- ...imeout-removes-other-socket-unref-timer.js | 6 +- test/parallel/test-tls-0-dns-altname.js | 4 +- test/parallel/test-tls-alert-handling.js | 6 +- test/parallel/test-tls-alert.js | 4 +- .../test-tls-async-cb-after-socket-end.js | 4 +- test/parallel/test-tls-cert-regression.js | 2 +- test/parallel/test-tls-client-destroy-soon.js | 4 +- test/parallel/test-tls-client-reject.js | 8 +- test/parallel/test-tls-client-resume.js | 6 +- test/parallel/test-tls-client-verify.js | 5 +- test/parallel/test-tls-close-error.js | 4 +- test/parallel/test-tls-close-notify.js | 4 +- test/parallel/test-tls-cnnic-whitelist.js | 7 +- .../test-tls-connect-address-family.js | 4 +- .../parallel/test-tls-connect-given-socket.js | 10 +- test/parallel/test-tls-connect-no-host.js | 24 +-- test/parallel/test-tls-connect-simple.js | 6 +- .../test-tls-connect-stream-writes.js | 6 +- .../parallel/test-tls-delayed-attach-error.js | 4 +- test/parallel/test-tls-delayed-attach.js | 4 +- test/parallel/test-tls-dhe.js | 4 +- test/parallel/test-tls-ecdh-disable.js | 4 +- test/parallel/test-tls-ecdh.js | 4 +- test/parallel/test-tls-econnreset.js | 4 +- test/parallel/test-tls-empty-sni-context.js | 4 +- test/parallel/test-tls-fast-writing.js | 5 +- .../test-tls-friendly-error-message.js | 2 +- test/parallel/test-tls-getcipher.js | 4 +- test/parallel/test-tls-handshake-error.js | 4 +- .../parallel/test-tls-hello-parser-failure.js | 4 +- test/parallel/test-tls-honorcipherorder.js | 5 +- test/parallel/test-tls-inception.js | 4 +- test/parallel/test-tls-interleave.js | 6 +- test/parallel/test-tls-invoke-queued.js | 4 +- test/parallel/test-tls-js-stream.js | 4 +- test/parallel/test-tls-junk-closes-server.js | 4 +- test/parallel/test-tls-junk-server.js | 4 +- test/parallel/test-tls-legacy-onselect.js | 4 +- test/parallel/test-tls-max-send-fragment.js | 4 +- test/parallel/test-tls-multi-key.js | 6 +- test/parallel/test-tls-no-cert-required.js | 2 +- test/parallel/test-tls-no-rsa-key.js | 4 +- test/parallel/test-tls-no-sslv3.js | 2 +- test/parallel/test-tls-npn-server-client.js | 13 +- test/parallel/test-tls-ocsp-callback.js | 4 +- test/parallel/test-tls-on-empty-socket.js | 4 +- test/parallel/test-tls-over-http-tunnel.js | 17 +-- test/parallel/test-tls-passphrase.js | 6 +- test/parallel/test-tls-pause.js | 4 +- .../test-tls-peer-certificate-encoding.js | 4 +- .../test-tls-peer-certificate-multi-keys.js | 4 +- test/parallel/test-tls-peer-certificate.js | 4 +- test/parallel/test-tls-pfx-gh-5100-regr.js | 4 +- test/parallel/test-tls-regr-gh-5108.js | 4 +- test/parallel/test-tls-request-timeout.js | 4 +- test/parallel/test-tls-securepair-server.js | 4 +- .../test-tls-server-connection-server.js | 4 +- test/parallel/test-tls-server-verify.js | 5 +- test/parallel/test-tls-session-cache.js | 26 ++-- test/parallel/test-tls-set-ciphers.js | 4 +- test/parallel/test-tls-set-encoding.js | 4 +- test/parallel/test-tls-sni-option.js | 15 +- test/parallel/test-tls-sni-server-client.js | 15 +- .../test-tls-socket-default-options.js | 4 +- test/parallel/test-tls-ticket.js | 4 +- test/parallel/test-tls-timeout-server-2.js | 4 +- test/parallel/test-tls-timeout-server.js | 4 +- test/parallel/test-tls-wrap-timeout.js | 4 +- test/parallel/test-tls-zero-clear-in.js | 4 +- test/parallel/test-zerolengthbufferbug.js | 6 +- 336 files changed, 1514 insertions(+), 1478 deletions(-) diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 5ae8654d337303..3ca0274399bea2 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -76,12 +76,12 @@ net.createServer(function(c) { net.createServer(function(c) { c.end(); this.close(checkTLS); -}).listen(common.PORT, function() { - net.connect(common.PORT, noop); +}).listen(0, function() { + net.connect(this.address().port, noop); }); -dgram.createSocket('udp4').bind(common.PORT, function() { - this.send(new Buffer(2), 0, 2, common.PORT, '::', () => { +dgram.createSocket('udp4').bind(0, function() { + this.send(new Buffer(2), 0, 2, this.address().port, '::', () => { this.close(); }); }); @@ -95,8 +95,9 @@ function checkTLS() { cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem') }; const server = tls.createServer(options, noop) - .listen(common.PORT, function() { - tls.connect(common.PORT, { rejectUnauthorized: false }, function() { + .listen(0, function() { + const connectOpts = { rejectUnauthorized: false }; + tls.connect(this.address().port, connectOpts, function() { this.destroy(); server.close(); }); diff --git a/test/parallel/test-async-wrap-disabled-propagate-parent.js b/test/parallel/test-async-wrap-disabled-propagate-parent.js index f0daaeb06d0031..5b6dd837de2774 100644 --- a/test/parallel/test-async-wrap-disabled-propagate-parent.js +++ b/test/parallel/test-async-wrap-disabled-propagate-parent.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); const async_wrap = process.binding('async_wrap'); @@ -40,8 +40,8 @@ const server = net.createServer(function(c) { c.end(); this.close(); }); -}).listen(common.PORT, function() { - net.connect(common.PORT, noop); +}).listen(0, function() { + net.connect(this.address().port, noop); }); async_wrap.disable(); diff --git a/test/parallel/test-async-wrap-propagate-parent.js b/test/parallel/test-async-wrap-propagate-parent.js index 34a00c22eeeafd..a3902081ea7708 100644 --- a/test/parallel/test-async-wrap-propagate-parent.js +++ b/test/parallel/test-async-wrap-propagate-parent.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); const async_wrap = process.binding('async_wrap'); @@ -40,8 +40,8 @@ const server = net.createServer(function(c) { c.end(); this.close(); }); -}).listen(common.PORT, function() { - net.connect(common.PORT, noop); +}).listen(0, function() { + net.connect(this.address().port, noop); }); diff --git a/test/parallel/test-beforeexit-event.js b/test/parallel/test-beforeexit-event.js index 6bc5ef53ed9518..d50ef67190c4c7 100644 --- a/test/parallel/test-beforeexit-event.js +++ b/test/parallel/test-beforeexit-event.js @@ -1,7 +1,7 @@ 'use strict'; +require('../common'); var assert = require('assert'); var net = require('net'); -var common = require('../common'); var revivals = 0; var deaths = 0; @@ -29,7 +29,7 @@ function tryTimer() { function tryListen() { console.log('create a server'); net.createServer() - .listen(common.PORT) + .listen(0) .on('listening', function() { revivals++; this.close(); diff --git a/test/parallel/test-child-process-disconnect.js b/test/parallel/test-child-process-disconnect.js index fd5153f3965b21..4ef95a3732e3bd 100644 --- a/test/parallel/test-child-process-disconnect.js +++ b/test/parallel/test-child-process-disconnect.js @@ -38,10 +38,10 @@ if (process.argv[2] === 'child') { // when the server is ready tell parent server.on('listening', function() { - process.send('ready'); + process.send({ msg: 'ready', port: server.address().port }); }); - server.listen(common.PORT); + server.listen(0); } else { // testcase @@ -65,11 +65,11 @@ if (process.argv[2] === 'child') { }); // when child is listening - child.on('message', function(msg) { - if (msg === 'ready') { + child.on('message', function(obj) { + if (obj && obj.msg === 'ready') { // connect to child using TCP to know if disconnect was emitted - var socket = net.connect(common.PORT); + var socket = net.connect(obj.port); socket.on('data', function(data) { data = data.toString(); diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js index ce2535a0605122..1edd2b85cac3d6 100644 --- a/test/parallel/test-child-process-fork-dgram.js +++ b/test/parallel/test-child-process-fork-dgram.js @@ -72,7 +72,7 @@ if (process.argv[2] === 'child') { msg, 0, msg.length, - common.PORT, + server.address().port, '127.0.0.1', function(err) { if (err) throw err; @@ -98,7 +98,7 @@ if (process.argv[2] === 'child') { client.close(); }; - server.bind(common.PORT, '127.0.0.1'); + server.bind(0, '127.0.0.1'); process.once('exit', function() { assert(parentGotMessage); diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index 1b12e1e173b92a..cbafcb13fbb068 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); require('../common'); +const assert = require('assert'); const fork = require('child_process').fork; const net = require('net'); diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index 45004041cc1c97..454769b875e181 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/test/parallel/test-child-process-fork-net2.js @@ -99,7 +99,7 @@ if (process.argv[2] === 'child') { var j = count, client; while (j--) { - client = net.connect(common.PORT, '127.0.0.1'); + client = net.connect(this.address().port, '127.0.0.1'); client.on('error', function() { // This can happen if we kill the child too early. // The client should still get a close event afterwards. @@ -125,7 +125,7 @@ if (process.argv[2] === 'child') { child3.kill(); })); - server.listen(common.PORT, '127.0.0.1'); + server.listen(0, '127.0.0.1'); var closeServer = function() { server.close(); diff --git a/test/parallel/test-child-process-fork-regr-gh-2847.js b/test/parallel/test-child-process-fork-regr-gh-2847.js index 12f6f2b9bda5f4..dba33259403cff 100644 --- a/test/parallel/test-child-process-fork-regr-gh-2847.js +++ b/test/parallel/test-child-process-fork-regr-gh-2847.js @@ -25,11 +25,11 @@ var server = net.createServer(function(s) { setTimeout(function() { s.destroy(); }, 100); -}).listen(common.PORT, function() { +}).listen(0, function() { var worker = cluster.fork(); function send(callback) { - var s = net.connect(common.PORT, function() { + var s = net.connect(server.address().port, function() { worker.send({}, s, callback); }); diff --git a/test/parallel/test-child-process-recv-handle.js b/test/parallel/test-child-process-recv-handle.js index 5c16c7a1c65850..441740e2d483bd 100644 --- a/test/parallel/test-child-process-recv-handle.js +++ b/test/parallel/test-child-process-recv-handle.js @@ -24,7 +24,7 @@ function master() { }); proc.stdout.on('data', function(data) { assert.equal(data, 'ok\r\n'); - net.createServer(common.fail).listen(common.PORT, function() { + net.createServer(common.fail).listen(0, function() { handle = this._handle; proc.send('one'); proc.send('two', handle); diff --git a/test/parallel/test-crypto-verify-failure.js b/test/parallel/test-crypto-verify-failure.js index f260ccfe128eaf..fdc27215027414 100644 --- a/test/parallel/test-crypto-verify-failure.js +++ b/test/parallel/test-crypto-verify-failure.js @@ -36,9 +36,9 @@ function verify() { .verify(certPem, 'asdfasdfas', 'base64'); } -server.listen(common.PORT, function() { +server.listen(0, function() { tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { verify(); diff --git a/test/parallel/test-dgram-address.js b/test/parallel/test-dgram-address.js index f128ce5110317b..38729de67098da 100644 --- a/test/parallel/test-dgram-address.js +++ b/test/parallel/test-dgram-address.js @@ -10,7 +10,9 @@ var family_ipv4 = 'IPv4'; socket_ipv4.on('listening', function() { var address_ipv4 = socket_ipv4.address(); assert.strictEqual(address_ipv4.address, common.localhostIPv4); - assert.strictEqual(address_ipv4.port, common.PORT); + assert.strictEqual(typeof address_ipv4.port, 'number'); + assert.ok(isFinite(address_ipv4.port)); + assert.ok(address_ipv4.port > 0); assert.strictEqual(address_ipv4.family, family_ipv4); socket_ipv4.close(); }); @@ -20,7 +22,7 @@ socket_ipv4.on('error', function(e) { socket_ipv4.close(); }); -socket_ipv4.bind(common.PORT, common.localhostIPv4); +socket_ipv4.bind(0, common.localhostIPv4); // IPv6 Test var localhost_ipv6 = '::1'; @@ -30,7 +32,9 @@ var family_ipv6 = 'IPv6'; socket_ipv6.on('listening', function() { var address_ipv6 = socket_ipv6.address(); assert.strictEqual(address_ipv6.address, localhost_ipv6); - assert.strictEqual(address_ipv6.port, common.PORT); + assert.strictEqual(typeof address_ipv6.port, 'number'); + assert.ok(isFinite(address_ipv6.port)); + assert.ok(address_ipv6.port > 0); assert.strictEqual(address_ipv6.family, family_ipv6); socket_ipv6.close(); }); @@ -40,4 +44,4 @@ socket_ipv6.on('error', function(e) { socket_ipv6.close(); }); -socket_ipv6.bind(common.PORT, localhost_ipv6); +socket_ipv6.bind(0, localhost_ipv6); diff --git a/test/parallel/test-dgram-bind-default-address.js b/test/parallel/test-dgram-bind-default-address.js index 3d786209260408..b2bd72f6db6a7c 100644 --- a/test/parallel/test-dgram-bind-default-address.js +++ b/test/parallel/test-dgram-bind-default-address.js @@ -9,8 +9,10 @@ if (common.inFreeBSDJail) { return; } -dgram.createSocket('udp4').bind(common.PORT + 0, common.mustCall(function() { - assert.equal(this.address().port, common.PORT + 0); +dgram.createSocket('udp4').bind(0, common.mustCall(function() { + assert.strictEqual(typeof this.address().port, 'number'); + assert.ok(isFinite(this.address().port)); + assert.ok(this.address().port > 0); assert.equal(this.address().address, '0.0.0.0'); this.close(); })); @@ -20,8 +22,10 @@ if (!common.hasIPv6) { return; } -dgram.createSocket('udp6').bind(common.PORT + 1, common.mustCall(function() { - assert.equal(this.address().port, common.PORT + 1); +dgram.createSocket('udp6').bind(0, common.mustCall(function() { + assert.strictEqual(typeof this.address().port, 'number'); + assert.ok(isFinite(this.address().port)); + assert.ok(this.address().port > 0); var address = this.address().address; if (address === '::ffff:0.0.0.0') address = '::'; diff --git a/test/parallel/test-dgram-empty-packet.js b/test/parallel/test-dgram-empty-packet.js index 696102bcb9f303..88ecc6ef745833 100644 --- a/test/parallel/test-dgram-empty-packet.js +++ b/test/parallel/test-dgram-empty-packet.js @@ -13,26 +13,27 @@ if (process.platform === 'darwin') { client = dgram.createSocket('udp4'); -client.bind(common.PORT); - -function callback() { - callbacks++; - if (callbacks == 2) { - clearTimeout(timer); - client.close(); - } else if (callbacks > 2) { - throw new Error('the callbacks should be called only two times'); +client.bind(0, function() { + function callback() { + callbacks++; + if (callbacks == 2) { + clearTimeout(timer); + client.close(); + } else if (callbacks > 2) { + throw new Error('the callbacks should be called only two times'); + } } -} -client.on('message', function(buffer, bytes) { - callback(); -}); + client.on('message', function(buffer, bytes) { + callback(); + }); -client.send(new Buffer(1), 0, 0, common.PORT, '127.0.0.1', function(err, len) { - callback(); -}); + const port = this.address().port; + client.send(new Buffer(1), 0, 0, port, '127.0.0.1', function(err, len) { + callback(); + }); -timer = setTimeout(function() { - throw new Error('Timeout'); -}, 200); + timer = setTimeout(function() { + throw new Error('Timeout'); + }, 200); +}); diff --git a/test/parallel/test-dgram-error-message-address.js b/test/parallel/test-dgram-error-message-address.js index 005695654f9542..d27b0043321aaf 100644 --- a/test/parallel/test-dgram-error-message-address.js +++ b/test/parallel/test-dgram-error-message-address.js @@ -9,14 +9,14 @@ var socket_ipv4 = dgram.createSocket('udp4'); socket_ipv4.on('listening', common.fail); socket_ipv4.on('error', common.mustCall(function(e) { - assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1:' + common.PORT); + assert.strictEqual(e.port, undefined); + assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1'); assert.equal(e.address, '1.1.1.1'); - assert.equal(e.port, common.PORT); assert.equal(e.code, 'EADDRNOTAVAIL'); socket_ipv4.close(); })); -socket_ipv4.bind(common.PORT, '1.1.1.1'); +socket_ipv4.bind(0, '1.1.1.1'); // IPv6 Test var socket_ipv6 = dgram.createSocket('udp6'); @@ -27,10 +27,10 @@ socket_ipv6.on('error', common.mustCall(function(e) { // EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system. var allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT']; assert.notEqual(allowed.indexOf(e.code), -1); - assert.equal(e.message, 'bind ' + e.code + ' 111::1:' + common.PORT); + assert.strictEqual(e.port, undefined); + assert.equal(e.message, 'bind ' + e.code + ' 111::1'); assert.equal(e.address, '111::1'); - assert.equal(e.port, common.PORT); socket_ipv6.close(); })); -socket_ipv6.bind(common.PORT, '111::1'); +socket_ipv6.bind(0, '111::1'); diff --git a/test/parallel/test-dgram-implicit-bind.js b/test/parallel/test-dgram-implicit-bind.js index 8b78bd66c6f313..bf1962143d856f 100644 --- a/test/parallel/test-dgram-implicit-bind.js +++ b/test/parallel/test-dgram-implicit-bind.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var dgram = require('dgram'); @@ -22,8 +22,9 @@ target.on('message', function(buf) { target.on('listening', function() { // Second .send() call should not throw a bind error. - source.send(Buffer('abc'), 0, 3, common.PORT, '127.0.0.1'); - source.send(Buffer('def'), 0, 3, common.PORT, '127.0.0.1'); + const port = this.address().port; + source.send(Buffer('abc'), 0, 3, port, '127.0.0.1'); + source.send(Buffer('def'), 0, 3, port, '127.0.0.1'); }); -target.bind(common.PORT); +target.bind(0); diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index 7f641237c7999b..83d482f426bcd4 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); let thrown = false; -socket.bind(common.PORT); +socket.bind(0); socket.on('listening', function() { socket.setMulticastTTL(16); diff --git a/test/parallel/test-dgram-send-callback-recursive.js b/test/parallel/test-dgram-send-callback-recursive.js index 63edd5e58716f3..c54b05c3f86ba1 100644 --- a/test/parallel/test-dgram-send-callback-recursive.js +++ b/test/parallel/test-dgram-send-callback-recursive.js @@ -9,17 +9,19 @@ let received = 0; let sent = 0; const limit = 10; let async = false; +let port; function onsend() { if (sent++ < limit) { - client.send( - chunk, 0, chunk.length, common.PORT, common.localhostIPv4, onsend); + client.send(chunk, 0, chunk.length, port, common.localhostIPv4, onsend); } else { assert.strictEqual(async, true, 'Send should be asynchronous.'); } } client.on('listening', function() { + port = this.address().port; + setImmediate(function() { async = true; }); @@ -38,4 +40,4 @@ client.on('close', common.mustCall(function() { assert.equal(received, limit); })); -client.bind(common.PORT); +client.bind(0); diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js index 190a3fe61edefe..4d269ee956f785 100644 --- a/test/parallel/test-dgram-send-empty-buffer.js +++ b/test/parallel/test-dgram-send-empty-buffer.js @@ -9,16 +9,18 @@ if (process.platform === 'darwin') { const client = dgram.createSocket('udp4'); -client.bind(common.PORT); +client.bind(0, function() { + const port = this.address().port; -client.on('message', function(buffer, bytes) { - clearTimeout(timer); - client.close(); -}); + client.on('message', common.mustCall(function onMessage(buffer, bytes) { + clearTimeout(timer); + client.close(); + })); -const buf = new Buffer(0); -client.send(buf, 0, 0, common.PORT, '127.0.0.1', function(err, len) { }); + const buf = new Buffer(0); + client.send(buf, 0, 0, port, '127.0.0.1', function(err, len) { }); -const timer = setTimeout(function() { - throw new Error('Timeout'); -}, common.platformTimeout(200)); + const timer = setTimeout(function() { + throw new Error('Timeout'); + }, common.platformTimeout(200)); +}); diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js index 88627a314c3848..9393e53c7f1912 100644 --- a/test/parallel/test-dgram-setTTL.js +++ b/test/parallel/test-dgram-setTTL.js @@ -1,10 +1,10 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); -socket.bind(common.PORT); +socket.bind(0); socket.on('listening', function() { var result = socket.setTTL(16); assert.strictEqual(result, 16); diff --git a/test/parallel/test-dgram-udp4.js b/test/parallel/test-dgram-udp4.js index 792aabb8c82597..5902dab3597af4 100644 --- a/test/parallel/test-dgram-udp4.js +++ b/test/parallel/test-dgram-udp4.js @@ -2,7 +2,6 @@ const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); -const server_port = common.PORT; const message_to_send = 'A message to send'; const server = dgram.createSocket('udp4'); @@ -13,9 +12,10 @@ server.on('message', common.mustCall((msg, rinfo) => { })); server.on('listening', common.mustCall(() => { const client = dgram.createSocket('udp4'); + const port = server.address().port; client.on('message', common.mustCall((msg, rinfo) => { assert.strictEqual(rinfo.address, common.localhostIPv4); - assert.strictEqual(rinfo.port, server_port); + assert.strictEqual(rinfo.port, port); assert.strictEqual(msg.toString(), message_to_send.toString()); client.close(); server.close(); @@ -23,10 +23,9 @@ server.on('listening', common.mustCall(() => { client.send(message_to_send, 0, message_to_send.length, - server_port, + port, 'localhost'); client.on('close', common.mustCall(() => {})); })); server.on('close', common.mustCall(() => {})); -server.bind(server_port); - +server.bind(0); diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js index 3adbb91f93d639..93d330e3d67370 100644 --- a/test/parallel/test-domain-abort-on-uncaught.js +++ b/test/parallel/test-domain-abort-on-uncaught.js @@ -109,8 +109,8 @@ const tests = [ const server = net.createServer(function(conn) { conn.pipe(conn); }); - server.listen(common.PORT, common.localhostIPv4, function() { - const conn = net.connect(common.PORT, common.localhostIPv4); + server.listen(0, common.localhostIPv4, function() { + const conn = net.connect(this.address().port, common.localhostIPv4); conn.once('data', function() { throw new Error('ok'); }); diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 594c34aae8d201..e131e02ea4d74b 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -1,8 +1,8 @@ 'use strict'; +require('../common'); var domain = require('domain'); var http = require('http'); var assert = require('assert'); -var common = require('../common'); var objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; objects.baz.asdf = objects; @@ -37,10 +37,11 @@ var server = http.createServer(function(req, res) { }); }); -server.listen(common.PORT, next); +server.listen(0, next); function next() { - console.log('listening on localhost:%d', common.PORT); + const port = this.address().port; + console.log('listening on localhost:%d', port); var requests = 0; var responses = 0; @@ -61,7 +62,7 @@ function next() { req.socket.destroy(); }); - var req = http.get({ host: 'localhost', port: common.PORT, path: p }); + var req = http.get({ host: 'localhost', port: port, path: p }); dom.add(req); req.on('response', function(res) { responses++; diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index ac01d66deee544..1b0af1dd3f438f 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -1,7 +1,7 @@ 'use strict'; // Tests of multiple domains happening at once. -var common = require('../common'); +require('../common'); var assert = require('assert'); var domain = require('domain'); @@ -49,24 +49,24 @@ var server = http.createServer(function(req, res) { throw new Error('this kills domain B, not A'); })); -}).listen(common.PORT); +}).listen(0, function() { + var c = domain.create(); + var req = http.get({ host: 'localhost', port: this.address().port }); -var c = domain.create(); -var req = http.get({ host: 'localhost', port: common.PORT }); + // add the request to the C domain + c.add(req); -// add the request to the C domain -c.add(req); - -req.on('response', function(res) { - console.error('got response'); - // add the response object to the C domain - c.add(res); - res.pipe(process.stdout); -}); + req.on('response', function(res) { + console.error('got response'); + // add the response object to the C domain + c.add(res); + res.pipe(process.stdout); + }); -c.on('error', function(er) { - caughtC = true; - console.error('Error on c', er.message); + c.on('error', function(er) { + caughtC = true; + console.error('Error on c', er.message); + }); }); process.on('exit', function() { diff --git a/test/parallel/test-http-1.0-keep-alive.js b/test/parallel/test-http-1.0-keep-alive.js index fa49707c24a8d5..383f67c90a31b5 100644 --- a/test/parallel/test-http-1.0-keep-alive.js +++ b/test/parallel/test-http-1.0-keep-alive.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var net = require('net'); @@ -84,14 +84,17 @@ check([{ function check(tests) { var test = tests[0]; - if (test) http.createServer(server).listen(common.PORT, '127.0.0.1', client); + var server; + if (test) { + server = http.createServer(serverHandler).listen(0, '127.0.0.1', client); + } var current = 0; function next() { check(tests.slice(1)); } - function server(req, res) { + function serverHandler(req, res) { if (current + 1 === test.responses.length) this.close(); var ctx = test.responses[current]; console.error('< SERVER SENDING RESPONSE', ctx); @@ -102,7 +105,8 @@ function check(tests) { function client() { if (current === test.requests.length) return next(); - var conn = net.createConnection(common.PORT, '127.0.0.1', connected); + const port = server.address().port; + var conn = net.createConnection(port, '127.0.0.1', connected); function connected() { var ctx = test.requests[current]; diff --git a/test/parallel/test-http-1.0.js b/test/parallel/test-http-1.0.js index facf5c98eacb83..622dd4a16f1516 100644 --- a/test/parallel/test-http-1.0.js +++ b/test/parallel/test-http-1.0.js @@ -6,18 +6,15 @@ var http = require('http'); var body = 'hello world\n'; -var common_port = common.PORT; - function test(handler, request_generator, response_validator) { - var port = common_port++; var server = http.createServer(handler); var client_got_eof = false; var server_response = ''; - server.listen(port); + server.listen(0); server.on('listening', function() { - var c = net.createConnection(port); + var c = net.createConnection(this.address().port); c.setEncoding('utf8'); diff --git a/test/parallel/test-http-abort-before-end.js b/test/parallel/test-http-abort-before-end.js index c0cee3886f4406..2934f1d74e34d3 100644 --- a/test/parallel/test-http-abort-before-end.js +++ b/test/parallel/test-http-abort-before-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var assert = require('assert'); @@ -7,8 +7,12 @@ var server = http.createServer(function(req, res) { assert(false); // should not be called }); -server.listen(common.PORT, function() { - var req = http.request({method: 'GET', host: '127.0.0.1', port: common.PORT}); +server.listen(0, function() { + var req = http.request({ + method: 'GET', + host: '127.0.0.1', + port: this.address().port + }); req.on('error', function(ex) { // https://github.com/joyent/node/issues/1399#issuecomment-2597359 diff --git a/test/parallel/test-http-abort-client.js b/test/parallel/test-http-abort-client.js index 4d7a32c1dfb26b..47da913fb814e3 100644 --- a/test/parallel/test-http-abort-client.js +++ b/test/parallel/test-http-abort-client.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var assert = require('assert'); @@ -13,11 +13,10 @@ var server = http.Server(function(req, res) { var responseClose = false; -server.listen(common.PORT, function() { +server.listen(0, function() { http.get({ - port: common.PORT, + port: this.address().port, headers: { connection: 'keep-alive' } - }, function(res) { server.close(); diff --git a/test/parallel/test-http-abort-queued.js b/test/parallel/test-http-abort-queued.js index d28ad01888884d..0a993a2658ca11 100644 --- a/test/parallel/test-http-abort-queued.js +++ b/test/parallel/test-http-abort-queued.js @@ -1,6 +1,6 @@ 'use strict'; +require('../common'); const assert = require('assert'); -const common = require('../common'); const http = require('http'); var complete; @@ -19,7 +19,7 @@ var server = http.createServer(function(req, res) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { console.log('listen', server.address().port); var agent = new http.Agent({maxSockets: 1}); diff --git a/test/parallel/test-http-after-connect.js b/test/parallel/test-http-after-connect.js index ed18def8608820..0bae99b1d34cf1 100644 --- a/test/parallel/test-http-after-connect.js +++ b/test/parallel/test-http-after-connect.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -26,9 +26,9 @@ server.on('connect', function(req, socket, firstBodyChunk) { socket.end(); }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'CONNECT', path: 'google.com:80' }); @@ -46,7 +46,7 @@ server.listen(common.PORT, function() { function doRequest(i) { http.get({ - port: common.PORT, + port: server.address().port, path: '/request' + i }, function(res) { console.error('Client got GET response'); diff --git a/test/parallel/test-http-agent-destroyed-socket.js b/test/parallel/test-http-agent-destroyed-socket.js index 954acc998c035d..34772f7d3e3081 100644 --- a/test/parallel/test-http-agent-destroyed-socket.js +++ b/test/parallel/test-http-agent-destroyed-socket.js @@ -1,86 +1,86 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); -}).listen(common.PORT); +}).listen(0, function() { + var agent = new http.Agent({maxSockets: 1}); -var agent = new http.Agent({maxSockets: 1}); - -agent.on('free', function(socket, host, port) { - console.log('freeing socket. destroyed? ', socket.destroyed); -}); + agent.on('free', function(socket, host, port) { + console.log('freeing socket. destroyed? ', socket.destroyed); + }); -var requestOptions = { - agent: agent, - host: 'localhost', - port: common.PORT, - path: '/' -}; + var requestOptions = { + agent: agent, + host: 'localhost', + port: this.address().port, + path: '/' + }; -var request1 = http.get(requestOptions, function(response) { - // assert request2 is queued in the agent - var key = agent.getName(requestOptions); - assert(agent.requests[key].length === 1); - console.log('got response1'); - request1.socket.on('close', function() { - console.log('request1 socket closed'); - }); - response.pipe(process.stdout); - response.on('end', function() { - console.log('response1 done'); - ///////////////////////////////// - // - // THE IMPORTANT PART - // - // It is possible for the socket to get destroyed and other work - // to run before the 'close' event fires because it happens on - // nextTick. This example is contrived because it destroys the - // socket manually at just the right time, but at Voxer we have - // seen cases where the socket is destroyed by non-user code - // then handed out again by an agent *before* the 'close' event - // is triggered. - request1.socket.destroy(); + var request1 = http.get(requestOptions, function(response) { + // assert request2 is queued in the agent + var key = agent.getName(requestOptions); + assert(agent.requests[key].length === 1); + console.log('got response1'); + request1.socket.on('close', function() { + console.log('request1 socket closed'); + }); + response.pipe(process.stdout); + response.on('end', function() { + console.log('response1 done'); + ///////////////////////////////// + // + // THE IMPORTANT PART + // + // It is possible for the socket to get destroyed and other work + // to run before the 'close' event fires because it happens on + // nextTick. This example is contrived because it destroys the + // socket manually at just the right time, but at Voxer we have + // seen cases where the socket is destroyed by non-user code + // then handed out again by an agent *before* the 'close' event + // is triggered. + request1.socket.destroy(); - response.once('close', function() { - // assert request2 was removed from the queue - assert(!agent.requests[key]); - console.log("waiting for request2.onSocket's nextTick"); - process.nextTick(function() { - // assert that the same socket was not assigned to request2, - // since it was destroyed. - assert(request1.socket !== request2.socket); - assert(!request2.socket.destroyed, 'the socket is destroyed'); + response.once('close', function() { + // assert request2 was removed from the queue + assert(!agent.requests[key]); + console.log("waiting for request2.onSocket's nextTick"); + process.nextTick(function() { + // assert that the same socket was not assigned to request2, + // since it was destroyed. + assert(request1.socket !== request2.socket); + assert(!request2.socket.destroyed, 'the socket is destroyed'); + }); }); }); }); -}); -var request2 = http.get(requestOptions, function(response) { - assert(!request2.socket.destroyed); - assert(request1.socket.destroyed); - // assert not reusing the same socket, since it was destroyed. - assert(request1.socket !== request2.socket); - console.log('got response2'); - var gotClose = false; - var gotResponseEnd = false; - request2.socket.on('close', function() { - console.log('request2 socket closed'); - gotClose = true; - done(); - }); - response.pipe(process.stdout); - response.on('end', function() { - console.log('response2 done'); - gotResponseEnd = true; - done(); - }); + var request2 = http.get(requestOptions, function(response) { + assert(!request2.socket.destroyed); + assert(request1.socket.destroyed); + // assert not reusing the same socket, since it was destroyed. + assert(request1.socket !== request2.socket); + console.log('got response2'); + var gotClose = false; + var gotResponseEnd = false; + request2.socket.on('close', function() { + console.log('request2 socket closed'); + gotClose = true; + done(); + }); + response.pipe(process.stdout); + response.on('end', function() { + console.log('response2 done'); + gotResponseEnd = true; + done(); + }); - function done() { - if (gotResponseEnd && gotClose) - server.close(); - } + function done() { + if (gotResponseEnd && gotClose) + server.close(); + } + }); }); diff --git a/test/parallel/test-http-agent-error-on-idle.js b/test/parallel/test-http-agent-error-on-idle.js index f609efc8d59b6d..59b0109ef1c398 100644 --- a/test/parallel/test-http-agent-error-on-idle.js +++ b/test/parallel/test-http-agent-error-on-idle.js @@ -1,31 +1,27 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var Agent = http.Agent; -var agent = new Agent({ - keepAlive: true, +var server = http.createServer(function(req, res) { + res.end('hello world'); }); -var requestParams = { - host: 'localhost', - port: common.PORT, - agent: agent, - path: '/' -}; - -var socketKey = agent.getName(requestParams); +server.listen(0, function() { + var agent = new Agent({ + keepAlive: true, + }); -function get(callback) { - return http.get(requestParams, callback); -} + var requestParams = { + host: 'localhost', + port: this.address().port, + agent: agent, + path: '/' + }; -var server = http.createServer(function(req, res) { - res.end('hello world'); -}); + var socketKey = agent.getName(requestParams); -server.listen(common.PORT, function() { get(function(res) { assert.equal(res.statusCode, 200); res.resume(); @@ -43,13 +39,17 @@ server.listen(common.PORT, function() { }); }); }); -}); -function done() { - assert.equal(Object.keys(agent.freeSockets).length, 0, - 'expect the freeSockets pool to be empty'); + function get(callback) { + return http.get(requestParams, callback); + } - agent.destroy(); - server.close(); - process.exit(0); -} + function done() { + assert.equal(Object.keys(agent.freeSockets).length, 0, + 'expect the freeSockets pool to be empty'); + + agent.destroy(); + server.close(); + process.exit(0); + } +}); diff --git a/test/parallel/test-http-agent-keepalive.js b/test/parallel/test-http-agent-keepalive.js index 85c0ad5dbc2b4f..02d4754602f20d 100644 --- a/test/parallel/test-http-agent-keepalive.js +++ b/test/parallel/test-http-agent-keepalive.js @@ -4,6 +4,8 @@ const assert = require('assert'); const http = require('http'); const Agent = require('_http_agent').Agent; +let name; + const agent = new Agent({ keepAlive: true, keepAliveMsecs: 1000, @@ -28,14 +30,12 @@ const server = http.createServer(function(req, res) { function get(path, callback) { return http.get({ host: 'localhost', - port: common.PORT, + port: server.address().port, agent: agent, path: path }, callback); } -const name = 'localhost:' + common.PORT + ':'; - function checkDataAndSockets(body) { assert.equal(body.toString(), 'hello world'); assert.equal(agent.sockets[name].length, 1); @@ -106,7 +106,8 @@ function done() { process.exit(0); } -server.listen(common.PORT, function() { +server.listen(0, function() { + name = `localhost:${server.address().port}:`; // request first, and keep alive get('/first', function(res) { assert.equal(res.statusCode, 200); diff --git a/test/parallel/test-http-agent-maxsockets-regress-4050.js b/test/parallel/test-http-agent-maxsockets-regress-4050.js index 1cbe37cf0cc443..0ba3d1304f0d68 100644 --- a/test/parallel/test-http-agent-maxsockets-regress-4050.js +++ b/test/parallel/test-http-agent-maxsockets-regress-4050.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const http = require('http'); @@ -19,13 +19,13 @@ const server = http.createServer(function(req, res) { function get(path, callback) { return http.get({ host: 'localhost', - port: common.PORT, + port: server.address().port, agent: agent, path: path }, callback); } -server.listen(common.PORT, function() { +server.listen(0, function() { var finished = 0; const num_requests = 6; for (var i = 0; i < num_requests; i++) { diff --git a/test/parallel/test-http-agent-maxsockets.js b/test/parallel/test-http-agent-maxsockets.js index 11f8d28a7389e2..ea443ff9bd1107 100644 --- a/test/parallel/test-http-agent-maxsockets.js +++ b/test/parallel/test-http-agent-maxsockets.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,7 +17,7 @@ var server = http.createServer(function(req, res) { function get(path, callback) { return http.get({ host: 'localhost', - port: common.PORT, + port: server.address().port, agent: agent, path: path }, callback); @@ -35,7 +35,7 @@ function done() { server.close(); } -server.listen(common.PORT, function() { +server.listen(0, function() { get('/1', function(res) { assert.equal(res.statusCode, 200); res.resume(); diff --git a/test/parallel/test-http-agent-no-protocol.js b/test/parallel/test-http-agent-no-protocol.js index d5b7e5e19440f9..0feb4d9fcf8a39 100644 --- a/test/parallel/test-http-agent-no-protocol.js +++ b/test/parallel/test-http-agent-no-protocol.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); @@ -14,8 +14,8 @@ process.on('exit', function() { var server = http.createServer(function(req, res) { res.end(); request++; -}).listen(common.PORT, '127.0.0.1', function() { - var opts = url.parse('http://127.0.0.1:' + common.PORT + '/'); +}).listen(0, '127.0.0.1', function() { + var opts = url.parse(`http://127.0.0.1:${this.address().port}/`); // remove the `protocol` field… the `http` module should fall back // to "http:", as defined by the global, default `http.Agent` instance. diff --git a/test/parallel/test-http-agent-null.js b/test/parallel/test-http-agent-null.js index 29961ff3a5e84b..cb8cc9ab00ed26 100644 --- a/test/parallel/test-http-agent-null.js +++ b/test/parallel/test-http-agent-null.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -13,7 +13,7 @@ process.on('exit', function() { var server = http.createServer(function(req, res) { request++; res.end(); -}).listen(common.PORT, function() { +}).listen(0, function() { var options = { agent: null, port: this.address().port diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js index 54094d1a68a511..075049d416f6aa 100644 --- a/test/parallel/test-http-agent.js +++ b/test/parallel/test-http-agent.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -12,11 +12,12 @@ var responses = 0; var N = 4; var M = 4; -server.listen(common.PORT, function() { +server.listen(0, function() { + const port = this.address().port; for (var i = 0; i < N; i++) { setTimeout(function() { for (var j = 0; j < M; j++) { - http.get({ port: common.PORT, path: '/' }, function(res) { + http.get({ port: port, path: '/' }, function(res) { console.log('%d %d', responses, res.statusCode); if (++responses == N * M) { console.error('Received all responses, closing server'); diff --git a/test/parallel/test-http-allow-req-after-204-res.js b/test/parallel/test-http-allow-req-after-204-res.js index ba98138bdca568..34d7c0bbdabca6 100644 --- a/test/parallel/test-http-allow-req-after-204-res.js +++ b/test/parallel/test-http-allow-req-after-204-res.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var assert = require('assert'); @@ -23,7 +23,7 @@ function nextRequest() { console.error('writing request: %s', method); var request = http.request({ - port: common.PORT, + port: server.address().port, method: method, path: '/' }, function(response) { @@ -43,4 +43,4 @@ function nextRequest() { request.end(); } -server.listen(common.PORT, nextRequest); +server.listen(0, nextRequest); diff --git a/test/parallel/test-http-automatic-headers.js b/test/parallel/test-http-automatic-headers.js index 8c454517020460..600be8e43ee23c 100644 --- a/test/parallel/test-http-automatic-headers.js +++ b/test/parallel/test-http-automatic-headers.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -9,12 +9,12 @@ var server = http.createServer(function(req, res) { res.setHeader('X-Content-Length', 'baz'); res.end(); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { - var agent = new http.Agent({ port: common.PORT, maxSockets: 1 }); + var agent = new http.Agent({ port: this.address().port, maxSockets: 1 }); http.get({ - port: common.PORT, + port: this.address().port, path: '/hello', agent: agent }, function(res) { diff --git a/test/parallel/test-http-bind-twice.js b/test/parallel/test-http-bind-twice.js index 4dde7c6d252c6a..453b23279e8e93 100644 --- a/test/parallel/test-http-bind-twice.js +++ b/test/parallel/test-http-bind-twice.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -14,14 +14,13 @@ function dontCall() { } var server1 = http.createServer(dontCall); -server1.listen(common.PORT, '127.0.0.1', function() {}); +server1.listen(0, '127.0.0.1', function() { + var server2 = http.createServer(dontCall); + server2.listen(this.address().port, '127.0.0.1', dontCall); -var server2 = http.createServer(dontCall); -server2.listen(common.PORT, '127.0.0.1', dontCall); - -server2.on('error', function(e) { - assert.equal(e.code, 'EADDRINUSE'); - server1.close(); - gotError = true; + server2.on('error', function(e) { + assert.equal(e.code, 'EADDRINUSE'); + server1.close(); + gotError = true; + }); }); - diff --git a/test/parallel/test-http-blank-header.js b/test/parallel/test-http-blank-header.js index 44f487d6b30f58..cd8e5aa1c89339 100644 --- a/test/parallel/test-http-blank-header.js +++ b/test/parallel/test-http-blank-header.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -18,8 +18,8 @@ var server = http.createServer(function(req, res) { }); -server.listen(common.PORT, function() { - var c = net.createConnection(common.PORT); +server.listen(0, function() { + var c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /blah HTTP/1.1\r\n' + diff --git a/test/parallel/test-http-buffer-sanity.js b/test/parallel/test-http-buffer-sanity.js index 98ce0f75b916a8..4cd6c80e25c520 100644 --- a/test/parallel/test-http-buffer-sanity.js +++ b/test/parallel/test-http-buffer-sanity.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -44,11 +44,11 @@ var web = http.Server(function(req, res) { var gotThanks = false; -web.listen(common.PORT, function() { +web.listen(0, function() { console.log('Making request'); var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'GET', path: '/', headers: { 'content-length': buffer.length } diff --git a/test/parallel/test-http-byteswritten.js b/test/parallel/test-http-byteswritten.js index 41d8f4d40d1bf7..c00edf72bd5f2b 100644 --- a/test/parallel/test-http-byteswritten.js +++ b/test/parallel/test-http-byteswritten.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -36,7 +36,7 @@ var httpServer = http.createServer(function(req, res) { res.end(body); }); -httpServer.listen(common.PORT, function() { - http.get({ port: common.PORT }); +httpServer.listen(0, function() { + http.get({ port: this.address().port }); }); diff --git a/test/parallel/test-http-catch-uncaughtexception.js b/test/parallel/test-http-catch-uncaughtexception.js index c4054aafbfb699..06d9b9a6e5d4e0 100644 --- a/test/parallel/test-http-catch-uncaughtexception.js +++ b/test/parallel/test-http-catch-uncaughtexception.js @@ -13,8 +13,8 @@ process.on('uncaughtException', uncaughtCallback); const server = http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('bye'); -}).listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +}).listen(0, function() { + http.get({ port: this.address().port }, function(res) { res.resume(); throw new Error('get did fail'); }).on('close', function() { diff --git a/test/parallel/test-http-chunk-problem.js b/test/parallel/test-http-chunk-problem.js index 23ec2d0263fa94..9bb004dc973f5c 100644 --- a/test/parallel/test-http-chunk-problem.js +++ b/test/parallel/test-http-chunk-problem.js @@ -10,7 +10,7 @@ if (!common.hasCrypto) { if (process.argv[2] === 'request') { const http = require('http'); const options = { - port: common.PORT, + port: +process.argv[3], path: '/' }; @@ -39,11 +39,13 @@ const http = require('http'); const cp = require('child_process'); const filename = require('path').join(common.tmpDir, 'big'); +let server; function executeRequest(cb) { cp.exec([process.execPath, __filename, 'request', + server.address().port, '|', process.execPath, __filename, @@ -64,7 +66,7 @@ const ddcmd = common.ddCommand(filename, 10240); cp.exec(ddcmd, function(err, stdout, stderr) { if (err) throw err; - const server = http.createServer(function(req, res) { + server = http.createServer(function(req, res) { res.writeHead(200); // Create the subprocess @@ -87,7 +89,7 @@ cp.exec(ddcmd, function(err, stdout, stderr) { }); - server.listen(common.PORT, () => { + server.listen(0, () => { executeRequest(() => server.close()); }); }); diff --git a/test/parallel/test-http-chunked-304.js b/test/parallel/test-http-chunked-304.js index 0f979420488d60..5ea1912b72dfee 100644 --- a/test/parallel/test-http-chunked-304.js +++ b/test/parallel/test-http-chunked-304.js @@ -23,8 +23,8 @@ function test(statusCode, next) { server.close(); }); - server.listen(common.PORT, function() { - var conn = net.createConnection(common.PORT, function() { + server.listen(0, function() { + var conn = net.createConnection(this.address().port, function() { conn.write('GET / HTTP/1.1\r\n\r\n'); var resp = ''; diff --git a/test/parallel/test-http-chunked.js b/test/parallel/test-http-chunked.js index 74b6943ab41f41..6edb1b3f96a74b 100644 --- a/test/parallel/test-http-chunked.js +++ b/test/parallel/test-http-chunked.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,12 +17,12 @@ var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8'}); res.end(UTF8_STRING, 'utf8'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var data = ''; var get = http.get({ path: '/', host: 'localhost', - port: common.PORT + port: this.address().port }, function(x) { x.setEncoding('utf8'); x.on('data', function(c) {data += c;}); diff --git a/test/parallel/test-http-client-abort-event.js b/test/parallel/test-http-client-abort-event.js index b428038028ad8e..8f98b578930cdb 100644 --- a/test/parallel/test-http-client-abort-event.js +++ b/test/parallel/test-http-client-abort-event.js @@ -1,14 +1,14 @@ 'use strict'; +require('../common'); var assert = require('assert'); var http = require('http'); -var common = require('../common'); var server = http.createServer(function(req, res) { res.end(); }); var count = 0; -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT + port: this.address().port }, function() { assert(false, 'should not receive data'); }); diff --git a/test/parallel/test-http-client-abort.js b/test/parallel/test-http-client-abort.js index a7d0510070e8ee..73f05da577d440 100644 --- a/test/parallel/test-http-client-abort.js +++ b/test/parallel/test-http-client-abort.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const http = require('http'); @@ -33,12 +33,12 @@ var responses = 0; const N = 8; const requests = []; -server.listen(common.PORT, function() { +server.listen(0, function() { console.log('Server listening.'); for (var i = 0; i < N; i++) { console.log('Making client ' + i); - var options = { port: common.PORT, path: '/?id=' + i }; + var options = { port: this.address().port, path: '/?id=' + i }; var req = http.get(options, function(res) { console.log('Client response code ' + res.statusCode); diff --git a/test/parallel/test-http-client-abort2.js b/test/parallel/test-http-client-abort2.js index 477d12b25827b2..9caa9d0a78c248 100644 --- a/test/parallel/test-http-client-abort2.js +++ b/test/parallel/test-http-client-abort2.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var server = http.createServer(function(req, res) { res.end('Hello'); }); -server.listen(common.PORT, function() { - var req = http.get({port: common.PORT}, function(res) { +server.listen(0, function() { + var req = http.get({port: this.address().port}, function(res) { res.on('data', function(data) { req.abort(); server.close(); diff --git a/test/parallel/test-http-client-agent.js b/test/parallel/test-http-client-agent.js index afe98902e5b6fc..36ed24ec526255 100644 --- a/test/parallel/test-http-client-agent.js +++ b/test/parallel/test-http-client-agent.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); -var name = http.globalAgent.getName({ port: common.PORT }); +var name; var max = 3; var count = 0; @@ -18,7 +18,8 @@ var server = http.Server(function(req, res) { res.end('Hello, World!'); } }); -server.listen(common.PORT, function() { +server.listen(0, function() { + name = http.globalAgent.getName({ port: this.address().port }); for (var i = 0; i < max; ++i) { request(i); } @@ -26,7 +27,7 @@ server.listen(common.PORT, function() { function request(i) { var req = http.get({ - port: common.PORT, + port: server.address().port, path: '/' + i }, function(res) { var socket = req.socket; diff --git a/test/parallel/test-http-client-default-headers-exist.js b/test/parallel/test-http-client-default-headers-exist.js index 94106285beca97..ec96002399ecdb 100644 --- a/test/parallel/test-http-client-default-headers-exist.js +++ b/test/parallel/test-http-client-default-headers-exist.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -36,11 +36,11 @@ var server = http.createServer(function(req, res) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { expectedMethods.forEach(function(method) { http.request({ method: method, - port: common.PORT + port: server.address().port }).end(); }); }); diff --git a/test/parallel/test-http-client-encoding.js b/test/parallel/test-http-client-encoding.js index baaef855b1e6e0..b02463aa5188d5 100644 --- a/test/parallel/test-http-client-encoding.js +++ b/test/parallel/test-http-client-encoding.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); http.createServer(function(req, res) { res.end('ok\n'); this.close(); -}).listen(common.PORT, test); +}).listen(0, test); function test() { http.request({ - port: common.PORT, + port: this.address().port, encoding: 'utf8' }, function(res) { res.pipe(process.stdout); diff --git a/test/parallel/test-http-client-get-url.js b/test/parallel/test-http-client-get-url.js index 1dd23143e46c68..d425dff3008e26 100644 --- a/test/parallel/test-http-client-get-url.js +++ b/test/parallel/test-http-client-get-url.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -15,8 +15,8 @@ var server = http.createServer(function(req, res) { seen_req = true; }); -server.listen(common.PORT, function() { - http.get('http://127.0.0.1:' + common.PORT + '/foo?bar'); +server.listen(0, function() { + http.get(`http://127.0.0.1:${this.address().port}/foo?bar`); }); process.on('exit', function() { diff --git a/test/parallel/test-http-client-parse-error.js b/test/parallel/test-http-client-parse-error.js index 43f85853b3bbeb..cd6f135d889534 100644 --- a/test/parallel/test-http-client-parse-error.js +++ b/test/parallel/test-http-client-parse-error.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,11 +17,11 @@ net.createServer(function(c) { c.end('bad http - should trigger parse error\r\n'); this.close(); } -}).listen(common.PORT, '127.0.0.1', function() { +}).listen(0, '127.0.0.1', function() { for (var i = 0; i < 2; i++) { http.request({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, method: 'GET', path: '/' }).on('error', function(e) { diff --git a/test/parallel/test-http-client-race-2.js b/test/parallel/test-http-client-race-2.js index 0a98e06c7bf062..20b71f909a83b5 100644 --- a/test/parallel/test-http-client-race-2.js +++ b/test/parallel/test-http-client-race-2.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); @@ -27,14 +27,14 @@ var server = http.createServer(function(req, res) { {'Content-Type': 'text/plain', 'Content-Length': body.length}); res.end(body); }); -server.listen(common.PORT); +server.listen(0); var body1 = ''; var body2 = ''; var body3 = ''; server.on('listening', function() { - var client = http.createClient(common.PORT); + var client = http.createClient(this.address().port); // // Client #1 is assigned Parser #1 @@ -59,7 +59,7 @@ server.on('listening', function() { // parser that previously belonged to Client #1. But we're not finished // with Client #1 yet! // - var client2 = http.createClient(common.PORT); + var client2 = http.createClient(server.address().port); // // At this point, the bug would manifest itself and crash because the diff --git a/test/parallel/test-http-client-race.js b/test/parallel/test-http-client-race.js index 11dcb7ae4ca89e..30ebb34fc7fcff 100644 --- a/test/parallel/test-http-client-race.js +++ b/test/parallel/test-http-client-race.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); @@ -13,13 +13,13 @@ var server = http.createServer(function(req, res) { {'Content-Type': 'text/plain', 'Content-Length': body.length}); res.end(body); }); -server.listen(common.PORT); +server.listen(0); var body1 = ''; var body2 = ''; server.on('listening', function() { - var req1 = http.request({ port: common.PORT, path: '/1' }); + var req1 = http.request({ port: this.address().port, path: '/1' }); req1.end(); req1.on('response', function(res1) { res1.setEncoding('utf8'); @@ -29,7 +29,7 @@ server.on('listening', function() { }); res1.on('end', function() { - var req2 = http.request({ port: common.PORT, path: '/2' }); + var req2 = http.request({ port: server.address().port, path: '/2' }); req2.end(); req2.on('response', function(res2) { res2.setEncoding('utf8'); diff --git a/test/parallel/test-http-client-reject-chunked-with-content-length.js b/test/parallel/test-http-client-reject-chunked-with-content-length.js index 400a1d0ddbb991..324ba004d58a7d 100644 --- a/test/parallel/test-http-client-reject-chunked-with-content-length.js +++ b/test/parallel/test-http-client-reject-chunked-with-content-length.js @@ -13,11 +13,11 @@ const server = net.createServer((socket) => { socket.write(reqstr); }); -server.listen(common.PORT, () => { +server.listen(0, () => { // The callback should not be called because the server is sending // both a Content-Length header and a Transfer-Encoding: chunked // header, which is a violation of the HTTP spec. - const req = http.get({port: common.PORT}, (res) => { + const req = http.get({port: server.address().port}, (res) => { assert.fail(null, null, 'callback should not be called'); }); req.on('error', common.mustCall((err) => { diff --git a/test/parallel/test-http-client-reject-cr-no-lf.js b/test/parallel/test-http-client-reject-cr-no-lf.js index 350d7f40e95b9b..e396637aaa448d 100644 --- a/test/parallel/test-http-client-reject-cr-no-lf.js +++ b/test/parallel/test-http-client-reject-cr-no-lf.js @@ -13,10 +13,10 @@ const server = net.createServer((socket) => { socket.write(reqstr); }); -server.listen(common.PORT, () => { +server.listen(0, () => { // The callback should not be called because the server is sending a // header field that ends only in \r with no following \n - const req = http.get({port: common.PORT}, (res) => { + const req = http.get({port: server.address().port}, (res) => { assert.fail(null, null, 'callback should not be called'); }); req.on('error', common.mustCall((err) => { diff --git a/test/parallel/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js index a282eca784ea1d..c479f6ef1c718b 100644 --- a/test/parallel/test-http-client-timeout-agent.js +++ b/test/parallel/test-http-client-timeout-agent.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -7,7 +7,7 @@ var requests_sent = 0; var requests_done = 0; var options = { method: 'GET', - port: common.PORT, + port: undefined, host: '127.0.0.1', }; @@ -25,7 +25,8 @@ var server = http.createServer(function(req, res) { } }); -server.listen(options.port, options.host, function() { +server.listen(0, options.host, function() { + options.port = this.address().port; var req; for (requests_sent = 0; requests_sent < 30; requests_sent += 1) { diff --git a/test/parallel/test-http-client-timeout-event.js b/test/parallel/test-http-client-timeout-event.js index aaa32e5b24d14d..03aa847a80b45a 100644 --- a/test/parallel/test-http-client-timeout-event.js +++ b/test/parallel/test-http-client-timeout-event.js @@ -5,7 +5,7 @@ var http = require('http'); var options = { method: 'GET', - port: common.PORT, + port: undefined, host: '127.0.0.1', path: '/' }; @@ -14,7 +14,8 @@ var server = http.createServer(function(req, res) { // this space intentionally left blank }); -server.listen(options.port, options.host, function() { +server.listen(0, options.host, function() { + options.port = this.address().port; var req = http.request(options, function(res) { // this space intentionally left blank }); diff --git a/test/parallel/test-http-client-timeout-with-data.js b/test/parallel/test-http-client-timeout-with-data.js index 2fff91227d1984..f5b2a60dc52a54 100644 --- a/test/parallel/test-http-client-timeout-with-data.js +++ b/test/parallel/test-http-client-timeout-with-data.js @@ -13,7 +13,7 @@ process.on('exit', function() { const options = { method: 'GET', - port: common.PORT, + port: undefined, host: '127.0.0.1', path: '/' }; @@ -24,7 +24,8 @@ const server = http.createServer(function(req, res) { setTimeout(function() { res.end('*'); }, common.platformTimeout(100)); }); -server.listen(options.port, options.host, function() { +server.listen(0, options.host, function() { + options.port = this.address().port; const req = http.request(options, onresponse); req.end(); diff --git a/test/parallel/test-http-client-timeout.js b/test/parallel/test-http-client-timeout.js index 1b09254d39bedc..402736e9b7d47c 100644 --- a/test/parallel/test-http-client-timeout.js +++ b/test/parallel/test-http-client-timeout.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var options = { method: 'GET', - port: common.PORT, + port: undefined, host: '127.0.0.1', path: '/' }; @@ -14,7 +14,8 @@ var server = http.createServer(function(req, res) { // this space intentionally left blank }); -server.listen(options.port, options.host, function() { +server.listen(0, options.host, function() { + options.port = this.address().port; var req = http.request(options, function(res) { // this space intentionally left blank }); diff --git a/test/parallel/test-http-client-upload-buf.js b/test/parallel/test-http-client-upload-buf.js index 57d258671c298d..132af3aa8a28f2 100644 --- a/test/parallel/test-http-client-upload-buf.js +++ b/test/parallel/test-http-client-upload-buf.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -23,11 +23,11 @@ var server = http.createServer(function(req, res) { res.end(); }); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/' }, function(res) { diff --git a/test/parallel/test-http-client-upload.js b/test/parallel/test-http-client-upload.js index 80a3d2aa6d33c9..ad66329d5adf05 100644 --- a/test/parallel/test-http-client-upload.js +++ b/test/parallel/test-http-client-upload.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -24,11 +24,11 @@ var server = http.createServer(function(req, res) { res.end(); }); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/' }, function(res) { diff --git a/test/parallel/test-http-conn-reset.js b/test/parallel/test-http-conn-reset.js index 2f047a2de4009a..956b895b050d51 100644 --- a/test/parallel/test-http-conn-reset.js +++ b/test/parallel/test-http-conn-reset.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -8,7 +8,7 @@ var caughtError = false; var options = { host: '127.0.0.1', - port: common.PORT + port: undefined }; // start a tcp server that closes incoming connections immediately @@ -16,10 +16,11 @@ var server = net.createServer(function(client) { client.destroy(); server.close(); }); -server.listen(options.port, options.host, onListen); +server.listen(0, options.host, onListen); // do a GET request, expect it to fail function onListen() { + options.port = this.address().port; var req = http.request(options, function(res) { assert.ok(false, 'this should never run'); }); diff --git a/test/parallel/test-http-connect-req-res.js b/test/parallel/test-http-connect-req-res.js index bb5056fce49a24..c6b545b61e3b82 100644 --- a/test/parallel/test-http-connect-req-res.js +++ b/test/parallel/test-http-connect-req-res.js @@ -28,9 +28,9 @@ server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) { socket.end(data); }); })); -server.listen(common.PORT, common.mustCall(function() { +server.listen(0, common.mustCall(function() { const req = http.request({ - port: common.PORT, + port: this.address().port, method: 'CONNECT', path: 'example.com:443' }, function(res) { @@ -43,7 +43,7 @@ server.listen(common.PORT, common.mustCall(function() { console.error('Client got CONNECT request'); // Make sure this request got removed from the pool. - const name = 'localhost:' + common.PORT; + const name = 'localhost:' + server.address().port; assert(!http.globalAgent.sockets.hasOwnProperty(name)); assert(!http.globalAgent.requests.hasOwnProperty(name)); diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index 43c272d89352e0..b0efca64fa1cd9 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -25,9 +25,9 @@ server.on('connect', function(req, socket, firstBodyChunk) { socket.end(data); }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'CONNECT', path: 'google.com:443' }, function(res) { @@ -44,7 +44,7 @@ server.listen(common.PORT, function() { clientGotConnect = true; // Make sure this request got removed from the pool. - var name = 'localhost:' + common.PORT; + var name = 'localhost:' + server.address().port; assert(!http.globalAgent.sockets.hasOwnProperty(name)); assert(!http.globalAgent.requests.hasOwnProperty(name)); diff --git a/test/parallel/test-http-content-length.js b/test/parallel/test-http-content-length.js index ec60396a24545d..2c14862f9a684c 100644 --- a/test/parallel/test-http-content-length.js +++ b/test/parallel/test-http-content-length.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -46,11 +46,11 @@ var server = http.createServer(function(req, res) { if (totalRequests === receivedRequests) server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req; req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/multiple-writes' }); @@ -63,7 +63,7 @@ server.listen(common.PORT, function() { }); req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/end-with-data' }); @@ -75,7 +75,7 @@ server.listen(common.PORT, function() { }); req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/empty' }); diff --git a/test/parallel/test-http-contentLength0.js b/test/parallel/test-http-contentLength0.js index 9004649d1d2057..19e90e151382be 100644 --- a/test/parallel/test-http-contentLength0.js +++ b/test/parallel/test-http-contentLength0.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); // Simple test of Node's HTTP Client choking on a response @@ -11,9 +11,9 @@ var s = http.createServer(function(req, res) { res.writeHead(200, {'Content-Length': '0 '}); res.end(); }); -s.listen(common.PORT, function() { +s.listen(0, function() { - var request = http.request({ port: common.PORT }, function(response) { + var request = http.request({ port: this.address().port }, function(response) { console.log('STATUS: ' + response.statusCode); s.close(); response.resume(); diff --git a/test/parallel/test-http-createConnection.js b/test/parallel/test-http-createConnection.js index 48a7d7dbe68ea3..85b524ff37efe2 100644 --- a/test/parallel/test-http-createConnection.js +++ b/test/parallel/test-http-createConnection.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -14,7 +14,7 @@ process.on('exit', function() { var server = http.createServer(function(req, res) { res.end(); response++; -}).listen(common.PORT, '127.0.0.1', function() { +}).listen(0, '127.0.0.1', function() { http.get({ createConnection: createConnection }, function(res) { res.resume(); server.close(); @@ -23,5 +23,5 @@ var server = http.createServer(function(req, res) { function createConnection() { create++; - return net.createConnection(common.PORT, '127.0.0.1'); + return net.createConnection(server.address().port, '127.0.0.1'); } diff --git a/test/parallel/test-http-date-header.js b/test/parallel/test-http-date-header.js index 5ed7fc620bc475..e0b93c1f8718f5 100644 --- a/test/parallel/test-http-date-header.js +++ b/test/parallel/test-http-date-header.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -13,12 +13,12 @@ var server = http.createServer(function(req, res) { }); res.end(testResBody); }); -server.listen(common.PORT); +server.listen(0); server.addListener('listening', function() { var options = { - port: common.PORT, + port: this.address().port, path: '/', method: 'GET' }; diff --git a/test/parallel/test-http-default-encoding.js b/test/parallel/test-http-default-encoding.js index 612a75bce46647..4fb386bf4bb0e8 100644 --- a/test/parallel/test-http-default-encoding.js +++ b/test/parallel/test-http-default-encoding.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -18,9 +18,9 @@ var server = http.Server(function(req, res) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { http.request({ - port: common.PORT, + port: this.address().port, path: '/', method: 'POST' }, function(res) { diff --git a/test/parallel/test-http-default-port.js b/test/parallel/test-http-default-port.js index c0a1ed50e34d1b..6fd5fb24bb1f07 100644 --- a/test/parallel/test-http-default-port.js +++ b/test/parallel/test-http-default-port.js @@ -1,8 +1,6 @@ 'use strict'; const common = require('../common'); const http = require('http'); -const PORT = common.PORT; -const SSLPORT = common.PORT + 1; const assert = require('assert'); const hostExpect = 'localhost'; const fs = require('fs'); @@ -29,18 +27,18 @@ process.on('exit', function() { console.log('ok'); }); -http.globalAgent.defaultPort = PORT; http.createServer(function(req, res) { assert.equal(req.headers.host, hostExpect); - assert.equal(req.headers['x-port'], PORT); + assert.equal(req.headers['x-port'], this.address().port); res.writeHead(200); res.end('ok'); this.close(); -}).listen(PORT, function() { +}).listen(0, function() { + http.globalAgent.defaultPort = this.address().port; http.get({ host: 'localhost', headers: { - 'x-port': PORT + 'x-port': this.address().port } }, function(res) { gotHttpResp = true; @@ -49,19 +47,19 @@ http.createServer(function(req, res) { }); if (common.hasCrypto) { - https.globalAgent.defaultPort = SSLPORT; https.createServer(options, function(req, res) { assert.equal(req.headers.host, hostExpect); - assert.equal(req.headers['x-port'], SSLPORT); + assert.equal(req.headers['x-port'], this.address().port); res.writeHead(200); res.end('ok'); this.close(); - }).listen(SSLPORT, function() { + }).listen(0, function() { + https.globalAgent.defaultPort = this.address().port; https.get({ host: 'localhost', rejectUnauthorized: false, headers: { - 'x-port': SSLPORT + 'x-port': this.address().port } }, function(res) { gotHttpsResp = true; diff --git a/test/parallel/test-http-destroyed-socket-write2.js b/test/parallel/test-http-destroyed-socket-write2.js index 7588393840f2cc..7d2f235a27f7fb 100644 --- a/test/parallel/test-http-destroyed-socket-write2.js +++ b/test/parallel/test-http-destroyed-socket-write2.js @@ -12,9 +12,9 @@ var server = http.createServer(function(req, res) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, path: '/', method: 'POST' }); diff --git a/test/parallel/test-http-double-content-length.js b/test/parallel/test-http-double-content-length.js index c35f18321c3d86..ac70168601aaf5 100644 --- a/test/parallel/test-http-double-content-length.js +++ b/test/parallel/test-http-double-content-length.js @@ -17,9 +17,9 @@ server.on('clientError', common.mustCall((err, socket) => { socket.destroy(); })); -server.listen(common.PORT, () => { +server.listen(0, () => { const req = http.get({ - port: common.PORT, + port: server.address().port, // Send two content-length header values. headers: {'Content-Length': [1, 2]}}, (res) => { diff --git a/test/parallel/test-http-end-throw-socket-handling.js b/test/parallel/test-http-end-throw-socket-handling.js index d6cc81d98a8fb9..bab5135555364b 100644 --- a/test/parallel/test-http-end-throw-socket-handling.js +++ b/test/parallel/test-http-end-throw-socket-handling.js @@ -16,9 +16,9 @@ const server = http.createServer((req, res) => { res.end('ok'); }); -server.listen(common.PORT, common.mustCall(() => { +server.listen(0, common.mustCall(() => { for (let i = 0; i < 10; i++) { - const options = { port: common.PORT }; + const options = { port: server.address().port }; const req = http.request(options, (res) => { res.resume(); res.on('end', common.mustCall(() => { diff --git a/test/parallel/test-http-eof-on-connect.js b/test/parallel/test-http-eof-on-connect.js index fc7dd1d9fe88ce..6f70dc239172ee 100644 --- a/test/parallel/test-http-eof-on-connect.js +++ b/test/parallel/test-http-eof-on-connect.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var net = require('net'); var http = require('http'); @@ -8,10 +8,10 @@ var http = require('http'); // reproduceable on the first packet on the first connection to a server. var server = http.createServer(function(req, res) {}); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { - net.createConnection(common.PORT).on('connect', function() { + net.createConnection(this.address().port).on('connect', function() { this.destroy(); }).on('close', function() { server.close(); diff --git a/test/parallel/test-http-exceptions.js b/test/parallel/test-http-exceptions.js index b01d31e030b627..e82485c0b30996 100644 --- a/test/parallel/test-http-exceptions.js +++ b/test/parallel/test-http-exceptions.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var server = http.createServer(function(req, res) { @@ -9,9 +9,9 @@ var server = http.createServer(function(req, res) { res.end(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { for (var i = 0; i < 4; i += 1) { - http.get({ port: common.PORT, path: '/busy/' + i }); + http.get({ port: this.address().port, path: '/busy/' + i }); } }); diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js index 247346a9ec81a4..a98cfcc07d05af 100644 --- a/test/parallel/test-http-expect-continue.js +++ b/test/parallel/test-http-expect-continue.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -28,12 +28,12 @@ server.on('checkContinue', function(req, res) { handler(req, res); }, 100); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'POST', path: '/world', headers: { 'Expect': '100-continue' } diff --git a/test/parallel/test-http-extra-response.js b/test/parallel/test-http-extra-response.js index fc398b9175402b..37bad7013e97b1 100644 --- a/test/parallel/test-http-extra-response.js +++ b/test/parallel/test-http-extra-response.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -44,8 +44,8 @@ var server = net.createServer(function(socket) { }); -server.listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +server.listen(0, function() { + http.get({ port: this.address().port }, function(res) { var buffer = ''; console.log('Got res code: ' + res.statusCode); diff --git a/test/parallel/test-http-flush-headers.js b/test/parallel/test-http-flush-headers.js index 5e91a4643a9019..c2b382188a14c1 100644 --- a/test/parallel/test-http-flush-headers.js +++ b/test/parallel/test-http-flush-headers.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const http = require('http'); @@ -9,11 +9,11 @@ server.on('request', function(req, res) { res.end('ok'); server.close(); }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { const req = http.request({ method: 'GET', host: '127.0.0.1', - port: common.PORT, + port: this.address().port, }); req.setHeader('foo', 'bar'); req.flushHeaders(); diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js index 76e739741cb2db..1cd8402df361b0 100644 --- a/test/parallel/test-http-flush-response-headers.js +++ b/test/parallel/test-http-flush-response-headers.js @@ -10,11 +10,11 @@ server.on('request', function(req, res) { res.flushHeaders(); res.flushHeaders(); // Should be idempotent. }); -server.listen(common.PORT, common.localhostIPv4, function() { +server.listen(0, common.localhostIPv4, function() { var req = http.request({ method: 'GET', host: common.localhostIPv4, - port: common.PORT, + port: this.address().port, }, onResponse); req.end(); diff --git a/test/parallel/test-http-flush.js b/test/parallel/test-http-flush.js index 8dc7ba7418dc88..8b3dacb803d9bd 100644 --- a/test/parallel/test-http-flush.js +++ b/test/parallel/test-http-flush.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); http.createServer(function(req, res) { res.end('ok'); this.close(); -}).listen(common.PORT, '127.0.0.1', function() { +}).listen(0, '127.0.0.1', function() { var req = http.request({ method: 'POST', host: '127.0.0.1', - port: common.PORT, + port: this.address().port, }); req.flush(); // Flush the request headers. req.flush(); // Should be idempotent. diff --git a/test/parallel/test-http-full-response.js b/test/parallel/test-http-full-response.js index 331f2171d828b4..dad7ca8fb43caa 100644 --- a/test/parallel/test-http-full-response.js +++ b/test/parallel/test-http-full-response.js @@ -20,7 +20,7 @@ var server = http.createServer(function(req, res) { var runs = 0; function runAb(opts, callback) { - var command = 'ab ' + opts + ' http://127.0.0.1:' + common.PORT + '/'; + var command = `ab ${opts} http://127.0.0.1:${server.address().port}/`; exec(command, function(err, stdout, stderr) { if (err) { if (/ab|apr/mi.test(stderr)) { @@ -49,7 +49,7 @@ function runAb(opts, callback) { }); } -server.listen(common.PORT, function() { +server.listen(0, function() { runAb('-c 1 -n 10', function() { console.log('-c 1 -n 10 okay'); diff --git a/test/parallel/test-http-get-pipeline-problem.js b/test/parallel/test-http-get-pipeline-problem.js index de339e5b91a322..9f2287e2990b3f 100644 --- a/test/parallel/test-http-get-pipeline-problem.js +++ b/test/parallel/test-http-get-pipeline-problem.js @@ -34,13 +34,13 @@ var server = http.Server(function(req, res) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { for (var i = 0; i < total; i++) { (function() { var x = i; var opts = { - port: common.PORT, + port: server.address().port, headers: { connection: 'close' } }; diff --git a/test/parallel/test-http-head-request.js b/test/parallel/test-http-head-request.js index faf2168e36d0be..68aaace7c3e15e 100644 --- a/test/parallel/test-http-head-request.js +++ b/test/parallel/test-http-head-request.js @@ -1,15 +1,11 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); - var body = 'hello world\n'; -var id = 0; function test(headers) { - var port = common.PORT + id++; - var server = http.createServer(function(req, res) { console.error('req: %s headers: %j', req.method, headers); res.writeHead(200, headers); @@ -19,9 +15,9 @@ function test(headers) { var gotEnd = false; - server.listen(port, function() { + server.listen(0, function() { var request = http.request({ - port: port, + port: this.address().port, method: 'HEAD', path: '/' }, function(response) { diff --git a/test/parallel/test-http-head-response-has-no-body-end.js b/test/parallel/test-http-head-response-has-no-body-end.js index 647b7c08936a97..2f7a2105a1c75c 100644 --- a/test/parallel/test-http-head-response-has-no-body-end.js +++ b/test/parallel/test-http-head-response-has-no-body-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -12,13 +12,13 @@ var server = http.createServer(function(req, res) { res.writeHead(200); res.end('FAIL'); // broken: sends FAIL from hot path. }); -server.listen(common.PORT); +server.listen(0); var responseComplete = false; server.on('listening', function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'HEAD', path: '/' }, function(res) { diff --git a/test/parallel/test-http-head-response-has-no-body.js b/test/parallel/test-http-head-response-has-no-body.js index a5293e174a2b2d..a36dec7cf2b1ce 100644 --- a/test/parallel/test-http-head-response-has-no-body.js +++ b/test/parallel/test-http-head-response-has-no-body.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -12,13 +12,13 @@ var server = http.createServer(function(req, res) { res.writeHead(200); // broken: defaults to TE chunked res.end(); }); -server.listen(common.PORT); +server.listen(0); var responseComplete = false; server.on('listening', function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'HEAD', path: '/' }, function(res) { diff --git a/test/parallel/test-http-header-obstext.js b/test/parallel/test-http-header-obstext.js index ba28768be320e6..b3422cf0ced181 100644 --- a/test/parallel/test-http-header-obstext.js +++ b/test/parallel/test-http-header-obstext.js @@ -7,9 +7,9 @@ const assert = require('assert'); const server = http.createServer(common.mustCall((req, res) => { res.end('ok'); })); -server.listen(common.PORT, () => { +server.listen(0, () => { http.get({ - port: common.PORT, + port: server.address().port, headers: {'Test': 'Düsseldorf'} }, common.mustCall((res) => { assert.equal(res.statusCode, 200); diff --git a/test/parallel/test-http-header-read.js b/test/parallel/test-http-header-read.js index 6266f8b11ffd2c..b726fe130f0ee4 100644 --- a/test/parallel/test-http-header-read.js +++ b/test/parallel/test-http-header-read.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -23,10 +23,10 @@ var s = http.createServer(function(req, res) { ); }); -s.listen(common.PORT, runTest); +s.listen(0, runTest); function runTest() { - http.get({ port: common.PORT }, function(response) { + http.get({ port: this.address().port }, function(response) { response.on('end', function() { s.close(); }); diff --git a/test/parallel/test-http-header-response-splitting.js b/test/parallel/test-http-header-response-splitting.js index 5483ea3a5bf899..21776d001c5e7c 100644 --- a/test/parallel/test-http-header-response-splitting.js +++ b/test/parallel/test-http-header-response-splitting.js @@ -65,9 +65,10 @@ var server = http.createServer(function(req, res) { } }); -server.listen(common.PORT, common.mustCall(function() { +server.listen(0, common.mustCall(function() { + const port = this.address().port; for (var i = 0; i < testCount; i++) { - http.get({ port: common.PORT, path: '/' }, common.mustCall(function(res) { + http.get({ port: port, path: '/' }, common.mustCall(function(res) { assert.strictEqual(res.headers.a, 'foo invalid: bar'); assert.strictEqual(res.headers.b, 'foo invalid: bar'); assert.strictEqual(res.headers.foo, undefined); diff --git a/test/parallel/test-http-hex-write.js b/test/parallel/test-http-hex-write.js index 371bbe7a43cb75..5b5729712d8575 100644 --- a/test/parallel/test-http-hex-write.js +++ b/test/parallel/test-http-hex-write.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -20,8 +20,8 @@ http.createServer(function(q, s) { s.write('utf8\n'); s.end(); this.close(); -}).listen(common.PORT, function() { - http.request({ port: common.PORT }).on('response', function(res) { +}).listen(0, function() { + http.request({ port: this.address().port }).on('response', function(res) { res.setEncoding('ascii'); res.on('data', function(c) { data += c; diff --git a/test/parallel/test-http-host-header-ipv6-fail.js b/test/parallel/test-http-host-header-ipv6-fail.js index 8a1a9a61afe5af..5f81234edba352 100644 --- a/test/parallel/test-http-host-header-ipv6-fail.js +++ b/test/parallel/test-http-host-header-ipv6-fail.js @@ -14,12 +14,11 @@ const assert = require('assert'); const http = require('http'); const hostname = '::1'; -const port = common.PORT; function httpreq() { var req = http.request({ host: hostname, - port: port, + port: server.address().port, path: '/', method: 'GET' }); @@ -37,4 +36,4 @@ const server = http.createServer(common.mustCall(function(req, res) { server.close(true); })); -server.listen(port, hostname, () => httpreq()); +server.listen(0, hostname, () => httpreq()); diff --git a/test/parallel/test-http-host-headers.js b/test/parallel/test-http-host-headers.js index f121216801c045..a9f12d6819314e 100644 --- a/test/parallel/test-http-host-headers.js +++ b/test/parallel/test-http-host-headers.js @@ -1,6 +1,6 @@ 'use strict'; +require('../common'); const http = require('http'); -const common = require('../common'); const assert = require('assert'); const httpServer = http.createServer(reqHandler); @@ -9,7 +9,7 @@ function reqHandler(req, res) { if (req.url === '/setHostFalse5') { assert.equal(req.headers.host, undefined); } else { - assert.equal(req.headers.host, 'localhost:' + common.PORT, + assert.equal(req.headers.host, `localhost:${this.address().port}`, 'Wrong host header for req[' + req.url + ']: ' + req.headers.host); } @@ -26,8 +26,6 @@ testHttp(); function testHttp() { - console.log('testing http on port ' + common.PORT); - var counter = 0; function cb(res) { @@ -39,8 +37,8 @@ function testHttp() { res.resume(); } - httpServer.listen(common.PORT, function(er) { - console.error('listening on ' + common.PORT); + httpServer.listen(0, function(er) { + console.error(`test http server listening on ${this.address().port}`); if (er) throw er; @@ -49,7 +47,7 @@ function testHttp() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower); @@ -58,7 +56,7 @@ function testHttp() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -67,7 +65,7 @@ function testHttp() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -76,7 +74,7 @@ function testHttp() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -85,7 +83,7 @@ function testHttp() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); }); diff --git a/test/parallel/test-http-incoming-pipelined-socket-destroy.js b/test/parallel/test-http-incoming-pipelined-socket-destroy.js index 1e5a910424d737..0cb29610f1b6d2 100644 --- a/test/parallel/test-http-incoming-pipelined-socket-destroy.js +++ b/test/parallel/test-http-incoming-pipelined-socket-destroy.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var net = require('net'); @@ -40,16 +40,16 @@ var server = http.createServer(function(req, res) { function generator(seeds) { return seeds.map(function(r) { return 'GET /' + r + ' HTTP/1.1\r\n' + - 'Host: localhost:' + common.PORT + '\r\n' + + `Host: localhost:${server.address().port}\r\n` + '\r\n' + '\r\n'; }).join(''); } -server.listen(common.PORT, function() { +server.listen(0, function() { var seeds = [ 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 ]; - var client = net.connect({ port: common.PORT }); + var client = net.connect({ port: this.address().port }); var done = 0; server.on('requestDone', function() { if (++done == seeds.length) { diff --git a/test/parallel/test-http-keep-alive-close-on-header.js b/test/parallel/test-http-keep-alive-close-on-header.js index 83a0d0684cf637..d9396b258e7515 100644 --- a/test/parallel/test-http-keep-alive-close-on-header.js +++ b/test/parallel/test-http-keep-alive-close-on-header.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -15,14 +15,14 @@ var server = http.createServer(function(req, res) { var connectCount = 0; -server.listen(common.PORT, function() { +server.listen(0, function() { var agent = new http.Agent({ maxSockets: 1 }); - var name = agent.getName({ port: common.PORT }); + var name = agent.getName({ port: this.address().port }); var request = http.request({ method: 'GET', path: '/', headers: headers, - port: common.PORT, + port: this.address().port, agent: agent }, function(res) { assert.equal(1, agent.sockets[name].length); @@ -39,7 +39,7 @@ server.listen(common.PORT, function() { method: 'GET', path: '/', headers: headers, - port: common.PORT, + port: this.address().port, agent: agent }, function(res) { assert.equal(1, agent.sockets[name].length); @@ -55,7 +55,7 @@ server.listen(common.PORT, function() { method: 'GET', path: '/', headers: headers, - port: common.PORT, + port: this.address().port, agent: agent }, function(response) { response.on('end', function() { diff --git a/test/parallel/test-http-keep-alive.js b/test/parallel/test-http-keep-alive.js index 0d30bbe1da3069..d48732e1161886 100644 --- a/test/parallel/test-http-keep-alive.js +++ b/test/parallel/test-http-keep-alive.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -13,11 +13,12 @@ var server = http.createServer(function(req, res) { var agent = new http.Agent({maxSockets: 1}); var headers = {'connection': 'keep-alive'}; -var name = agent.getName({ port: common.PORT }); +var name; -server.listen(common.PORT, function() { +server.listen(0, function() { + name = agent.getName({ port: this.address().port }); http.get({ - path: '/', headers: headers, port: common.PORT, agent: agent + path: '/', headers: headers, port: this.address().port, agent: agent }, function(response) { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.requests[name].length, 2); @@ -25,7 +26,7 @@ server.listen(common.PORT, function() { }); http.get({ - path: '/', headers: headers, port: common.PORT, agent: agent + path: '/', headers: headers, port: this.address().port, agent: agent }, function(response) { assert.equal(agent.sockets[name].length, 1); assert.equal(agent.requests[name].length, 1); @@ -33,7 +34,7 @@ server.listen(common.PORT, function() { }); http.get({ - path: '/', headers: headers, port: common.PORT, agent: agent + path: '/', headers: headers, port: this.address().port, agent: agent }, function(response) { response.on('end', function() { assert.equal(agent.sockets[name].length, 1); diff --git a/test/parallel/test-http-keepalive-client.js b/test/parallel/test-http-keepalive-client.js index c573ac82d6f884..955fc006e22d58 100644 --- a/test/parallel/test-http-keepalive-client.js +++ b/test/parallel/test-http-keepalive-client.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -16,7 +16,9 @@ var server = http.createServer(function(req, res) { res.end(req.url); }); -server.listen(common.PORT); +server.listen(0, function() { + makeRequest(expectRequests); +}); var agent = http.Agent({ keepAlive: true }); @@ -26,7 +28,6 @@ var expectRequests = 10; var actualRequests = 0; -makeRequest(expectRequests); function makeRequest(n) { if (n === 0) { server.close(); @@ -35,7 +36,7 @@ function makeRequest(n) { } var req = http.request({ - port: common.PORT, + port: server.address().port, agent: agent, path: '/' + n }); diff --git a/test/parallel/test-http-keepalive-maxsockets.js b/test/parallel/test-http-keepalive-maxsockets.js index a5382b6e328485..6f1476d0ce3aed 100644 --- a/test/parallel/test-http-keepalive-maxsockets.js +++ b/test/parallel/test-http-keepalive-maxsockets.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -12,75 +12,75 @@ var server = http.createServer(function(req, res) { } res.end(req.url); }); -server.listen(common.PORT); - -var agent = http.Agent({ - keepAlive: true, - maxSockets: 5, - maxFreeSockets: 2 -}); - -// make 10 requests in parallel, -// then 10 more when they all finish. -function makeReqs(n, cb) { - for (var i = 0; i < n; i++) - makeReq(i, then); - - function then(er) { - if (er) - return cb(er); - else if (--n === 0) - setTimeout(cb, 100); - } -} - -function makeReq(i, cb) { - http.request({ - port: common.PORT, - path: '/' + i, - agent: agent - }, function(res) { - var data = ''; - res.setEncoding('ascii'); - res.on('data', function(c) { - data += c; - }); - res.on('end', function() { - assert.equal(data, '/' + i); - cb(); - }); - }).end(); -} - -var closed = false; -makeReqs(10, function(er) { - assert.ifError(er); - assert.equal(count(agent.freeSockets), 2); - assert.equal(count(agent.sockets), 0); - assert.equal(serverSockets.length, 5); +server.listen(0, function() { + var agent = http.Agent({ + keepAlive: true, + maxSockets: 5, + maxFreeSockets: 2 + }); - // now make 10 more reqs. - // should use the 2 free reqs from the pool first. + var closed = false; makeReqs(10, function(er) { assert.ifError(er); assert.equal(count(agent.freeSockets), 2); assert.equal(count(agent.sockets), 0); - assert.equal(serverSockets.length, 8); + assert.equal(serverSockets.length, 5); - agent.destroy(); - server.close(function() { - closed = true; + // now make 10 more reqs. + // should use the 2 free reqs from the pool first. + makeReqs(10, function(er) { + assert.ifError(er); + assert.equal(count(agent.freeSockets), 2); + assert.equal(count(agent.sockets), 0); + assert.equal(serverSockets.length, 8); + + agent.destroy(); + server.close(function() { + closed = true; + }); }); }); -}); -function count(sockets) { - return Object.keys(sockets).reduce(function(n, name) { - return n + sockets[name].length; - }, 0); -} + process.on('exit', function() { + assert(closed); + console.log('ok'); + }); -process.on('exit', function() { - assert(closed); - console.log('ok'); + // make 10 requests in parallel, + // then 10 more when they all finish. + function makeReqs(n, cb) { + for (var i = 0; i < n; i++) + makeReq(i, then); + + function then(er) { + if (er) + return cb(er); + else if (--n === 0) + setTimeout(cb, 100); + } + } + + function makeReq(i, cb) { + http.request({ + port: server.address().port, + path: '/' + i, + agent: agent + }, function(res) { + var data = ''; + res.setEncoding('ascii'); + res.on('data', function(c) { + data += c; + }); + res.on('end', function() { + assert.equal(data, '/' + i); + cb(); + }); + }).end(); + } + + function count(sockets) { + return Object.keys(sockets).reduce(function(n, name) { + return n + sockets[name].length; + }, 0); + } }); diff --git a/test/parallel/test-http-keepalive-request.js b/test/parallel/test-http-keepalive-request.js index 8736c9cd4f88ce..daae5aa9944294 100644 --- a/test/parallel/test-http-keepalive-request.js +++ b/test/parallel/test-http-keepalive-request.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -16,7 +16,9 @@ var server = http.createServer(function(req, res) { res.end(req.url); }); -server.listen(common.PORT); +server.listen(0, function() { + makeRequest(expectRequests); +}); var agent = http.Agent({ keepAlive: true }); @@ -26,7 +28,6 @@ var expectRequests = 10; var actualRequests = 0; -makeRequest(expectRequests); function makeRequest(n) { if (n === 0) { server.close(); @@ -35,7 +36,7 @@ function makeRequest(n) { } var req = http.request({ - port: common.PORT, + port: server.address().port, path: '/' + n, agent: agent }); diff --git a/test/parallel/test-http-legacy.js b/test/parallel/test-http-legacy.js index 4004749d6276ec..363c3a92362e6a 100644 --- a/test/parallel/test-http-legacy.js +++ b/test/parallel/test-http-legacy.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); @@ -37,8 +37,8 @@ var server = http.createServer(function(req, res) { req.resume(); }); -server.listen(common.PORT, function() { - var client = http.createClient(common.PORT); +server.listen(0, function() { + var client = http.createClient(this.address().port); var req = client.request('/hello', {'Accept': '*/*', 'Foo': 'bar'}); setTimeout(function() { req.end(); diff --git a/test/parallel/test-http-localaddress-bind-error.js b/test/parallel/test-http-localaddress-bind-error.js index adaeba2b9459ea..51605fab6aa10e 100644 --- a/test/parallel/test-http-localaddress-bind-error.js +++ b/test/parallel/test-http-localaddress-bind-error.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -16,10 +16,10 @@ var server = http.createServer(function(req, res) { req.resume(); }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { http.request({ host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', localAddress: invalidLocalAddress diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 9bf213a880444b..fd38f8a901fe81 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -19,9 +19,9 @@ var server = http.createServer(function(req, res) { req.resume(); }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var options = { host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', localAddress: '127.0.0.2' }; diff --git a/test/parallel/test-http-malformed-request.js b/test/parallel/test-http-malformed-request.js index c83aeca9b943fa..fe6c01b79ddd66 100644 --- a/test/parallel/test-http-malformed-request.js +++ b/test/parallel/test-http-malformed-request.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var http = require('http'); @@ -20,10 +20,10 @@ var server = http.createServer(function(req, res) { if (++nrequests_completed == nrequests_expected) server.close(); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { - var c = net.createConnection(common.PORT); + var c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n'); c.end(); diff --git a/test/parallel/test-http-many-ended-pipelines.js b/test/parallel/test-http-many-ended-pipelines.js index c415af64f9dcd6..7966f47a9efa19 100644 --- a/test/parallel/test-http-many-ended-pipelines.js +++ b/test/parallel/test-http-many-ended-pipelines.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); // no warnings should happen! var trace = console.trace; @@ -27,13 +27,13 @@ var server = http.createServer(function(req, res) { req.socket.destroy(); }); -server.listen(common.PORT); - -var client = net.connect({ port: common.PORT, allowHalfOpen: true }); -for (var i = 0; i < numRequests; i++) { - client.write('GET / HTTP/1.1\r\n' + - 'Host: some.host.name\r\n' + - '\r\n\r\n'); -} -client.end(); -client.pipe(process.stdout); +server.listen(0, function() { + var client = net.connect({ port: this.address().port, allowHalfOpen: true }); + for (var i = 0; i < numRequests; i++) { + client.write('GET / HTTP/1.1\r\n' + + 'Host: some.host.name\r\n' + + '\r\n\r\n'); + } + client.end(); + client.pipe(process.stdout); +}); diff --git a/test/parallel/test-http-max-headers-count.js b/test/parallel/test-http-max-headers-count.js index 18b160d0b6d8ed..2d68ead110fc6c 100644 --- a/test/parallel/test-http-max-headers-count.js +++ b/test/parallel/test-http-max-headers-count.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -32,7 +32,7 @@ var server = http.createServer(function(req, res) { }); server.maxHeadersCount = max; -server.listen(common.PORT, function() { +server.listen(0, function() { var maxAndExpected = [ // for client [20, 20], [1200, 1200], @@ -44,7 +44,7 @@ server.listen(common.PORT, function() { var max = maxAndExpected[responses][0]; var expected = maxAndExpected[responses][1]; var req = http.request({ - port: common.PORT, + port: server.address().port, headers: headers }, function(res) { assert.equal(Object.keys(res.headers).length, expected); diff --git a/test/parallel/test-http-multi-line-headers.js b/test/parallel/test-http-multi-line-headers.js index 0c36b7cbf3cac9..3a1f5f268948e9 100644 --- a/test/parallel/test-http-multi-line-headers.js +++ b/test/parallel/test-http-multi-line-headers.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -24,8 +24,8 @@ var server = net.createServer(function(conn) { server.close(); }); -server.listen(common.PORT, function() { - http.get({host: '127.0.0.1', port: common.PORT}, function(res) { +server.listen(0, function() { + http.get({host: '127.0.0.1', port: this.address().port}, function(res) { assert.equal(res.headers['content-type'], 'text/plain; x-unix-mode=0600; name="hello.txt"'); gotResponse = true; diff --git a/test/parallel/test-http-mutable-headers.js b/test/parallel/test-http-mutable-headers.js index af8fd6d7e8f938..3aba8be49cc586 100644 --- a/test/parallel/test-http-mutable-headers.js +++ b/test/parallel/test-http-mutable-headers.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -61,7 +61,7 @@ var s = http.createServer(function(req, res) { res.end(content); }); -s.listen(common.PORT, nextTest); +s.listen(0, nextTest); function nextTest() { @@ -71,7 +71,7 @@ function nextTest() { var bufferedResponse = ''; - http.get({ port: common.PORT }, function(response) { + http.get({ port: s.address().port }, function(response) { console.log('TEST: ' + test); console.log('STATUS: ' + response.statusCode); console.log('HEADERS: '); diff --git a/test/parallel/test-http-no-content-length.js b/test/parallel/test-http-no-content-length.js index 7a205dc07df3ca..dcdf00c402d1e1 100644 --- a/test/parallel/test-http-no-content-length.js +++ b/test/parallel/test-http-no-content-length.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var http = require('http'); @@ -9,8 +9,8 @@ var body = ''; var server = net.createServer(function(socket) { // Neither Content-Length nor Connection socket.end('HTTP/1.1 200 ok\r\n\r\nHello'); -}).listen(common.PORT, function() { - http.get({port: common.PORT}, function(res) { +}).listen(0, function() { + http.get({port: this.address().port}, function(res) { res.setEncoding('utf8'); res.on('data', function(chunk) { body += chunk; diff --git a/test/parallel/test-http-outgoing-finish.js b/test/parallel/test-http-outgoing-finish.js index 2140759139c8ed..1af4ca40e3beb9 100644 --- a/test/parallel/test-http-outgoing-finish.js +++ b/test/parallel/test-http-outgoing-finish.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -10,9 +10,9 @@ http.createServer(function(req, res) { write(res); }); this.close(); -}).listen(common.PORT, function() { +}).listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'PUT' }); write(req); diff --git a/test/parallel/test-http-parser-free.js b/test/parallel/test-http-parser-free.js index af94d0c89c8f52..125374bbedde63 100644 --- a/test/parallel/test-http-parser-free.js +++ b/test/parallel/test-http-parser-free.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var N = 100; @@ -9,12 +9,12 @@ var server = http.createServer(function(req, res) { res.end('Hello'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { http.globalAgent.maxSockets = 1; var parser; for (var i = 0; i < N; ++i) { (function makeRequest(i) { - var req = http.get({port: common.PORT}, function(res) { + var req = http.get({port: server.address().port}, function(res) { if (!parser) { parser = req.parser; } else { diff --git a/test/parallel/test-http-pause-resume-one-end.js b/test/parallel/test-http-pause-resume-one-end.js index 2a10aeb3beb9e6..76969775e604cc 100644 --- a/test/parallel/test-http-pause-resume-one-end.js +++ b/test/parallel/test-http-pause-resume-one-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -12,9 +12,9 @@ var server = http.Server(function(req, res) { var dataCount = 0, endCount = 0; -server.listen(common.PORT, function() { +server.listen(0, function() { var opts = { - port: common.PORT, + port: this.address().port, headers: { connection: 'close' } }; diff --git a/test/parallel/test-http-pause.js b/test/parallel/test-http-pause.js index 2d317d8ea7d988..f6562b3afc94ae 100644 --- a/test/parallel/test-http-pause.js +++ b/test/parallel/test-http-pause.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -26,9 +26,9 @@ var server = http.createServer(function(req, res) { }, 100); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, path: '/', method: 'POST' }, function(res) { diff --git a/test/parallel/test-http-pipe-fs.js b/test/parallel/test-http-pipe-fs.js index d180da3fbf6e64..89dfbb9c551e3a 100644 --- a/test/parallel/test-http-pipe-fs.js +++ b/test/parallel/test-http-pipe-fs.js @@ -18,13 +18,13 @@ var server = http.createServer(function(req, res) { res.writeHead(200); res.end(); }); -}).listen(common.PORT, function() { +}).listen(0, function() { http.globalAgent.maxSockets = 1; for (var i = 0; i < 2; ++i) { (function(i) { var req = http.request({ - port: common.PORT, + port: server.address().port, method: 'POST', headers: { 'Content-Length': 5 diff --git a/test/parallel/test-http-pipeline-flood.js b/test/parallel/test-http-pipeline-flood.js index 382c5d35880130..8a7e9acea90137 100644 --- a/test/parallel/test-http-pipeline-flood.js +++ b/test/parallel/test-http-pipeline-flood.js @@ -52,9 +52,9 @@ function parent() { connections++; }); - server.listen(common.PORT, function() { + server.listen(0, function() { const spawn = require('child_process').spawn; - const args = [__filename, 'child']; + const args = [__filename, 'child', this.address().port]; const child = spawn(process.execPath, args, { stdio: 'inherit' }); child.on('close', common.mustCall(function() { server.close(); @@ -73,10 +73,10 @@ function parent() { function child() { const net = require('net'); - const conn = net.connect({ port: common.PORT }); + const port = +process.argv[3]; + const conn = net.connect({ port: port }); - var req = 'GET / HTTP/1.1\r\nHost: localhost:' + - common.PORT + '\r\nAccept: */*\r\n\r\n'; + var req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`; req = new Array(10241).join(req); diff --git a/test/parallel/test-http-pipeline-regr-2639.js b/test/parallel/test-http-pipeline-regr-2639.js index c7cebb9d46a19f..f67803ba159c74 100644 --- a/test/parallel/test-http-pipeline-regr-2639.js +++ b/test/parallel/test-http-pipeline-regr-2639.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const http = require('http'); const net = require('net'); @@ -19,8 +19,8 @@ var server = http.createServer(function(req, res) { setTimeout(function() { res.end(); }, (Math.random() * 100) | 0); -}).listen(common.PORT, function() { - const s = net.connect(common.PORT); +}).listen(0, function() { + const s = net.connect(this.address().port); var big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); diff --git a/test/parallel/test-http-pipeline-regr-3332.js b/test/parallel/test-http-pipeline-regr-3332.js index 061e202d975f32..828da8ca5d4103 100644 --- a/test/parallel/test-http-pipeline-regr-3332.js +++ b/test/parallel/test-http-pipeline-regr-3332.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const http = require('http'); const net = require('net'); @@ -19,9 +19,9 @@ const server = http.createServer(function(req, res) { client.end(); } }); -}).listen(common.PORT, function() { +}).listen(0, function() { var req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n'); - client = net.connect(common.PORT, function() { + client = net.connect(this.address().port, function() { client.write(req); }); diff --git a/test/parallel/test-http-pipeline-regr-3508.js b/test/parallel/test-http-pipeline-regr-3508.js index 74fe7586726cbd..b196942969f608 100644 --- a/test/parallel/test-http-pipeline-regr-3508.js +++ b/test/parallel/test-http-pipeline-regr-3508.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const http = require('http'); const net = require('net'); @@ -41,8 +41,8 @@ var server = http.createServer(function(req, res) { socket.end(); }); first.end('hello'); -}).listen(common.PORT, function() { - var s = net.connect(common.PORT); +}).listen(0, function() { + var s = net.connect(this.address().port); more = function() { s.write('GET / HTTP/1.1\r\n\r\n'); }; diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js index 8a579cd69aa5b4..cfca4ee552b8bf 100644 --- a/test/parallel/test-http-proxy.js +++ b/test/parallel/test-http-proxy.js @@ -1,12 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var PROXY_PORT = common.PORT; -var BACKEND_PORT = common.PORT + 1; - var cookies = [ 'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT', 'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT' @@ -26,7 +23,7 @@ var backend = http.createServer(function(req, res) { var proxy = http.createServer(function(req, res) { console.error('proxy req headers: ' + JSON.stringify(req.headers)); http.get({ - port: BACKEND_PORT, + port: backend.address().port, path: url.parse(req.url).pathname }, function(proxy_res) { @@ -57,7 +54,7 @@ function startReq() { if (nlistening < 2) return; http.get({ - port: PROXY_PORT, + port: proxy.address().port, path: '/test' }, function(res) { console.error('got res'); @@ -79,10 +76,10 @@ function startReq() { } console.error('listen proxy'); -proxy.listen(PROXY_PORT, startReq); +proxy.listen(0, startReq); console.error('listen backend'); -backend.listen(BACKEND_PORT, startReq); +backend.listen(0, startReq); process.on('exit', function() { assert.equal(body, 'hello world\n'); diff --git a/test/parallel/test-http-raw-headers.js b/test/parallel/test-http-raw-headers.js index 2042c0262a95ed..a068acab1c8fdb 100644 --- a/test/parallel/test-http-raw-headers.js +++ b/test/parallel/test-http-raw-headers.js @@ -1,14 +1,13 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); http.createServer(function(req, res) { - this.close(); var expectRawHeaders = [ 'Host', - 'localhost:' + common.PORT, + `localhost:${this.address().port}`, 'transfer-ENCODING', 'CHUNKED', 'x-BaR', @@ -17,12 +16,11 @@ http.createServer(function(req, res) { 'close' ]; var expectHeaders = { - host: 'localhost:' + common.PORT, + host: `localhost:${this.address().port}`, 'transfer-encoding': 'CHUNKED', 'x-bar': 'yoyoyo', connection: 'close' }; - var expectRawTrailers = [ 'x-bAr', 'yOyOyOy', @@ -33,9 +31,10 @@ http.createServer(function(req, res) { 'X-baR', 'OyOyOyO' ]; - var expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' }; + this.close(); + assert.deepEqual(req.rawHeaders, expectRawHeaders); assert.deepEqual(req.headers, expectHeaders); @@ -53,8 +52,8 @@ http.createServer(function(req, res) { ['X-foO', 'OxOxOxO'] ]); res.end('x f o o'); -}).listen(common.PORT, function() { - var req = http.request({ port: common.PORT, path: '/' }); +}).listen(0, function() { + var req = http.request({ port: this.address().port, path: '/' }); req.addTrailers([ ['x-bAr', 'yOyOyOy'], ['x-baR', 'OyOyOyO'], diff --git a/test/parallel/test-http-regr-gh-2821.js b/test/parallel/test-http-regr-gh-2821.js index 8725111324a869..e3061a5b550b69 100644 --- a/test/parallel/test-http-regr-gh-2821.js +++ b/test/parallel/test-http-regr-gh-2821.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const http = require('http'); const server = http.createServer(function(req, res) { @@ -9,11 +9,11 @@ const server = http.createServer(function(req, res) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { const req = http.request({ method: 'POST', - port: common.PORT + port: this.address().port }); const payload = new Buffer(16390); diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 20390ffb2060d6..9b8ff35b0fe5d3 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -27,8 +27,8 @@ process.on('exit', function() { console.log('ok'); }); -server.listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +server.listen(0, function() { + http.get({ port: this.address().port }, function(res) { assert.equal(200, res.statusCode); assert.deepStrictEqual(res.headers, { date: 'coffee o clock' }); diff --git a/test/parallel/test-http-request-dont-override-options.js b/test/parallel/test-http-request-dont-override-options.js index 66d82caeac930d..5570dd49a2fc1b 100644 --- a/test/parallel/test-http-request-dont-override-options.js +++ b/test/parallel/test-http-request-dont-override-options.js @@ -11,35 +11,35 @@ http.createServer(function(req, res) { res.end('ok'); requests++; -}).listen(common.PORT).unref(); - -var agent = new http.Agent(); -agent.defaultPort = common.PORT; - -// options marked as explicitly undefined for readability -// in this test, they should STAY undefined as options should not -// be mutable / modified -var options = { - host: undefined, - hostname: common.localhostIPv4, - port: undefined, - defaultPort: undefined, - path: undefined, - method: undefined, - agent: agent -}; - -http.request(options, function(res) { - res.resume(); -}).end(); - -process.on('exit', function() { - assert.equal(requests, 1); - - assert.strictEqual(options.host, undefined); - assert.strictEqual(options.hostname, common.localhostIPv4); - assert.strictEqual(options.port, undefined); - assert.strictEqual(options.defaultPort, undefined); - assert.strictEqual(options.path, undefined); - assert.strictEqual(options.method, undefined); -}); +}).listen(0, function() { + var agent = new http.Agent(); + agent.defaultPort = this.address().port; + + // options marked as explicitly undefined for readability + // in this test, they should STAY undefined as options should not + // be mutable / modified + var options = { + host: undefined, + hostname: common.localhostIPv4, + port: undefined, + defaultPort: undefined, + path: undefined, + method: undefined, + agent: agent + }; + + http.request(options, function(res) { + res.resume(); + }).end(); + + process.on('exit', function() { + assert.equal(requests, 1); + + assert.strictEqual(options.host, undefined); + assert.strictEqual(options.hostname, common.localhostIPv4); + assert.strictEqual(options.port, undefined); + assert.strictEqual(options.defaultPort, undefined); + assert.strictEqual(options.path, undefined); + assert.strictEqual(options.method, undefined); + }); +}).unref(); diff --git a/test/parallel/test-http-request-end-twice.js b/test/parallel/test-http-request-end-twice.js index 871880e51463d8..fe08ae2d4864c6 100644 --- a/test/parallel/test-http-request-end-twice.js +++ b/test/parallel/test-http-request-end-twice.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -7,8 +7,8 @@ var server = http.Server(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('hello world\n'); }); -server.listen(common.PORT, function() { - var req = http.get({port: common.PORT}, function(res) { +server.listen(0, function() { + var req = http.get({port: this.address().port}, function(res) { res.on('end', function() { assert.ok(!req.end()); server.close(); diff --git a/test/parallel/test-http-request-end.js b/test/parallel/test-http-request-end.js index 6ecfc0672e35ff..5f03c60b7518e6 100644 --- a/test/parallel/test-http-request-end.js +++ b/test/parallel/test-http-request-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -20,9 +20,9 @@ var server = http.Server(function(req, res) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { http.request({ - port: common.PORT, + port: this.address().port, path: '/', method: 'POST' }, function(res) { diff --git a/test/parallel/test-http-request-methods.js b/test/parallel/test-http-request-methods.js index b29a6663ff6b26..cbfbbbc2ed603a 100644 --- a/test/parallel/test-http-request-methods.js +++ b/test/parallel/test-http-request-methods.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var http = require('http'); @@ -7,8 +7,6 @@ var http = require('http'); // Test that the DELETE, PATCH and PURGE verbs get passed through correctly ['DELETE', 'PATCH', 'PURGE'].forEach(function(method, index) { - var port = common.PORT + index; - var server_response = ''; var received_method = null; @@ -19,10 +17,10 @@ var http = require('http'); res.write('world\n'); res.end(); }); - server.listen(port); + server.listen(0); server.on('listening', function() { - var c = net.createConnection(port); + var c = net.createConnection(this.address().port); c.setEncoding('utf8'); diff --git a/test/parallel/test-http-res-write-after-end.js b/test/parallel/test-http-res-write-after-end.js index 206f4273ec70c7..8dca7adc9ec629 100644 --- a/test/parallel/test-http-res-write-after-end.js +++ b/test/parallel/test-http-res-write-after-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,8 +17,8 @@ var server = http.Server(function(req, res) { assert.equal(r, true, 'write after end should return true'); }); -server.listen(common.PORT, function() { - http.get({port: common.PORT}, function(res) { +server.listen(0, function() { + http.get({port: this.address().port}, function(res) { server.close(); }); }); diff --git a/test/parallel/test-http-res-write-end-dont-take-array.js b/test/parallel/test-http-res-write-end-dont-take-array.js index 0befd951f0cf16..ec3ff5107d5ec8 100644 --- a/test/parallel/test-http-res-write-end-dont-take-array.js +++ b/test/parallel/test-http-res-write-end-dont-take-array.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -31,14 +31,14 @@ var server = http.createServer(function(req, res) { } }); -server.listen(common.PORT, function() { +server.listen(0, function() { // just make a request, other tests handle responses - http.get({port: common.PORT}, function(res) { + http.get({port: this.address().port}, function(res) { res.resume(); // lazy serial test, because we can only call end once per request test += 1; // do it again to test .end(Buffer); - http.get({port: common.PORT}, function(res) { + http.get({port: server.address().port}, function(res) { res.resume(); server.close(); }); diff --git a/test/parallel/test-http-response-close.js b/test/parallel/test-http-response-close.js index 82fd782717371c..072136dfeeb811 100644 --- a/test/parallel/test-http-response-close.js +++ b/test/parallel/test-http-response-close.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -19,12 +19,12 @@ var server = http.createServer(function(req, res) { responseGotEnd = true; }); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { console.error('make req'); http.get({ - port: common.PORT + port: this.address().port }, function(res) { console.error('got res'); res.on('data', function(data) { diff --git a/test/parallel/test-http-response-multi-content-length.js b/test/parallel/test-http-response-multi-content-length.js index 8c03332fb2b7d2..dd6ad6a1cd4a0c 100644 --- a/test/parallel/test-http-response-multi-content-length.js +++ b/test/parallel/test-http-response-multi-content-length.js @@ -26,14 +26,14 @@ const server = http.createServer((req, res) => { var count = 0; -server.listen(common.PORT, common.mustCall(() => { +server.listen(0, common.mustCall(() => { for (let n = 1; n <= MAX_COUNT ; n++) { // This runs twice, the first time, the server will use // setHeader, the second time it uses writeHead. In either // case, the error handler must be called because the client // is not allowed to accept multiple content-length headers. http.get( - {port: common.PORT, headers: {'x-num': n}}, + {port: server.address().port, headers: {'x-num': n}}, (res) => { assert(false, 'client allowed multiple content-length headers.'); } diff --git a/test/parallel/test-http-response-no-headers.js b/test/parallel/test-http-response-no-headers.js index 888eb9ac4b87e2..8f70bead33f824 100644 --- a/test/parallel/test-http-response-no-headers.js +++ b/test/parallel/test-http-response-no-headers.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -24,10 +24,10 @@ function test(httpVersion, callback) { conn.end(reply); }); - server.listen(common.PORT, '127.0.0.1', function() { + server.listen(0, '127.0.0.1', function() { var options = { host: '127.0.0.1', - port: common.PORT + port: this.address().port }; var req = http.get(options, function(res) { diff --git a/test/parallel/test-http-response-readable.js b/test/parallel/test-http-response-readable.js index 1f50137d7166fd..9b4ab08fa5cfe6 100644 --- a/test/parallel/test-http-response-readable.js +++ b/test/parallel/test-http-response-readable.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -8,8 +8,8 @@ var testServer = new http.Server(function(req, res) { res.end('Hello world'); }); -testServer.listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +testServer.listen(0, function() { + http.get({ port: this.address().port }, function(res) { assert.equal(res.readable, true, 'res.readable initially true'); res.on('end', function() { assert.equal(res.readable, false, 'res.readable set to false after end'); diff --git a/test/parallel/test-http-response-splitting.js b/test/parallel/test-http-response-splitting.js index 3675f8182d21a5..07ced3fd146f9c 100644 --- a/test/parallel/test-http-response-splitting.js +++ b/test/parallel/test-http-response-splitting.js @@ -44,9 +44,9 @@ const server = http.createServer((req, res) => { server.close(); res.end('ok'); }); -server.listen(common.PORT, () => { +server.listen(0, () => { const end = 'HTTP/1.1\r\n\r\n'; - const client = net.connect({port: common.PORT}, () => { + const client = net.connect({port: server.address().port}, () => { client.write(`GET ${str} ${end}`); client.write(`GET / ${end}`); client.write(`GET / ${end}`); diff --git a/test/parallel/test-http-response-status-message.js b/test/parallel/test-http-response-status-message.js index a1e1f15697e468..b14c1f2faf0fce 100644 --- a/test/parallel/test-http-response-status-message.js +++ b/test/parallel/test-http-response-status-message.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -41,7 +41,10 @@ var server = net.createServer(function(connection) { var runTest = function(testCaseIndex) { var testCase = testCases[testCaseIndex]; - http.get({ port: common.PORT, path: testCase.path }, function(response) { + http.get({ + port: server.address().port, + path: testCase.path + }, function(response) { console.log('client: expected status message: ' + testCase.statusMessage); console.log('client: actual status message: ' + response.statusMessage); assert.equal(testCase.statusMessage, response.statusMessage); @@ -60,7 +63,7 @@ var runTest = function(testCaseIndex) { }); }; -server.listen(common.PORT, function() { runTest(0); }); +server.listen(0, function() { runTest(0); }); process.on('exit', function() { assert.equal(testCases.length, testsComplete); diff --git a/test/parallel/test-http-server-consumed-timeout.js b/test/parallel/test-http-server-consumed-timeout.js index 26110b32e7fba4..362b052ee78d58 100644 --- a/test/parallel/test-http-server-consumed-timeout.js +++ b/test/parallel/test-http-server-consumed-timeout.js @@ -19,9 +19,9 @@ const server = http.createServer((req, res) => { })); }); -server.listen(common.PORT, common.mustCall(() => { +server.listen(0, common.mustCall(() => { const req = http.request({ - port: common.PORT, + port: server.address().port, method: 'POST' }, (res) => { const interval = setInterval(() => { diff --git a/test/parallel/test-http-server-multiheaders.js b/test/parallel/test-http-server-multiheaders.js index 132f3fc1ea047f..5b41ee89d87e50 100644 --- a/test/parallel/test-http-server-multiheaders.js +++ b/test/parallel/test-http-server-multiheaders.js @@ -3,7 +3,7 @@ // of the same header as per RFC2616: joining the handful of fields by ', ' // that support it, and dropping duplicates for other fields. -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -24,10 +24,10 @@ var srv = http.createServer(function(req, res) { srv.close(); }); -srv.listen(common.PORT, function() { +srv.listen(0, function() { http.get({ host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', headers: [ ['accept', 'abc'], diff --git a/test/parallel/test-http-server-multiheaders2.js b/test/parallel/test-http-server-multiheaders2.js index 80cc3416d60dae..9f6d41e6a10cea 100644 --- a/test/parallel/test-http-server-multiheaders2.js +++ b/test/parallel/test-http-server-multiheaders2.js @@ -3,7 +3,7 @@ // of the same header as per RFC2616: joining the handful of fields by ', ' // that support it, and dropping duplicates for other fields. -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -76,10 +76,10 @@ var headers = [] .concat(multipleAllowed.map(makeHeader('bar'))) .concat(multipleForbidden.map(makeHeader('bar'))); -srv.listen(common.PORT, function() { +srv.listen(0, function() { http.get({ host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', headers: headers, }); diff --git a/test/parallel/test-http-server-reject-chunked-with-content-length.js b/test/parallel/test-http-server-reject-chunked-with-content-length.js index 42cc1e83eb26d6..b3284c368546b5 100644 --- a/test/parallel/test-http-server-reject-chunked-with-content-length.js +++ b/test/parallel/test-http-server-reject-chunked-with-content-length.js @@ -17,8 +17,8 @@ server.on('clientError', common.mustCall((err) => { assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); server.close(); })); -server.listen(common.PORT, () => { - const client = net.connect({port: common.PORT}, () => { +server.listen(0, () => { + const client = net.connect({port: server.address().port}, () => { client.write(reqstr); client.end(); }); diff --git a/test/parallel/test-http-server-reject-cr-no-lf.js b/test/parallel/test-http-server-reject-cr-no-lf.js index 9245dc2de54999..6c55dead96f19f 100644 --- a/test/parallel/test-http-server-reject-cr-no-lf.js +++ b/test/parallel/test-http-server-reject-cr-no-lf.js @@ -19,8 +19,8 @@ server.on('clientError', common.mustCall((err) => { assert.equal(err.code, 'HPE_LF_EXPECTED'); server.close(); })); -server.listen(common.PORT, () => { - const client = net.connect({port: common.PORT}, () => { +server.listen(0, () => { + const client = net.connect({port: server.address().port}, () => { client.on('data', (chunk) => { assert.fail(null, null, 'this should not be called'); }); diff --git a/test/parallel/test-http-server-stale-close.js b/test/parallel/test-http-server-stale-close.js index 349e869c1a4fbc..7430566dfd17e2 100644 --- a/test/parallel/test-http-server-stale-close.js +++ b/test/parallel/test-http-server-stale-close.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); var util = require('util'); var fork = require('child_process').fork; -if (process.env.NODE_TEST_FORK) { +if (process.env.NODE_TEST_FORK_PORT) { var req = http.request({ headers: {'Content-Length': '42'}, method: 'POST', host: '127.0.0.1', - port: common.PORT, + port: +process.env.NODE_TEST_FORK_PORT, }, process.exit); req.write('BAM'); req.end(); @@ -23,9 +23,9 @@ else { res.end(); }); }); - server.listen(common.PORT, function() { + server.listen(0, function() { fork(__filename, { - env: util._extend(process.env, {NODE_TEST_FORK: '1'}) + env: util._extend(process.env, {NODE_TEST_FORK_PORT: this.address().port}) }); }); } diff --git a/test/parallel/test-http-server-unconsume.js b/test/parallel/test-http-server-unconsume.js index 0d33263ad6ffa6..76238380c7cfde 100644 --- a/test/parallel/test-http-server-unconsume.js +++ b/test/parallel/test-http-server-unconsume.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -15,8 +15,8 @@ var server = http.createServer(function(req, res) { }); server.close(); -}).listen(common.PORT, function() { - var socket = net.connect(common.PORT, function() { +}).listen(0, function() { + var socket = net.connect(this.address().port, function() { socket.write('PUT / HTTP/1.1\r\n\r\n'); socket.once('data', function() { diff --git a/test/parallel/test-http-server.js b/test/parallel/test-http-server.js index b33c19a076fe04..110a1ebca93247 100644 --- a/test/parallel/test-http-server.js +++ b/test/parallel/test-http-server.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var http = require('http'); @@ -43,12 +43,12 @@ var server = http.createServer(function(req, res) { }, 1); }); -server.listen(common.PORT); +server.listen(0); server.httpAllowHalfOpen = true; server.on('listening', function() { - var c = net.createConnection(common.PORT); + var c = net.createConnection(this.address().port); c.setEncoding('utf8'); diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index 9a43f82a39c12e..522119c95888d2 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,13 +17,13 @@ var server = http.createServer(function(req, res) { res.end('two\n'); } }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { // // one set-cookie header // - http.get({ port: common.PORT, path: '/one' }, function(res) { + http.get({ port: this.address().port, path: '/one' }, function(res) { // set-cookie headers are always return in an array. // even if there is only one. assert.deepEqual(['A'], res.headers['set-cookie']); @@ -42,7 +42,7 @@ server.on('listening', function() { // two set-cookie headers - http.get({ port: common.PORT, path: '/two' }, function(res) { + http.get({ port: this.address().port, path: '/two' }, function(res) { assert.deepEqual(['A', 'B'], res.headers['set-cookie']); assert.equal('text/plain', res.headers['content-type']); diff --git a/test/parallel/test-http-set-timeout.js b/test/parallel/test-http-set-timeout.js index ca238de43144e2..08777d30d22570 100644 --- a/test/parallel/test-http-set-timeout.js +++ b/test/parallel/test-http-set-timeout.js @@ -15,14 +15,14 @@ var server = http.createServer(function(req, res) { }); }); -server.listen(common.PORT, function() { - console.log('Server running at http://127.0.0.1:' + common.PORT + '/'); +server.listen(0, function() { + console.log(`Server running at http://127.0.0.1:${this.address().port}/`); var errorTimer = setTimeout(function() { throw new Error('Timeout was not successful'); }, common.platformTimeout(2000)); - var x = http.get({port: common.PORT, path: '/'}); + var x = http.get({port: this.address().port, path: '/'}); x.on('error', function() { clearTimeout(errorTimer); console.log('HTTP REQUEST COMPLETE (this is good)'); diff --git a/test/parallel/test-http-set-trailers.js b/test/parallel/test-http-set-trailers.js index 000df0189a9286..df69a060c8d052 100644 --- a/test/parallel/test-http-set-trailers.js +++ b/test/parallel/test-http-set-trailers.js @@ -11,12 +11,12 @@ var server = http.createServer(function(req, res) { res.addTrailers({'x-foo': 'bar'}); res.end('stuff' + '\n'); }); -server.listen(common.PORT); +server.listen(0); // first, we test an HTTP/1.0 request. server.on('listening', function() { - var c = net.createConnection(common.PORT); + var c = net.createConnection(this.address().port); var res_buffer = ''; c.setEncoding('utf8'); @@ -44,7 +44,7 @@ server.on('listening', function() { // now, we test an HTTP/1.1 request. server.on('listening', function() { - var c = net.createConnection(common.PORT); + var c = net.createConnection(this.address().port); var res_buffer = ''; var tid; @@ -76,7 +76,11 @@ server.on('listening', function() { // now, see if the client sees the trailers. server.on('listening', function() { - http.get({ port: common.PORT, path: '/hello', headers: {} }, function(res) { + http.get({ + port: this.address().port, + path: '/hello', + headers: {} + }, function(res) { res.on('end', function() { //console.log(res.trailers); assert.ok('x-foo' in res.trailers, 'Client doesn\'t see trailers.'); diff --git a/test/parallel/test-http-should-keep-alive.js b/test/parallel/test-http-should-keep-alive.js index 870223a37b6d44..3aaa2d3d73acdc 100644 --- a/test/parallel/test-http-should-keep-alive.js +++ b/test/parallel/test-http-should-keep-alive.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -27,9 +27,9 @@ http.globalAgent.maxSockets = 5; var server = net.createServer(function(socket) { socket.write(SERVER_RESPONSES[requests]); ++requests; -}).listen(common.PORT, function() { +}).listen(0, function() { function makeRequest() { - var req = http.get({port: common.PORT}, function(res) { + var req = http.get({port: server.address().port}, function(res) { assert.equal(req.shouldKeepAlive, SHOULD_KEEP_ALIVE[responses], SERVER_RESPONSES[responses] + ' should ' + (SHOULD_KEEP_ALIVE[responses] ? '' : 'not ') + diff --git a/test/parallel/test-http-status-code.js b/test/parallel/test-http-status-code.js index 19c36b0b2fd27f..4422124a8cf70d 100644 --- a/test/parallel/test-http-status-code.js +++ b/test/parallel/test-http-status-code.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -18,7 +18,7 @@ var s = http.createServer(function(req, res) { res.end('hello world\n'); }); -s.listen(common.PORT, nextTest); +s.listen(0, nextTest); function nextTest() { @@ -27,7 +27,7 @@ function nextTest() { } var test = tests[testIdx]; - http.get({ port: common.PORT }, function(response) { + http.get({ port: s.address().port }, function(response) { console.log('client: expected status: ' + test); console.log('client: statusCode: ' + response.statusCode); assert.equal(response.statusCode, test); diff --git a/test/parallel/test-http-status-message.js b/test/parallel/test-http-status-message.js index e579b8e995e120..15567794c33ae1 100644 --- a/test/parallel/test-http-status-message.js +++ b/test/parallel/test-http-status-message.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -10,12 +10,12 @@ var s = http.createServer(function(req, res) { res.end(''); }); -s.listen(common.PORT, test); +s.listen(0, test); function test() { var bufs = []; - var client = net.connect(common.PORT, function() { + var client = net.connect(this.address().port, function() { client.write('GET / HTTP/1.1\r\nConnection: close\r\n\r\n'); }); client.on('data', function(chunk) { diff --git a/test/parallel/test-http-timeout-overflow.js b/test/parallel/test-http-timeout-overflow.js index 0df485edc93f9c..49cf3ec0278fca 100644 --- a/test/parallel/test-http-timeout-overflow.js +++ b/test/parallel/test-http-timeout-overflow.js @@ -1,10 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); -var port = common.PORT; var serverRequests = 0; var clientRequests = 0; @@ -14,11 +13,11 @@ var server = http.createServer(function(req, res) { res.end('OK'); }); -server.listen(port, function() { +server.listen(0, function() { function callback() {} var req = http.request({ - port: port, + port: this.address().port, path: '/', agent: false }, function(res) { diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js index abaa368045d14d..d1cec8e6e0c324 100644 --- a/test/parallel/test-http-timeout.js +++ b/test/parallel/test-http-timeout.js @@ -1,10 +1,8 @@ 'use strict'; -var common = require('../common'); +require('../common'); var http = require('http'); -var port = common.PORT; - var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('OK'); @@ -12,7 +10,7 @@ var server = http.createServer(function(req, res) { var agent = new http.Agent({maxSockets: 1}); -server.listen(port, function() { +server.listen(0, function() { for (var i = 0; i < 11; ++i) { createRequest().end(); @@ -24,7 +22,7 @@ server.listen(port, function() { function createRequest() { const req = http.request( - {port: port, path: '/', agent: agent}, + {port: server.address().port, path: '/', agent: agent}, function(res) { req.clearTimeout(callback); diff --git a/test/parallel/test-http-upgrade-advertise.js b/test/parallel/test-http-upgrade-advertise.js index fbc183f84b2ada..3deb71fbea1b75 100644 --- a/test/parallel/test-http-upgrade-advertise.js +++ b/test/parallel/test-http-upgrade-advertise.js @@ -24,7 +24,7 @@ function fire() { }); const req = http.request({ - port: common.PORT, + port: server.address().port, path: '/', headers: test.headers }, function onResponse(res) { @@ -51,4 +51,4 @@ const server = http.createServer(function(req, res) { 'Connection: upgrade\r\n' + 'Upgrade: h2c\r\n\r\n' + 'ohai'); -}).listen(common.PORT, fire); +}).listen(0, fire); diff --git a/test/parallel/test-http-upgrade-agent.js b/test/parallel/test-http-upgrade-agent.js index 8c2256db5933bc..4d1c11eaefb383 100644 --- a/test/parallel/test-http-upgrade-agent.js +++ b/test/parallel/test-http-upgrade-agent.js @@ -27,10 +27,10 @@ var srv = net.createServer(function(c) { var gotUpgrade = false; -srv.listen(common.PORT, '127.0.0.1', function() { +srv.listen(0, '127.0.0.1', function() { var options = { - port: common.PORT, + port: this.address().port, host: '127.0.0.1', headers: { 'connection': 'upgrade', diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index 8d90eea116d485..d0f29753c1794d 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -27,10 +27,10 @@ var srv = net.createServer(function(c) { var gotUpgrade = false; -srv.listen(common.PORT, '127.0.0.1', function() { +srv.listen(0, '127.0.0.1', function() { var req = http.get({ - port: common.PORT, + port: this.address().port, headers: { connection: 'upgrade', upgrade: 'websocket' diff --git a/test/parallel/test-http-upgrade-client2.js b/test/parallel/test-http-upgrade-client2.js index 424d7c811c1a5a..f48644ee735794 100644 --- a/test/parallel/test-http-upgrade-client2.js +++ b/test/parallel/test-http-upgrade-client2.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -17,12 +17,15 @@ server.on('upgrade', function(req, socket, head) { var successCount = 0; -server.listen(common.PORT, function() { +server.listen(0, function() { function upgradeRequest(fn) { console.log('req'); var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' }; - var request = http.request({ port: common.PORT, headers: header }); + var request = http.request({ + port: server.address().port, + headers: header + }); var wasUpgrade = false; function onUpgrade(res, socket, head) { diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 9b34fe42eb05b9..ba0533c0fe8293 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var util = require('util'); @@ -16,20 +16,19 @@ function createTestServer() { } function testServer() { - var server = this; - http.Server.call(server, function() {}); + http.Server.call(this, function() {}); - server.on('connection', function() { + this.on('connection', function() { requests_recv++; }); - server.on('request', function(req, res) { + this.on('request', function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('okay'); res.end(); }); - server.on('upgrade', function(req, socket, upgradeHead) { + this.on('upgrade', function(req, socket, upgradeHead) { socket.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + 'Upgrade: WebSocket\r\n' + 'Connection: Upgrade\r\n' + @@ -60,8 +59,8 @@ function writeReq(socket, data, encoding) { /*----------------------------------------------- connection: Upgrade with listener -----------------------------------------------*/ -function test_upgrade_with_listener(_server) { - var conn = net.createConnection(common.PORT); +function test_upgrade_with_listener() { + var conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); var state = 0; @@ -92,7 +91,7 @@ function test_upgrade_with_listener(_server) { conn.on('end', function() { assert.equal(2, state); conn.end(); - _server.removeAllListeners('upgrade'); + server.removeAllListeners('upgrade'); test_upgrade_no_listener(); }); } @@ -103,7 +102,7 @@ function test_upgrade_with_listener(_server) { var test_upgrade_no_listener_ended = false; function test_upgrade_no_listener() { - var conn = net.createConnection(common.PORT); + var conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); conn.on('connect', function() { @@ -128,7 +127,7 @@ function test_upgrade_no_listener() { connection: normal -----------------------------------------------*/ function test_standard_http() { - var conn = net.createConnection(common.PORT); + var conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); conn.on('connect', function() { @@ -149,9 +148,9 @@ function test_standard_http() { var server = createTestServer(); -server.listen(common.PORT, function() { +server.listen(0, function() { // All tests get chained after this: - test_upgrade_with_listener(server); + test_upgrade_with_listener(); }); diff --git a/test/parallel/test-http-upgrade-server2.js b/test/parallel/test-http-upgrade-server2.js index dec3bab1caeac0..b1616617294b5e 100644 --- a/test/parallel/test-http-upgrade-server2.js +++ b/test/parallel/test-http-upgrade-server2.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); @@ -23,8 +23,8 @@ process.on('uncaughtException', function(e) { }); -server.listen(common.PORT, function() { - var c = net.createConnection(common.PORT); +server.listen(0, function() { + var c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /blah HTTP/1.1\r\n' + diff --git a/test/parallel/test-http-url.parse-auth-with-header-in-request.js b/test/parallel/test-http-url.parse-auth-with-header-in-request.js index bb5de74ff9dcad..fa930bd5ec2e34 100644 --- a/test/parallel/test-http-url.parse-auth-with-header-in-request.js +++ b/test/parallel/test-http-url.parse-auth-with-header-in-request.js @@ -1,16 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var testURL = url.parse('http://asdf:qwer@localhost:' + common.PORT); -// the test here is if you set a specific authorization header in the -// request we should not override that with basic auth -testURL.headers = { - Authorization: 'NoAuthForYOU' -}; - function check(request) { // the correct authorization header is be passed assert.strictEqual(request.headers.authorization, 'NoAuthForYOU'); @@ -24,7 +17,14 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + var testURL = url.parse(`http://asdf:qwer@localhost:${this.address().port}`); + // the test here is if you set a specific authorization header in the + // request we should not override that with basic auth + testURL.headers = { + Authorization: 'NoAuthForYOU' + }; + // make the request http.request(testURL).end(); }); diff --git a/test/parallel/test-http-url.parse-auth.js b/test/parallel/test-http-url.parse-auth.js index d06c79a9e707a4..0e901ebb599b00 100644 --- a/test/parallel/test-http-url.parse-auth.js +++ b/test/parallel/test-http-url.parse-auth.js @@ -1,12 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -// username = "user", password = "pass:" -var testURL = url.parse('http://user:pass%3A@localhost:' + common.PORT); - function check(request) { // the correct authorization header is be passed assert.strictEqual(request.headers.authorization, 'Basic dXNlcjpwYXNzOg=='); @@ -20,7 +17,11 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + const port = this.address().port; + // username = "user", password = "pass:" + var testURL = url.parse(`http://user:pass%3A@localhost:${port}`); + // make the request http.request(testURL).end(); }); diff --git a/test/parallel/test-http-url.parse-basic.js b/test/parallel/test-http-url.parse-basic.js index efc375e97cbb62..b0d1274b594d7e 100644 --- a/test/parallel/test-http-url.parse-basic.js +++ b/test/parallel/test-http-url.parse-basic.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var testURL = url.parse('http://localhost:' + common.PORT); +var testURL; // make sure the basics work function check(request) { @@ -25,7 +25,9 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + testURL = url.parse(`http://localhost:${this.address().port}`); + // make the request var clientRequest = http.request(testURL); // since there is a little magic with the agent diff --git a/test/parallel/test-http-url.parse-https.request.js b/test/parallel/test-http-url.parse-https.request.js index d843d9838d9914..edd83a2d1306f5 100644 --- a/test/parallel/test-http-url.parse-https.request.js +++ b/test/parallel/test-http-url.parse-https.request.js @@ -17,9 +17,6 @@ var httpsOptions = { cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var testURL = url.parse('https://localhost:' + common.PORT); -testURL.rejectUnauthorized = false; - function check(request) { // assert that I'm https assert.ok(request.socket._secureEstablished); @@ -33,7 +30,10 @@ var server = https.createServer(httpsOptions, function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + var testURL = url.parse(`https://localhost:${this.address().port}`); + testURL.rejectUnauthorized = false; + // make the request var clientRequest = https.request(testURL); // since there is a little magic with the agent diff --git a/test/parallel/test-http-url.parse-path.js b/test/parallel/test-http-url.parse-path.js index 087f535fa99c83..73de297d45fca5 100644 --- a/test/parallel/test-http-url.parse-path.js +++ b/test/parallel/test-http-url.parse-path.js @@ -1,11 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var testURL = url.parse('http://localhost:' + common.PORT + '/asdf'); - function check(request) { // a path should come over assert.strictEqual(request.url, '/asdf'); @@ -19,7 +17,9 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + var testURL = url.parse(`http://localhost:${this.address().port}/asdf`); + // make the request http.request(testURL).end(); }); diff --git a/test/parallel/test-http-url.parse-post.js b/test/parallel/test-http-url.parse-post.js index 7611b0856320a6..0af482c94a875d 100644 --- a/test/parallel/test-http-url.parse-post.js +++ b/test/parallel/test-http-url.parse-post.js @@ -1,11 +1,10 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var testURL = url.parse('http://localhost:' + common.PORT + '/asdf?qwer=zxcv'); -testURL.method = 'POST'; +var testURL; function check(request) { //url.parse should not mess with the method @@ -25,7 +24,10 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + testURL = url.parse(`http://localhost:${this.address().port}/asdf?qwer=zxcv`); + testURL.method = 'POST'; + // make the request http.request(testURL).end(); }); diff --git a/test/parallel/test-http-url.parse-search.js b/test/parallel/test-http-url.parse-search.js index 04e5a72e8f913e..9a1e7565572fcc 100644 --- a/test/parallel/test-http-url.parse-search.js +++ b/test/parallel/test-http-url.parse-search.js @@ -1,11 +1,9 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); -var testURL = url.parse('http://localhost:' + common.PORT + '/asdf?qwer=zxcv'); - function check(request) { // a path should come over with params assert.strictEqual(request.url, '/asdf?qwer=zxcv'); @@ -19,7 +17,10 @@ var server = http.createServer(function(request, response) { server.close(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { + const port = this.address().port; + var testURL = url.parse(`http://localhost:${port}/asdf?qwer=zxcv`); + // make the request http.request(testURL).end(); }); diff --git a/test/parallel/test-http-wget.js b/test/parallel/test-http-wget.js index 78144ac6fbf7cb..2c3ea3335d89dd 100644 --- a/test/parallel/test-http-wget.js +++ b/test/parallel/test-http-wget.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var http = require('http'); @@ -29,10 +29,10 @@ var server = http.createServer(function(req, res) { res.write('world\n'); res.end(); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { - var c = net.createConnection(common.PORT); + var c = net.createConnection(this.address().port); c.setEncoding('utf8'); diff --git a/test/parallel/test-http-write-callbacks.js b/test/parallel/test-http-write-callbacks.js index 404396723e4416..55b6cbac6ade42 100644 --- a/test/parallel/test-http-write-callbacks.js +++ b/test/parallel/test-http-write-callbacks.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -50,9 +50,9 @@ server.on('checkContinue', function(req, res) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, method: 'PUT', headers: { 'expect': '100-continue' } }); diff --git a/test/parallel/test-http-write-empty-string.js b/test/parallel/test-http-write-empty-string.js index 44a1ae9d02dfef..6ae723e306bae2 100644 --- a/test/parallel/test-http-write-empty-string.js +++ b/test/parallel/test-http-write-empty-string.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -24,8 +24,8 @@ process.on('exit', function() { }); -server.listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +server.listen(0, function() { + http.get({ port: this.address().port }, function(res) { assert.equal(200, res.statusCode); res.setEncoding('ascii'); res.on('data', function(chunk) { diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js index 79a8502c4f01b0..3e3e7fe80bd6ef 100644 --- a/test/parallel/test-http-write-head.js +++ b/test/parallel/test-http-write-head.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -34,10 +34,10 @@ var s = http.createServer(function(req, res) { res.end(); }); -s.listen(common.PORT, runTest); +s.listen(0, runTest); function runTest() { - http.get({ port: common.PORT }, function(response) { + http.get({ port: this.address().port }, function(response) { response.on('end', function() { assert.equal(response.headers['test'], '2'); assert(response.rawHeaders.indexOf('Test') !== -1); diff --git a/test/parallel/test-http-zero-length-write.js b/test/parallel/test-http-zero-length-write.js index 1ba29ca1c4a9fb..b928aaeb341a88 100644 --- a/test/parallel/test-http-zero-length-write.js +++ b/test/parallel/test-http-zero-length-write.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -53,8 +53,8 @@ var server = http.createServer(function(req, res) { server.close(); }); -server.listen(common.PORT, function() { - var req = http.request({ port: common.PORT, method: 'POST' }); +server.listen(0, function() { + var req = http.request({ port: this.address().port, method: 'POST' }); var actual = ''; req.on('response', function(res) { res.setEncoding('utf8'); diff --git a/test/parallel/test-http.js b/test/parallel/test-http.js index 5738fc766d7cc7..102567fc2b42a7 100644 --- a/test/parallel/test-http.js +++ b/test/parallel/test-http.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var url = require('url'); @@ -38,12 +38,12 @@ var server = http.Server(function(req, res) { //assert.equal('127.0.0.1', res.connection.remoteAddress); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { - var agent = new http.Agent({ port: common.PORT, maxSockets: 1 }); + var agent = new http.Agent({ port: this.address().port, maxSockets: 1 }); http.get({ - port: common.PORT, + port: this.address().port, path: '/hello', headers: {'Accept': '*/*', 'Foo': 'bar'}, agent: agent @@ -57,7 +57,7 @@ server.on('listening', function() { setTimeout(function() { var req = http.request({ - port: common.PORT, + port: server.address().port, method: 'POST', path: '/world', agent: agent diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js index 1ebed86a82878a..348cf499b65f56 100644 --- a/test/parallel/test-https-agent-servername.js +++ b/test/parallel/test-https-agent-servername.js @@ -22,10 +22,10 @@ var server = https.Server(options, function(req, res) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { https.get({ path: '/', - port: common.PORT, + port: this.address().port, rejectUnauthorized: true, servername: 'agent1', ca: options.ca diff --git a/test/parallel/test-https-agent-session-eviction.js b/test/parallel/test-https-agent-session-eviction.js index 37f4fa3e564439..a3e71db5827398 100644 --- a/test/parallel/test-https-agent-session-eviction.js +++ b/test/parallel/test-https-agent-session-eviction.js @@ -21,31 +21,32 @@ const options = { // Create TLS1.2 server https.createServer(options, function(req, res) { res.end('ohai'); -}).listen(common.PORT, function() { +}).listen(0, function() { first(this); }); // Do request and let agent cache the session function first(server) { + const port = server.address().port; const req = https.request({ - port: common.PORT, + port: port, rejectUnauthorized: false }, function(res) { res.resume(); server.close(function() { - faultyServer(); + faultyServer(port); }); }); req.end(); } // Create TLS1 server -function faultyServer() { +function faultyServer(port) { options.secureProtocol = 'TLSv1_method'; https.createServer(options, function(req, res) { res.end('hello faulty'); - }).listen(common.PORT, function() { + }).listen(port, function() { second(this); }); } @@ -53,7 +54,7 @@ function faultyServer() { // Attempt to request using cached session function second(server, session) { const req = https.request({ - port: common.PORT, + port: server.address().port, rejectUnauthorized: false }, function(res) { res.resume(); @@ -70,10 +71,10 @@ function second(server, session) { req.end(); } -// Try on more time - session should be evicted! +// Try one more time - session should be evicted! function third(server) { const req = https.request({ - port: common.PORT, + port: server.address().port, rejectUnauthorized: false }, function(res) { res.resume(); diff --git a/test/parallel/test-https-agent-session-reuse.js b/test/parallel/test-https-agent-session-reuse.js index 1421d545783ac3..01f161574b29db 100644 --- a/test/parallel/test-https-agent-session-reuse.js +++ b/test/parallel/test-https-agent-session-reuse.js @@ -32,7 +32,7 @@ var server = https.createServer(options, function(req, res) { serverRequests++; res.end('ok'); -}).listen(common.PORT, function() { +}).listen(0, function() { var queue = [ { name: 'first', @@ -41,7 +41,7 @@ var server = https.createServer(options, function(req, res) { path: '/', servername: 'agent1', ca: ca, - port: common.PORT + port: this.address().port }, { name: 'first-reuse', @@ -50,7 +50,7 @@ var server = https.createServer(options, function(req, res) { path: '/', servername: 'agent1', ca: ca, - port: common.PORT + port: this.address().port }, { name: 'cipher-change', @@ -62,7 +62,7 @@ var server = https.createServer(options, function(req, res) { // Choose different cipher to use different cache entry ciphers: 'AES256-SHA', ca: ca, - port: common.PORT + port: this.address().port }, // Change the ticket key to ensure session is updated in cache { @@ -72,7 +72,7 @@ var server = https.createServer(options, function(req, res) { path: '/drop-key', servername: 'agent1', ca: ca, - port: common.PORT + port: this.address().port }, // Ticket will be updated starting from this @@ -83,7 +83,7 @@ var server = https.createServer(options, function(req, res) { path: '/', servername: 'agent1', ca: ca, - port: common.PORT + port: this.address().port }, { name: 'after-drop-reuse', @@ -92,7 +92,7 @@ var server = https.createServer(options, function(req, res) { path: '/', servername: 'agent1', ca: ca, - port: common.PORT + port: this.address().port } ]; diff --git a/test/parallel/test-https-agent-sni.js b/test/parallel/test-https-agent-sni.js index b8f6c8cde8520c..4174fd0b9c1fed 100644 --- a/test/parallel/test-https-agent-sni.js +++ b/test/parallel/test-https-agent-sni.js @@ -27,7 +27,7 @@ const server = https.Server(options, function(req, res) { res.end('hello world'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { function expectResponse(id) { return common.mustCall(function(res) { res.resume(); @@ -43,7 +43,7 @@ server.listen(common.PORT, function() { agent: agent, path: '/', - port: common.PORT, + port: this.address().port, host: '127.0.0.1', servername: 'sni.' + j, rejectUnauthorized: false diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js index 08d35337121acf..2ad3bd8d01a850 100644 --- a/test/parallel/test-https-agent.js +++ b/test/parallel/test-https-agent.js @@ -26,13 +26,13 @@ var responses = 0; var N = 4; var M = 4; -server.listen(common.PORT, function() { +server.listen(0, function() { for (var i = 0; i < N; i++) { setTimeout(function() { for (var j = 0; j < M; j++) { https.get({ path: '/', - port: common.PORT, + port: server.address().port, rejectUnauthorized: false }, function(res) { res.resume(); diff --git a/test/parallel/test-https-byteswritten.js b/test/parallel/test-https-byteswritten.js index 2f8856ca999833..0ca4bca95cc012 100644 --- a/test/parallel/test-https-byteswritten.js +++ b/test/parallel/test-https-byteswritten.js @@ -27,9 +27,9 @@ var httpsServer = https.createServer(options, function(req, res) { res.end(body); }); -httpsServer.listen(common.PORT, function() { +httpsServer.listen(0, function() { https.get({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); }); diff --git a/test/parallel/test-https-client-checkServerIdentity.js b/test/parallel/test-https-client-checkServerIdentity.js index f16285860afe60..4b4bbc9d0598ad 100644 --- a/test/parallel/test-https-client-checkServerIdentity.js +++ b/test/parallel/test-https-client-checkServerIdentity.js @@ -23,13 +23,13 @@ var server = https.createServer(options, function(req, res) { res.writeHead(200); res.end(); req.resume(); -}).listen(common.PORT, function() { +}).listen(0, function() { authorized(); }); function authorized() { var req = https.request({ - port: common.PORT, + port: server.address().port, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))] }, function(res) { @@ -43,7 +43,7 @@ function authorized() { function override() { var options = { - port: common.PORT, + port: server.address().port, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))], checkServerIdentity: function(host, cert) { diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index 50875e6d452da7..1d816bee32ffda 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/test/parallel/test-https-client-get-url.js @@ -30,8 +30,8 @@ var server = https.createServer(options, function(req, res) { seen_req = true; }); -server.listen(common.PORT, function() { - https.get('https://127.0.0.1:' + common.PORT + '/foo?bar'); +server.listen(0, function() { + https.get(`https://127.0.0.1:${this.address().port}/foo?bar`); }); process.on('exit', function() { diff --git a/test/parallel/test-https-client-reject.js b/test/parallel/test-https-client-reject.js index ee19de2acdd0ab..1bf42e5df57090 100644 --- a/test/parallel/test-https-client-reject.js +++ b/test/parallel/test-https-client-reject.js @@ -23,13 +23,13 @@ var server = https.createServer(options, function(req, res) { res.writeHead(200); res.end(); req.resume(); -}).listen(common.PORT, function() { +}).listen(0, function() { unauthorized(); }); function unauthorized() { var req = https.request({ - port: common.PORT, + port: server.address().port, rejectUnauthorized: false }, function(res) { assert(!req.socket.authorized); @@ -44,7 +44,7 @@ function unauthorized() { function rejectUnauthorized() { var options = { - port: common.PORT + port: server.address().port }; options.agent = new https.Agent(options); var req = https.request(options, function(res) { @@ -58,7 +58,7 @@ function rejectUnauthorized() { function authorized() { var options = { - port: common.PORT, + port: server.address().port, ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))] }; options.agent = new https.Agent(options); diff --git a/test/parallel/test-https-client-resume.js b/test/parallel/test-https-client-resume.js index b91f3d83148ff1..9ddf20fa34a47c 100644 --- a/test/parallel/test-https-client-resume.js +++ b/test/parallel/test-https-client-resume.js @@ -28,11 +28,11 @@ var server = https.createServer(options, function(req, res) { }); // start listening -server.listen(common.PORT, function() { +server.listen(0, function() { var session1 = null; var client1 = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { console.log('connect1'); @@ -47,7 +47,7 @@ server.listen(common.PORT, function() { console.log('close1'); var opts = { - port: common.PORT, + port: server.address().port, rejectUnauthorized: false, session: session1 }; diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js index 18237a612bde31..f77726ceb68bf9 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -39,10 +39,10 @@ function shutdown() { } } -server.listen(common.PORT, function() { +server.listen(0, function() { var requestOptions = { hostname: '127.0.0.1', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', rejectUnauthorized: false diff --git a/test/parallel/test-https-connect-address-family.js b/test/parallel/test-https-connect-address-family.js index b2f3c233cfd720..8d7c406924f830 100644 --- a/test/parallel/test-https-connect-address-family.js +++ b/test/parallel/test-https-connect-address-family.js @@ -12,10 +12,10 @@ const ciphers = 'AECDH-NULL-SHA'; https.createServer({ ciphers }, function(req, res) { this.close(); res.end(); -}).listen(common.PORT, '::1', function() { +}).listen(0, '::1', function() { const options = { host: 'localhost', - port: common.PORT, + port: this.address().port, family: 6, ciphers: ciphers, rejectUnauthorized: false, diff --git a/test/parallel/test-https-connecting-to-http.js b/test/parallel/test-https-connecting-to-http.js index 2b705b4cfabb5b..31eb0171ad87e6 100644 --- a/test/parallel/test-https-connecting-to-http.js +++ b/test/parallel/test-https-connecting-to-http.js @@ -25,8 +25,8 @@ var server = http.createServer(function(req, res) { }); -server.listen(common.PORT, function() { - var req = https.get({ port: common.PORT }, function(res) { +server.listen(0, function() { + var req = https.get({ port: this.address().port }, function(res) { resCount++; }); diff --git a/test/parallel/test-https-drain.js b/test/parallel/test-https-drain.js index e4ce6d9890353f..ce0e3376f86baf 100644 --- a/test/parallel/test-https-drain.js +++ b/test/parallel/test-https-drain.js @@ -25,11 +25,11 @@ var server = https.createServer(options, function(req, res) { req.pipe(res); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var resumed = false; var req = https.request({ method: 'POST', - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function(res) { var timer; diff --git a/test/parallel/test-https-eof-for-eom.js b/test/parallel/test-https-eof-for-eom.js index 5431d33c3d394f..924785e0aaefd1 100644 --- a/test/parallel/test-https-eof-for-eom.js +++ b/test/parallel/test-https-eof-for-eom.js @@ -51,10 +51,10 @@ var gotHeaders = false; var gotEnd = false; var bodyBuffer = ''; -server.listen(common.PORT, function() { +server.listen(0, function() { console.log('1) Making Request'); https.get({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function(res) { server.close(); diff --git a/test/parallel/test-https-foafssl.js b/test/parallel/test-https-foafssl.js index c91cb0b138c7d0..f8370e73902242 100644 --- a/test/parallel/test-https-foafssl.js +++ b/test/parallel/test-https-foafssl.js @@ -44,10 +44,10 @@ var server = https.createServer(options, function(req, res) { res.end(body); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var args = ['s_client', '-quiet', - '-connect', '127.0.0.1:' + common.PORT, + '-connect', `127.0.0.1:${this.address().port}`, '-cert', join(common.fixturesDir, 'foafssl.crt'), '-key', join(common.fixturesDir, 'foafssl.key')]; diff --git a/test/parallel/test-https-host-headers.js b/test/parallel/test-https-host-headers.js index 4c292d7e8bbd6f..e4fd6dfe92ef15 100644 --- a/test/parallel/test-https-host-headers.js +++ b/test/parallel/test-https-host-headers.js @@ -20,7 +20,7 @@ function reqHandler(req, res) { if (req.url === '/setHostFalse5') { assert.equal(req.headers.host, undefined); } else { - assert.equal(req.headers.host, 'localhost:' + common.PORT, + assert.equal(req.headers.host, `localhost:${this.address().port}`, 'Wrong host header for req[' + req.url + ']: ' + req.headers.host); } @@ -37,8 +37,6 @@ testHttps(); function testHttps() { - console.log('testing https on port ' + common.PORT); - var counter = 0; function cb(res) { @@ -51,7 +49,9 @@ function testHttps() { res.resume(); } - httpsServer.listen(common.PORT, function(er) { + httpsServer.listen(0, function(er) { + console.log(`test https server listening on port ${this.address().port}`); + if (er) throw er; https.get({ @@ -59,7 +59,7 @@ function testHttps() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower); @@ -68,7 +68,7 @@ function testHttps() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -77,7 +77,7 @@ function testHttps() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -86,7 +86,7 @@ function testHttps() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -95,7 +95,7 @@ function testHttps() { path: '/' + (counter++), host: 'localhost', //agent: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); @@ -104,7 +104,7 @@ function testHttps() { path: '/setHostFalse' + (counter++), host: 'localhost', setHost: false, - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, cb).on('error', thrower).end(); }); diff --git a/test/parallel/test-https-localaddress-bind-error.js b/test/parallel/test-https-localaddress-bind-error.js index 75f915a05cc250..5e5f900c7a809b 100644 --- a/test/parallel/test-https-localaddress-bind-error.js +++ b/test/parallel/test-https-localaddress-bind-error.js @@ -27,10 +27,10 @@ var server = https.createServer(options, function(req, res) { req.resume(); }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { https.request({ host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', localAddress: invalidLocalAddress diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index ed70d0281cfdc2..e6aa0c93a2aaaa 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -30,10 +30,10 @@ var server = https.createServer(options, function(req, res) { req.resume(); }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var options = { host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', localAddress: '127.0.0.2', diff --git a/test/parallel/test-https-pfx.js b/test/parallel/test-https-pfx.js index 0d2c6d367a6e9a..ab6db5f7226430 100644 --- a/test/parallel/test-https-pfx.js +++ b/test/parallel/test-https-pfx.js @@ -13,7 +13,7 @@ var pfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); var options = { host: '127.0.0.1', - port: common.PORT, + port: undefined, path: '/', pfx: pfx, passphrase: 'sample', @@ -28,7 +28,8 @@ var server = https.createServer(options, function(req, res) { res.end('OK'); }); -server.listen(options.port, options.host, function() { +server.listen(0, options.host, function() { + options.port = this.address().port; var data = ''; https.get(options, function(res) { diff --git a/test/parallel/test-https-req-split.js b/test/parallel/test-https-req-split.js index d7b49b6d71b284..c9707ab43906d4 100644 --- a/test/parallel/test-https-req-split.js +++ b/test/parallel/test-https-req-split.js @@ -33,10 +33,10 @@ server.on('upgrade', function(req, socket, upgrade) { seen_req = true; }); -server.listen(common.PORT, function() { +server.listen(0, function() { var req = https.request({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, agent: false, headers: { Connection: 'Upgrade', diff --git a/test/parallel/test-https-resume-after-renew.js b/test/parallel/test-https-resume-after-renew.js index 23626ccb40cb51..a2286f7a94496a 100644 --- a/test/parallel/test-https-resume-after-renew.js +++ b/test/parallel/test-https-resume-after-renew.js @@ -33,7 +33,7 @@ server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) { return [ 1, hmac, aes, newName, newIV ]; }; -server.listen(common.PORT, function() { +server.listen(0, function() { var addr = this.address(); function doReq(callback) { diff --git a/test/parallel/test-https-set-timeout-server.js b/test/parallel/test-https-set-timeout-server.js index 176d056b66cfac..298ec51587b07f 100644 --- a/test/parallel/test-https-set-timeout-server.js +++ b/test/parallel/test-https-set-timeout-server.js @@ -42,18 +42,19 @@ test(function serverTimeout(cb) { var server = https.createServer(serverOptions, function(req, res) { // just do nothing, we should get a timeout event. }); - server.listen(common.PORT); - var s = server.setTimeout(50, function(socket) { - caughtTimeout = true; - socket.destroy(); - server.close(); - cb(); + server.listen(0, function() { + var s = server.setTimeout(50, function(socket) { + caughtTimeout = true; + socket.destroy(); + server.close(); + cb(); + }); + assert.ok(s instanceof https.Server); + https.get({ + port: this.address().port, + rejectUnauthorized: false + }).on('error', function() {}); }); - assert.ok(s instanceof https.Server); - https.get({ - port: common.PORT, - rejectUnauthorized: false - }).on('error', function() {}); }); test(function serverRequestTimeout(cb) { @@ -70,15 +71,16 @@ test(function serverRequestTimeout(cb) { cb(); }); }); - server.listen(common.PORT); - var req = https.request({ - port: common.PORT, - method: 'POST', - rejectUnauthorized: false + server.listen(0, function() { + var req = https.request({ + port: this.address().port, + method: 'POST', + rejectUnauthorized: false + }); + req.on('error', function() {}); + req.write('Hello'); + // req is in progress }); - req.on('error', function() {}); - req.write('Hello'); - // req is in progress }); test(function serverResponseTimeout(cb) { @@ -95,11 +97,12 @@ test(function serverResponseTimeout(cb) { cb(); }); }); - server.listen(common.PORT); - https.get({ - port: common.PORT, - rejectUnauthorized: false - }).on('error', function() {}); + server.listen(0, function() { + https.get({ + port: this.address().port, + rejectUnauthorized: false + }).on('error', function() {}); + }); }); test(function serverRequestNotTimeoutAfterEnd(cb) { @@ -123,11 +126,12 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { server.close(); cb(); }); - server.listen(common.PORT); - https.get({ - port: common.PORT, - rejectUnauthorized: false - }).on('error', function() {}); + server.listen(0, function() { + https.get({ + port: this.address().port, + rejectUnauthorized: false + }).on('error', function() {}); + }); }); test(function serverResponseTimeoutWithPipeline(cb) { @@ -146,16 +150,17 @@ test(function serverResponseTimeoutWithPipeline(cb) { server.close(); cb(); }); - server.listen(common.PORT); - var options = { - port: common.PORT, - allowHalfOpen: true, - rejectUnauthorized: false - }; - var c = tls.connect(options, function() { - c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); - c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n'); - c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n'); + server.listen(0, function() { + var options = { + port: this.address().port, + allowHalfOpen: true, + rejectUnauthorized: false + }; + var c = tls.connect(options, function() { + c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); + c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n'); + c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n'); + }); }); }); @@ -183,14 +188,15 @@ test(function idleTimeout(cb) { server.close(); cb(); }); - server.listen(common.PORT); - var options = { - port: common.PORT, - allowHalfOpen: true, - rejectUnauthorized: false - }; - tls.connect(options, function() { - this.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); - // Keep-Alive + server.listen(0, function() { + var options = { + port: this.address().port, + allowHalfOpen: true, + rejectUnauthorized: false + }; + tls.connect(options, function() { + this.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); + // Keep-Alive + }); }); }); diff --git a/test/parallel/test-https-simple.js b/test/parallel/test-https-simple.js index 14ebb29e2d88ff..0040b9dd054058 100644 --- a/test/parallel/test-https-simple.js +++ b/test/parallel/test-https-simple.js @@ -34,11 +34,11 @@ const serverCallback = common.mustCall(function(req, res) { const server = https.createServer(options, serverCallback); -server.listen(common.PORT, function() { +server.listen(0, function() { // Do a request ignoring the unauthorized server certs const noCertCheckOptions = { hostname: '127.0.0.1', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', rejectUnauthorized: false @@ -65,7 +65,7 @@ server.listen(common.PORT, function() { // Do a request that throws error due to the invalid server certs const checkCertOptions = { hostname: '127.0.0.1', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET' }; diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js index 0306c659026dfd..70013d1770ff98 100644 --- a/test/parallel/test-https-socket-options.js +++ b/test/parallel/test-https-socket-options.js @@ -27,9 +27,9 @@ var server_http = http.createServer(function(req, res) { }); -server_http.listen(common.PORT, function() { +server_http.listen(0, function() { var req = http.request({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function(res) { server_http.close(); @@ -51,9 +51,9 @@ var server_https = https.createServer(options, function(req, res) { res.end(body); }); -server_https.listen(common.PORT + 1, function() { +server_https.listen(0, function() { var req = https.request({ - port: common.PORT + 1, + port: this.address().port, rejectUnauthorized: false }, function(res) { server_https.close(); diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js index 9f845470b0f2e9..639892f1a10bc4 100644 --- a/test/parallel/test-https-strict.js +++ b/test/parallel/test-https-strict.js @@ -65,13 +65,9 @@ var server3 = server(options3); var listenWait = 0; -var port = common.PORT; -var port1 = port++; -var port2 = port++; -var port3 = port++; -server1.listen(port1, listening()); -server2.listen(port2, listening()); -server3.listen(port3, listening()); +server1.listen(0, listening()); +server2.listen(0, listening()); +server3.listen(0, listening()); var responseErrors = {}; var expectResponseCount = 0; @@ -131,9 +127,9 @@ function makeReq(path, port, error, host, ca) { } var req = https.get(options); expectResponseCount++; - var server = port === port1 ? server1 - : port === port2 ? server2 - : port === port3 ? server3 + var server = port === server1.address().port ? server1 + : port === server2.address().port ? server2 + : port === server3.address().port ? server3 : null; if (!server) throw new Error('invalid port: ' + port); @@ -155,6 +151,9 @@ function makeReq(path, port, error, host, ca) { function allListening() { // ok, ready to start the tests! + const port1 = server1.address().port; + const port2 = server2.address().port; + const port3 = server3.address().port; // server1: host 'agent1', signed by ca1 makeReq('/inv1', port1, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); diff --git a/test/parallel/test-https-timeout-server-2.js b/test/parallel/test-https-timeout-server-2.js index f543150de7e118..07b7984f2d644b 100644 --- a/test/parallel/test-https-timeout-server-2.js +++ b/test/parallel/test-https-timeout-server-2.js @@ -27,10 +27,10 @@ server.on('secureConnection', function(cleartext) { assert.ok(s instanceof tls.TLSSocket); }); -server.listen(common.PORT, function() { +server.listen(0, function() { tls.connect({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); }); diff --git a/test/parallel/test-https-timeout-server.js b/test/parallel/test-https-timeout-server.js index 8e362da82f8119..0edfc8a65c1c54 100644 --- a/test/parallel/test-https-timeout-server.js +++ b/test/parallel/test-https-timeout-server.js @@ -34,6 +34,6 @@ server.on('clientError', function(err, conn) { clientErrors++; }); -server.listen(common.PORT, function() { - net.connect({ host: '127.0.0.1', port: common.PORT }); +server.listen(0, function() { + net.connect({ host: '127.0.0.1', port: this.address().port }); }); diff --git a/test/parallel/test-https-timeout.js b/test/parallel/test-https-timeout.js index 20ee1d6868fa46..865c15165e2460 100644 --- a/test/parallel/test-https-timeout.js +++ b/test/parallel/test-https-timeout.js @@ -17,10 +17,10 @@ var options = { // a server that never replies var server = https.createServer(options, function() { console.log('Got request. Doing nothing.'); -}).listen(common.PORT, function() { +}).listen(0, function() { var req = https.request({ host: 'localhost', - port: common.PORT, + port: this.address().port, path: '/', method: 'GET', rejectUnauthorized: false diff --git a/test/parallel/test-https-truncate.js b/test/parallel/test-https-truncate.js index c9bf1766a2b360..6baf77d0fbbef2 100644 --- a/test/parallel/test-https-truncate.js +++ b/test/parallel/test-https-truncate.js @@ -13,8 +13,6 @@ var fs = require('fs'); var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); -var PORT = common.PORT; - // number of bytes discovered empirically to trigger the bug var data = new Buffer(1024 * 32 + 1); @@ -29,8 +27,8 @@ function httpsTest() { server.close(); }); - server.listen(PORT, function() { - var opts = { port: PORT, rejectUnauthorized: false }; + server.listen(0, function() { + var opts = { port: this.address().port, rejectUnauthorized: false }; https.get(opts).on('response', function(res) { test(res); }); diff --git a/test/parallel/test-listen-fd-cluster.js b/test/parallel/test-listen-fd-cluster.js index 92aadfd49f8acd..606109030b51d0 100644 --- a/test/parallel/test-listen-fd-cluster.js +++ b/test/parallel/test-listen-fd-cluster.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); -var PORT = common.PORT; var cluster = require('cluster'); console.error('Cluster listen fd test', process.argv[2] || 'runner'); @@ -35,11 +34,11 @@ process.on('exit', function() { // server handles to stdio fd's is NOT a good or reliable way to do // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. -test(function(parent) { +test(function(parent, port) { // now make sure that we can request to the worker, then kill it. http.get({ server: 'localhost', - port: PORT, + port: port, path: '/', }).on('response', function(res) { var s = ''; @@ -65,8 +64,9 @@ function test(cb) { var server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); - }).listen(PORT, function() { - console.error('server listening on %d', PORT); + }).listen(0, function() { + const port = this.address().port; + console.error('server listening on %d', port); var spawn = require('child_process').spawn; var master = spawn(process.execPath, [__filename, 'master'], { @@ -89,7 +89,7 @@ function test(cb) { console.error('master spawned'); master.on('message', function(msg) { if (msg === 'started worker') { - cb(master); + cb(master, port); } }); }); diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js index abe3b7ca5126b9..8469a6132d513d 100644 --- a/test/parallel/test-listen-fd-detached-inherit.js +++ b/test/parallel/test-listen-fd-detached-inherit.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); -var PORT = common.PORT; var spawn = require('child_process').spawn; if (common.isWindows) { @@ -38,7 +37,7 @@ function test() { // now make sure that we can request to the child, then kill it. http.get({ server: 'localhost', - port: PORT, + port: child.port, path: '/', }).on('response', function(res) { var s = ''; @@ -60,21 +59,21 @@ function test() { } } -// Listen on PORT, and then pass the handle to the detached child. +// Listen on port, and then pass the handle to the detached child. // Then output the child's pid, and immediately exit. function parent() { var server = net.createServer(function(conn) { conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n'); throw new Error('Should not see connections on parent'); - }).listen(PORT, function() { - console.error('server listening on %d', PORT); + }).listen(0, function() { + console.error('server listening on %d', this.address().port); var child = spawn(process.execPath, [__filename, 'child'], { stdio: [ 0, 1, 2, server._handle ], detached: true }); - console.log('%j\n', { pid: child.pid }); + console.log('%j\n', { pid: child.pid, port: this.address().port }); // Now close the parent, so that the child is the only thing // referencing that handle. Note that connections will still diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js index 1bb1a7f13336a5..6bbf6045715ba9 100644 --- a/test/parallel/test-listen-fd-detached.js +++ b/test/parallel/test-listen-fd-detached.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); -var PORT = common.PORT; var spawn = require('child_process').spawn; if (common.isWindows) { @@ -38,7 +37,7 @@ function test() { // now make sure that we can request to the child, then kill it. http.get({ server: 'localhost', - port: PORT, + port: child.port, path: '/', }).on('response', function(res) { var s = ''; @@ -64,8 +63,8 @@ function parent() { var server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); - }).listen(PORT, function() { - console.error('server listening on %d', PORT); + }).listen(0, function() { + console.error('server listening on %d', this.address().port); var spawn = require('child_process').spawn; var child = spawn(process.execPath, [__filename, 'child'], { @@ -73,7 +72,7 @@ function parent() { detached: true }); - console.log('%j\n', { pid: child.pid }); + console.log('%j\n', { pid: child.pid, port: this.address().port }); // Now close the parent, so that the child is the only thing // referencing that handle. Note that connections will still diff --git a/test/parallel/test-listen-fd-server.js b/test/parallel/test-listen-fd-server.js index 25a5393bd4a2fb..eda75e5c723261 100644 --- a/test/parallel/test-listen-fd-server.js +++ b/test/parallel/test-listen-fd-server.js @@ -3,7 +3,6 @@ var common = require('../common'); var assert = require('assert'); var http = require('http'); var net = require('net'); -var PORT = common.PORT; if (common.isWindows) { common.skip('This test is disabled on windows.'); @@ -25,11 +24,11 @@ process.on('exit', function() { // server handles to stdio fd's is NOT a good or reliable way to do // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. -test(function(child) { +test(function(child, port) { // now make sure that we can request to the child, then kill it. http.get({ server: 'localhost', - port: PORT, + port: port, path: '/', }).on('response', function(res) { var s = ''; @@ -71,8 +70,9 @@ function test(cb) { var server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); - }).listen(PORT, function() { - console.error('server listening on %d', PORT); + }).listen(0, function() { + const port = this.address().port; + console.error('server listening on %d', port); var spawn = require('child_process').spawn; var child = spawn(process.execPath, [__filename, 'child'], { @@ -88,7 +88,7 @@ function test(cb) { child.on('message', function(msg) { if (msg === 'listening') { - cb(child); + cb(child, port); } }); }); diff --git a/test/parallel/test-net-after-close.js b/test/parallel/test-net-after-close.js index 223417111600a1..05782477891ec9 100644 --- a/test/parallel/test-net-after-close.js +++ b/test/parallel/test-net-after-close.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var closed = false; @@ -9,8 +9,8 @@ var server = net.createServer(function(s) { s.end(); }); -server.listen(common.PORT, function() { - var c = net.createConnection(common.PORT); +server.listen(0, function() { + var c = net.createConnection(this.address().port); c.on('close', function() { console.error('connection closed'); assert.strictEqual(c._handle, null); diff --git a/test/parallel/test-net-binary.js b/test/parallel/test-net-binary.js index 484ae60c111b3a..9a966c64281080 100644 --- a/test/parallel/test-net-binary.js +++ b/test/parallel/test-net-binary.js @@ -1,5 +1,5 @@ /* eslint-disable strict */ -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -22,14 +22,14 @@ var echoServer = net.Server(function(connection) { connection.end(); }); }); -echoServer.listen(common.PORT); +echoServer.listen(0); var recv = ''; echoServer.on('listening', function() { var j = 0; var c = net.createConnection({ - port: common.PORT + port: this.address().port }); c.setEncoding('binary'); diff --git a/test/parallel/test-net-bind-twice.js b/test/parallel/test-net-bind-twice.js index ca4f554d30ca16..d8ea1b34a5ca36 100644 --- a/test/parallel/test-net-bind-twice.js +++ b/test/parallel/test-net-bind-twice.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -14,13 +14,13 @@ function dontCall() { } var server1 = net.createServer(dontCall); -server1.listen(common.PORT, '127.0.0.1', function() {}); +server1.listen(0, '127.0.0.1', function() { + var server2 = net.createServer(dontCall); + server2.listen(this.address().port, '127.0.0.1', dontCall); -var server2 = net.createServer(dontCall); -server2.listen(common.PORT, '127.0.0.1', dontCall); - -server2.on('error', function(e) { - assert.equal(e.code, 'EADDRINUSE'); - server1.close(); - gotError = true; + server2.on('error', function(e) { + assert.equal(e.code, 'EADDRINUSE'); + server1.close(); + gotError = true; + }); }); diff --git a/test/parallel/test-net-buffersize.js b/test/parallel/test-net-buffersize.js index fcf0331c4ed500..872d8de7b42f3b 100644 --- a/test/parallel/test-net-buffersize.js +++ b/test/parallel/test-net-buffersize.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -15,8 +15,8 @@ var server = net.createServer(function(socket) { }); }); -server.listen(common.PORT, function() { - var client = net.connect(common.PORT); +server.listen(0, function() { + var client = net.connect(this.address().port); client.on('finish', function() { assert.strictEqual(client.bufferSize, 0); diff --git a/test/parallel/test-net-bytes-read.js b/test/parallel/test-net-bytes-read.js index 5473ca96ca2cb6..a06117749da596 100644 --- a/test/parallel/test-net-bytes-read.js +++ b/test/parallel/test-net-bytes-read.js @@ -9,7 +9,7 @@ const big = Buffer(1024 * 1024); const server = net.createServer((socket) => { socket.end(big); server.close(); -}).listen(common.PORT, () => { +}).listen(0, () => { let prev = 0; function checkRaise(value) { @@ -17,7 +17,7 @@ const server = net.createServer((socket) => { prev = value; } - const socket = net.connect(common.PORT, () => { + const socket = net.connect(server.address().port, () => { socket.on('data', (chunk) => { checkRaise(socket.bytesRead); }); diff --git a/test/parallel/test-net-bytes-stats.js b/test/parallel/test-net-bytes-stats.js index 4e0a2e4001a452..a8643b03b97250 100644 --- a/test/parallel/test-net-bytes-stats.js +++ b/test/parallel/test-net-bytes-stats.js @@ -1,9 +1,8 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); -var tcpPort = common.PORT; var bytesRead = 0; var bytesWritten = 0; var count = 0; @@ -20,9 +19,9 @@ var tcp = net.Server(function(s) { }); }); -tcp.listen(common.PORT, function doTest() { +tcp.listen(0, function doTest() { console.error('listening'); - var socket = net.createConnection(tcpPort); + var socket = net.createConnection(this.address().port); socket.on('connect', function() { count++; @@ -45,7 +44,7 @@ tcp.listen(common.PORT, function doTest() { console.log('Bytes written: ' + bytesWritten); if (count < 2) { console.error('RECONNECTING'); - socket.connect(tcpPort); + socket.connect(tcp.address().port); } else { tcp.close(); } diff --git a/test/parallel/test-net-can-reset-timeout.js b/test/parallel/test-net-can-reset-timeout.js index 9fd7da4bb498ff..a63932e1ad5c1e 100644 --- a/test/parallel/test-net-can-reset-timeout.js +++ b/test/parallel/test-net-can-reset-timeout.js @@ -1,6 +1,6 @@ 'use strict'; +require('../common'); var net = require('net'); -var common = require('../common'); var assert = require('assert'); var timeoutCount = 0; @@ -25,8 +25,8 @@ var server = net.createServer(function(stream) { }); }); -server.listen(common.PORT, function() { - var c = net.createConnection(common.PORT); +server.listen(0, function() { + var c = net.createConnection(this.address().port); c.on('data', function() { c.end(); diff --git a/test/parallel/test-net-connect-buffer.js b/test/parallel/test-net-connect-buffer.js index 304401f56ef50d..2057fadd38ec76 100644 --- a/test/parallel/test-net-connect-buffer.js +++ b/test/parallel/test-net-connect-buffer.js @@ -1,9 +1,8 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); -var tcpPort = common.PORT; var dataWritten = false; var connectHappened = false; @@ -30,12 +29,12 @@ var tcp = net.Server(function(s) { }); }); -tcp.listen(common.PORT, function() { +tcp.listen(0, function() { var socket = net.Stream({ highWaterMark: 0 }); console.log('Connecting to socket '); - socket.connect(tcpPort, function() { + socket.connect(this.address().port, function() { console.log('socket connected'); connectHappened = true; }); diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index f84c02678ff654..7f638d66f59508 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -19,12 +19,12 @@ const server = net.createServer({allowHalfOpen: true}, function(socket) { socket.end(); }); -server.listen(common.PORT, '::1', tryConnect); +server.listen(0, '::1', tryConnect); function tryConnect() { const client = net.connect({ host: host, - port: common.PORT, + port: server.address().port, family: 6, allowHalfOpen: true }, function() { diff --git a/test/parallel/test-net-connect-options.js b/test/parallel/test-net-connect-options.js index ac8bbcefc03e4c..302a8a9bbc0f89 100644 --- a/test/parallel/test-net-connect-options.js +++ b/test/parallel/test-net-connect-options.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -14,10 +14,10 @@ var server = net.createServer({allowHalfOpen: true}, function(socket) { socket.end(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var client = net.connect({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, allowHalfOpen: true }, function() { console.error('client connect cb'); diff --git a/test/parallel/test-net-connect-paused-connection.js b/test/parallel/test-net-connect-paused-connection.js index bb258ef009a657..857b287b62174f 100644 --- a/test/parallel/test-net-connect-paused-connection.js +++ b/test/parallel/test-net-connect-paused-connection.js @@ -1,15 +1,15 @@ 'use strict'; +require('../common'); var assert = require('assert'); -var common = require('../common'); var net = require('net'); net.createServer(function(conn) { conn.unref(); -}).listen(common.PORT).unref(); +}).listen(0, function() { + net.connect(this.address().port, 'localhost').pause(); -net.connect(common.PORT, 'localhost').pause(); - -setTimeout(function() { - assert.fail(null, null, 'expected to exit'); -}, 1000).unref(); + setTimeout(function() { + assert.fail(null, null, 'expected to exit'); + }, 1000).unref(); +}).unref(); diff --git a/test/parallel/test-net-create-connection.js b/test/parallel/test-net-create-connection.js index 38452be6e6a954..b61e1d1ffc0ad5 100644 --- a/test/parallel/test-net-create-connection.js +++ b/test/parallel/test-net-create-connection.js @@ -1,21 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +require('../common'); +const assert = require('assert'); +const net = require('net'); -var tcpPort = common.PORT; -var expectedConnections = 7; +const expectedConnections = 7; var clientConnected = 0; var serverConnected = 0; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.end(); if (++serverConnected === expectedConnections) { server.close(); } }); -server.listen(tcpPort, 'localhost', function() { +server.listen(0, 'localhost', function() { function cb() { ++clientConnected; } @@ -28,13 +27,13 @@ server.listen(tcpPort, 'localhost', function() { }); } - net.createConnection(tcpPort).on('connect', cb); - net.createConnection(tcpPort, 'localhost').on('connect', cb); - net.createConnection(tcpPort, cb); - net.createConnection(tcpPort, 'localhost', cb); - net.createConnection(tcpPort + '', 'localhost', cb); - net.createConnection({port: tcpPort + ''}).on('connect', cb); - net.createConnection({port: '0x' + tcpPort.toString(16)}, cb); + net.createConnection(this.address().port).on('connect', cb); + net.createConnection(this.address().port, 'localhost').on('connect', cb); + net.createConnection(this.address().port, cb); + net.createConnection(this.address().port, 'localhost', cb); + net.createConnection(this.address().port + '', 'localhost', cb); + net.createConnection({port: this.address().port + ''}).on('connect', cb); + net.createConnection({port: '0x' + this.address().port.toString(16)}, cb); fail({ port: true diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js index a2ce3966ae1237..12dc4d68d2ebe5 100644 --- a/test/parallel/test-net-dns-custom-lookup.js +++ b/test/parallel/test-net-dns-custom-lookup.js @@ -12,9 +12,9 @@ function check(addressType, cb) { }); var address = addressType === 4 ? common.localhostIPv4 : '::1'; - server.listen(common.PORT, address, function() { + server.listen(0, address, function() { net.connect({ - port: common.PORT, + port: this.address().port, host: 'localhost', family: addressType, lookup: lookup diff --git a/test/parallel/test-net-dns-lookup-skip.js b/test/parallel/test-net-dns-lookup-skip.js index 9b3ae15fc393ae..513a6d0422498e 100644 --- a/test/parallel/test-net-dns-lookup-skip.js +++ b/test/parallel/test-net-dns-lookup-skip.js @@ -9,8 +9,8 @@ function check(addressType) { }); var address = addressType === 4 ? '127.0.0.1' : '::1'; - server.listen(common.PORT, address, function() { - net.connect(common.PORT, address).on('lookup', common.fail); + server.listen(0, address, function() { + net.connect(this.address().port, address).on('lookup', common.fail); }); } diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 2bcff9143c092d..7a0468fd0e07de 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var ok = false; @@ -9,13 +9,14 @@ var server = net.createServer(function(client) { server.close(); }); -server.listen(common.PORT, '127.0.0.1', function() { - net.connect(common.PORT, 'localhost').on('lookup', function(err, ip, type) { - assert.equal(err, null); - assert.equal(ip, '127.0.0.1'); - assert.equal(type, '4'); - ok = true; - }); +server.listen(0, '127.0.0.1', function() { + net.connect(this.address().port, 'localhost') + .on('lookup', function(err, ip, type) { + assert.equal(err, null); + assert.equal(ip, '127.0.0.1'); + assert.equal(type, '4'); + ok = true; + }); }); process.on('exit', function() { diff --git a/test/parallel/test-net-during-close.js b/test/parallel/test-net-during-close.js index a2fd424e0e83c0..24510acac753b7 100644 --- a/test/parallel/test-net-during-close.js +++ b/test/parallel/test-net-during-close.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var accessedProperties = false; @@ -8,8 +8,8 @@ var server = net.createServer(function(socket) { socket.end(); }); -server.listen(common.PORT, function() { - var client = net.createConnection(common.PORT); +server.listen(0, function() { + var client = net.createConnection(this.address().port); server.close(); // server connection event has not yet fired // client is still attempting to connect diff --git a/test/parallel/test-net-eaddrinuse.js b/test/parallel/test-net-eaddrinuse.js index c1797b7369d5ed..4741c820797154 100644 --- a/test/parallel/test-net-eaddrinuse.js +++ b/test/parallel/test-net-eaddrinuse.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -7,9 +7,10 @@ var server1 = net.createServer(function(socket) { }); var server2 = net.createServer(function(socket) { }); -server1.listen(common.PORT); -server2.on('error', function(error) { - assert.equal(true, error.message.indexOf('EADDRINUSE') >= 0); - server1.close(); +server1.listen(0, function() { + server2.on('error', function(error) { + assert.equal(true, error.message.indexOf('EADDRINUSE') >= 0); + server1.close(); + }); + server2.listen(this.address().port); }); -server2.listen(common.PORT); diff --git a/test/parallel/test-net-error-twice.js b/test/parallel/test-net-error-twice.js index 28e90ddd611ba9..be7d6159e9654a 100644 --- a/test/parallel/test-net-error-twice.js +++ b/test/parallel/test-net-error-twice.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -29,8 +29,8 @@ var srv = net.createServer(function onConnection(conn) { }); serverSocket = conn; ready(); -}).listen(common.PORT, function() { - var client = net.connect({ port: common.PORT }); +}).listen(0, function() { + var client = net.connect({ port: this.address().port }); client.on('connect', function() { clientSocket = client; diff --git a/test/parallel/test-net-keepalive.js b/test/parallel/test-net-keepalive.js index b05537ba052e10..d414393a9346cd 100644 --- a/test/parallel/test-net-keepalive.js +++ b/test/parallel/test-net-keepalive.js @@ -23,9 +23,9 @@ var echoServer = net.createServer(function(connection) { connection.end(); }); }); -echoServer.listen(common.PORT); +echoServer.listen(0); echoServer.on('listening', function() { - clientConnection = net.createConnection(common.PORT); + clientConnection = net.createConnection(this.address().port); clientConnection.setTimeout(0); }); diff --git a/test/parallel/test-net-large-string.js b/test/parallel/test-net-large-string.js index 26227c8e759787..8feb35c067d0d4 100644 --- a/test/parallel/test-net-large-string.js +++ b/test/parallel/test-net-large-string.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -18,8 +18,8 @@ var server = net.createServer(function(socket) { }); }); -server.listen(common.PORT, function() { - var client = net.createConnection(common.PORT); +server.listen(0, function() { + var client = net.createConnection(this.address().port); client.on('end', function() { server.close(); }); diff --git a/test/parallel/test-net-listen-close-server-callback-is-not-function.js b/test/parallel/test-net-listen-close-server-callback-is-not-function.js index 7450cb16fc7943..b0fe8c2fe15b71 100644 --- a/test/parallel/test-net-listen-close-server-callback-is-not-function.js +++ b/test/parallel/test-net-listen-close-server-callback-is-not-function.js @@ -1,6 +1,6 @@ 'use strict'; +require('../common'); var assert = require('assert'); -var common = require('../common'); var net = require('net'); var server = net.createServer(assert.fail); @@ -10,7 +10,7 @@ server.on('close', function() { ++closeEvents; }); -server.listen(common.PORT, function() { +server.listen(0, function() { assert(false); }); diff --git a/test/parallel/test-net-listen-close-server.js b/test/parallel/test-net-listen-close-server.js index 9cde6df1645d01..47da53de7dae6f 100644 --- a/test/parallel/test-net-listen-close-server.js +++ b/test/parallel/test-net-listen-close-server.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var server = net.createServer(function(socket) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { assert(false); }); server.on('error', function(error) { diff --git a/test/parallel/test-net-listen-port-option.js b/test/parallel/test-net-listen-port-option.js index 5c3bc8eb7956ae..4e766c5e54018a 100644 --- a/test/parallel/test-net-listen-port-option.js +++ b/test/parallel/test-net-listen-port-option.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); function close() { this.close(); } net.Server().listen({ port: undefined }, close); -net.Server().listen({ port: '' + common.PORT }, close); +net.Server().listen({ port: '0' }, close); [ 'nan', -1, diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js index 728993ee1bb023..2f25f53fa82670 100644 --- a/test/parallel/test-net-local-address-port.js +++ b/test/parallel/test-net-local-address-port.js @@ -7,16 +7,16 @@ var conns = 0; var server = net.createServer(function(socket) { conns++; - assert.equal(common.localhostIPv4, socket.localAddress); - assert.equal(socket.localPort, common.PORT); + assert.equal(socket.localAddress, common.localhostIPv4); + assert.equal(socket.localPort, this.address().port); socket.on('end', function() { server.close(); }); socket.resume(); }); -server.listen(common.PORT, common.localhostIPv4, function() { - var client = net.createConnection(common.PORT, common.localhostIPv4); +server.listen(0, common.localhostIPv4, function() { + var client = net.createConnection(this.address().port, common.localhostIPv4); client.on('connect', function() { client.end(); }); diff --git a/test/parallel/test-net-localport.js b/test/parallel/test-net-localport.js index 09b6627c79ce47..4af9dcfd08aeca 100644 --- a/test/parallel/test-net-localport.js +++ b/test/parallel/test-net-localport.js @@ -5,17 +5,17 @@ var net = require('net'); var server = net.createServer(function(socket) { console.log(socket.remotePort); - assert.strictEqual(socket.remotePort, common.PORT + 1); + assert.strictEqual(socket.remotePort, common.PORT); socket.end(); socket.on('close', function() { server.close(); }); -}).listen(common.PORT).on('listening', function() { +}).listen(0).on('listening', function() { var client = net.connect({ host: '127.0.0.1', - port: common.PORT, - localPort: common.PORT + 1, + port: this.address().port, + localPort: common.PORT, }).on('connect', function() { - assert.strictEqual(client.localPort, common.PORT + 1); + assert.strictEqual(client.localPort, common.PORT); }); }); diff --git a/test/parallel/test-net-pause-resume-connecting.js b/test/parallel/test-net-pause-resume-connecting.js index 6be20cecb91159..a96a94e22f315c 100644 --- a/test/parallel/test-net-pause-resume-connecting.js +++ b/test/parallel/test-net-pause-resume-connecting.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -17,61 +17,60 @@ var server = net.createServer(function(conn) { server.close(); }); -server.listen(common.PORT); +server.listen(0, function() { + // Client 1 + conn = require('net').createConnection(this.address().port, 'localhost'); + conn.resume(); + conn.on('data', onDataOk); -// Client 1 -conn = require('net').createConnection(common.PORT, 'localhost'); -conn.resume(); -conn.on('data', onDataOk); + // Client 2 + conn = require('net').createConnection(this.address().port, 'localhost'); + conn.pause(); + conn.resume(); + conn.on('data', onDataOk); -// Client 2 -conn = require('net').createConnection(common.PORT, 'localhost'); -conn.pause(); -conn.resume(); -conn.on('data', onDataOk); + // Client 3 + conn = require('net').createConnection(this.address().port, 'localhost'); + conn.pause(); + conn.on('data', onDataError); + scheduleTearDown(conn); -// Client 3 -conn = require('net').createConnection(common.PORT, 'localhost'); -conn.pause(); -conn.on('data', onDataError); -scheduleTearDown(conn); + // Client 4 + conn = require('net').createConnection(this.address().port, 'localhost'); + conn.resume(); + conn.pause(); + conn.resume(); + conn.on('data', onDataOk); -// Client 4 -conn = require('net').createConnection(common.PORT, 'localhost'); -conn.resume(); -conn.pause(); -conn.resume(); -conn.on('data', onDataOk); + // Client 5 + conn = require('net').createConnection(this.address().port, 'localhost'); + conn.resume(); + conn.resume(); + conn.pause(); + conn.on('data', onDataError); + scheduleTearDown(conn); -// Client 5 -conn = require('net').createConnection(common.PORT, 'localhost'); -conn.resume(); -conn.resume(); -conn.pause(); -conn.on('data', onDataError); -scheduleTearDown(conn); + // Client helper functions + function onDataError() { + assert(false); + } + function onDataOk() { + dataEvents++; + } -// Client helper functions -function onDataError() { - assert(false); -} - -function onDataOk() { - dataEvents++; -} - -function scheduleTearDown(conn) { - setTimeout(function() { - conn.removeAllListeners('data'); - conn.resume(); - }, 100); -} + function scheduleTearDown(conn) { + setTimeout(function() { + conn.removeAllListeners('data'); + conn.resume(); + }, 100); + } +}); // Exit sanity checks diff --git a/test/parallel/test-net-persistent-keepalive.js b/test/parallel/test-net-persistent-keepalive.js index fccfb69c4b19f3..d1dfb370167714 100644 --- a/test/parallel/test-net-persistent-keepalive.js +++ b/test/parallel/test-net-persistent-keepalive.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -21,7 +21,7 @@ var echoServer = net.createServer(function(connection) { connection.end(); }); }); -echoServer.listen(common.PORT); +echoServer.listen(0); echoServer.on('listening', function() { clientConnection = new net.Socket(); @@ -29,6 +29,6 @@ echoServer.on('listening', function() { // and make sure it persists var s = clientConnection.setKeepAlive(true, 400); assert.ok(s instanceof net.Socket); - clientConnection.connect(common.PORT); + clientConnection.connect(this.address().port); clientConnection.setTimeout(0); }); diff --git a/test/parallel/test-net-persistent-nodelay.js b/test/parallel/test-net-persistent-nodelay.js index e120305b3a62eb..e23b8718dfee6d 100644 --- a/test/parallel/test-net-persistent-nodelay.js +++ b/test/parallel/test-net-persistent-nodelay.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var TCPWrap = process.binding('tcp_wrap').TCP; @@ -7,7 +7,7 @@ var TCPWrap = process.binding('tcp_wrap').TCP; var echoServer = net.createServer(function(connection) { connection.end(); }); -echoServer.listen(common.PORT); +echoServer.listen(0); var callCount = 0; @@ -26,7 +26,7 @@ echoServer.on('listening', function() { var s = sock1.setNoDelay(); assert.ok(s instanceof net.Socket); - sock1.connect(common.PORT); + sock1.connect(this.address().port); sock1.on('end', function() { assert.equal(callCount, 1); echoServer.close(); diff --git a/test/parallel/test-net-persistent-ref-unref.js b/test/parallel/test-net-persistent-ref-unref.js index b3ea0969f39961..32782e7c591444 100644 --- a/test/parallel/test-net-persistent-ref-unref.js +++ b/test/parallel/test-net-persistent-ref-unref.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var TCPWrap = process.binding('tcp_wrap').TCP; @@ -25,13 +25,13 @@ TCPWrap.prototype.unref = function() { assert.equal(refCount, -1); }; -echoServer.listen(common.PORT); +echoServer.listen(0); echoServer.on('listening', function() { var sock = new net.Socket(); sock.unref(); sock.ref(); - sock.connect(common.PORT); + sock.connect(this.address().port); sock.on('end', function() { assert.equal(refCount, 0); echoServer.close(); diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index e27ae2f1819fa6..33fbafd8f97861 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -49,7 +49,7 @@ function pingPongTest(port, host) { }); socket.on('close', function() { - console.log('server socket.endd'); + console.log('server socket.end'); assert.equal(false, socket.writable); assert.equal(false, socket.readable); socket.server.close(); @@ -58,7 +58,9 @@ function pingPongTest(port, host) { server.listen(port, host, function() { - console.log('server listening on ' + port + ' ' + host); + if (this.address().port) + port = this.address().port; + console.log(`server listening on ${port} ${host}`); var client = net.createConnection(port, host); @@ -108,10 +110,10 @@ function pingPongTest(port, host) { /* All are run at once, so run on different ports */ common.refreshTmpDir(); pingPongTest(common.PIPE); -pingPongTest(common.PORT); -pingPongTest(common.PORT + 1, 'localhost'); +pingPongTest(0); +pingPongTest(0, 'localhost'); if (common.hasIPv6) - pingPongTest(common.PORT + 2, '::1'); + pingPongTest(0, '::1'); process.on('exit', function() { if (common.hasIPv6) diff --git a/test/parallel/test-net-reconnect.js b/test/parallel/test-net-reconnect.js index f8cdcbdc4e76dd..519bf09bc711da 100644 --- a/test/parallel/test-net-reconnect.js +++ b/test/parallel/test-net-reconnect.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -27,9 +27,9 @@ var server = net.createServer(function(socket) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { console.log('SERVER listening'); - var client = net.createConnection(common.PORT); + var client = net.createConnection(this.address().port); client.setEncoding('UTF8'); @@ -54,7 +54,7 @@ server.listen(common.PORT, function() { console.log('CLIENT disconnect'); assert.equal(false, had_error); if (disconnect_count++ < N) - client.connect(common.PORT); // reconnect + client.connect(server.address().port); // reconnect else server.close(); }); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 11d753ea460b79..beb5625ee11858 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -17,7 +17,7 @@ var server = net.createServer(function(socket) { assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress)); assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily)); assert.ok(socket.remotePort); - assert.notEqual(socket.remotePort, common.PORT); + assert.notEqual(socket.remotePort, this.address().port); socket.on('end', function() { if (++conns_closed == 2) server.close(); }); @@ -28,13 +28,13 @@ var server = net.createServer(function(socket) { socket.resume(); }); -server.listen(common.PORT, 'localhost', function() { - var client = net.createConnection(common.PORT, 'localhost'); - var client2 = net.createConnection(common.PORT); +server.listen(0, 'localhost', function() { + var client = net.createConnection(this.address().port, 'localhost'); + var client2 = net.createConnection(this.address().port); client.on('connect', function() { assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress)); assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily)); - assert.equal(common.PORT, client.remotePort); + assert.equal(client.remotePort, server.address().port); client.end(); }); client.on('close', function() { @@ -44,7 +44,7 @@ server.listen(common.PORT, 'localhost', function() { client2.on('connect', function() { assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress)); assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily)); - assert.equal(common.PORT, client2.remotePort); + assert.equal(client2.remotePort, server.address().port); client2.end(); }); client2.on('close', function() { diff --git a/test/parallel/test-net-server-close.js b/test/parallel/test-net-server-close.js index 446b835a4c67df..006ca529c79ab3 100644 --- a/test/parallel/test-net-server-close.js +++ b/test/parallel/test-net-server-close.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -32,7 +32,7 @@ server.on('close', function() { events.push('server'); }); -server.listen(common.PORT, function() { - net.createConnection(common.PORT); - net.createConnection(common.PORT); +server.listen(0, function() { + net.createConnection(this.address().port); + net.createConnection(this.address().port); }); diff --git a/test/parallel/test-net-server-listen-remove-callback.js b/test/parallel/test-net-server-listen-remove-callback.js index a7d54081a6bb03..9bdfd628072798 100644 --- a/test/parallel/test-net-server-listen-remove-callback.js +++ b/test/parallel/test-net-server-listen-remove-callback.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -12,12 +12,12 @@ server.on('close', function() { assert.equal(0, listeners.length); }); -server.listen(common.PORT, function() { +server.listen(0, function() { server.close(); }); server.once('close', function() { - server.listen(common.PORT + 1, function() { + server.listen(0, function() { server.close(); }); }); diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js index 1569e859417f5a..fd1c50b9698294 100644 --- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js +++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -21,7 +21,7 @@ var createConnection = function(index) { console.error('creating connection ' + index); return new Promise(function(resolve, reject) { - var connection = net.createConnection(common.PORT, function() { + var connection = net.createConnection(server.address().port, function() { var msg = '' + index; console.error('sending message: ' + msg); this.write(msg); @@ -67,7 +67,7 @@ var server = net.createServer(function(socket) { server.maxConnections = 1; -server.listen(common.PORT, function() { +server.listen(0, function() { createConnection(0) .then(createConnection.bind(null, 1)) .then(closeConnection.bind(null, 0)) diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js index 2b418e1c3c7bf4..661c18113b53fd 100644 --- a/test/parallel/test-net-server-max-connections.js +++ b/test/parallel/test-net-server-max-connections.js @@ -19,7 +19,7 @@ var server = net.createServer(function(connection) { waits.push(function() { connection.end(); }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { makeConnection(0); }); @@ -29,7 +29,7 @@ console.error('server.maxConnections = %d', server.maxConnections); function makeConnection(index) { - var c = net.createConnection(common.PORT); + var c = net.createConnection(server.address().port); var gotData = false; c.on('connect', function() { @@ -78,7 +78,7 @@ function makeConnection(index) { // Retry if SmartOS and ECONNREFUSED. See // https://github.com/nodejs/node/issues/2663. if (common.isSunOS && (e.code === 'ECONNREFUSED')) { - c.connect(common.PORT); + c.connect(server.address().port); } console.error('error %d: %s', index, e); }); diff --git a/test/parallel/test-net-server-pause-on-connect.js b/test/parallel/test-net-server-pause-on-connect.js index f13500b3800e7f..798175737b80b3 100644 --- a/test/parallel/test-net-server-pause-on-connect.js +++ b/test/parallel/test-net-server-pause-on-connect.js @@ -37,13 +37,13 @@ const server2ConnHandler = function(socket) { const server2 = net.createServer({pauseOnConnect: false}, server2ConnHandler); -server1.listen(common.PORT, function() { +server1.listen(0, function() { const clientHandler = common.mustCall(function() { - server2.listen(common.PORT + 1, function() { - net.createConnection({port: common.PORT + 1}).write(msg); + server2.listen(0, function() { + net.createConnection({port: this.address().port}).write(msg); }); }); - net.createConnection({port: common.PORT}).write(msg, clientHandler); + net.createConnection({port: this.address().port}).write(msg, clientHandler); }); process.on('exit', function() { diff --git a/test/parallel/test-net-server-try-ports.js b/test/parallel/test-net-server-try-ports.js index 653170ced22415..b0a877cf98f868 100644 --- a/test/parallel/test-net-server-try-ports.js +++ b/test/parallel/test-net-server-try-ports.js @@ -1,7 +1,7 @@ 'use strict'; // This tests binds to one port, then attempts to start a server on that // port. It should be EADDRINUSE but be able to then bind to another port. -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -26,7 +26,7 @@ server2.on('error', function(e) { server2eaddrinuse = true; } - server2.listen(common.PORT + 1, function() { + server2.listen(0, function() { console.error('server2 listening'); server2listening = true; @@ -36,11 +36,11 @@ server2.on('error', function(e) { }); -server1.listen(common.PORT, function() { +server1.listen(0, function() { console.error('server1 listening'); server1listening = true; // This should make server2 emit EADDRINUSE - server2.listen(common.PORT); + server2.listen(this.address().port); }); diff --git a/test/parallel/test-net-server-unref.js b/test/parallel/test-net-server-unref.js index 98e95d6f105a84..50c1a5678535f4 100644 --- a/test/parallel/test-net-server-unref.js +++ b/test/parallel/test-net-server-unref.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var closed = false; var s = net.createServer(); -s.listen(common.PORT); +s.listen(0); s.unref(); setTimeout(function() { diff --git a/test/parallel/test-net-settimeout.js b/test/parallel/test-net-settimeout.js index db0329deea0466..688937fe46300c 100644 --- a/test/parallel/test-net-settimeout.js +++ b/test/parallel/test-net-settimeout.js @@ -12,20 +12,20 @@ const server = net.createServer(common.mustCall((c) => { c.write('hello'); })); -server.listen(common.PORT); - -const socket = net.createConnection(common.PORT, 'localhost'); - -const s = socket.setTimeout(T, () => { - common.fail('Socket timeout event is not expected to fire'); +server.listen(0, function() { + const socket = net.createConnection(this.address().port, 'localhost'); + + const s = socket.setTimeout(T, () => { + common.fail('Socket timeout event is not expected to fire'); + }); + assert.ok(s instanceof net.Socket); + + socket.on('data', common.mustCall(() => { + setTimeout(function() { + socket.destroy(); + server.close(); + }, T * 2); + })); + + socket.setTimeout(0); }); -assert.ok(s instanceof net.Socket); - -socket.on('data', common.mustCall(() => { - setTimeout(function() { - socket.destroy(); - server.close(); - }, T * 2); -})); - -socket.setTimeout(0); diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 2569c363f49ce7..56787dfd494c78 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -24,7 +24,7 @@ server.on('close', common.mustCall(() => { assert.strictEqual(2, conns); })); -server.listen(common.PORT, common.localhostIPv4, connect); +server.listen(0, common.localhostIPv4, connect); function connect() { if (conns === 2) { @@ -34,7 +34,7 @@ function connect() { conns++; client.once('close', connect); - client.connect(common.PORT, common.localhostIPv4, () => { + client.connect(server.address().port, common.localhostIPv4, () => { clientLocalPorts.push(client.localPort); }); } diff --git a/test/parallel/test-net-socket-timeout-unref.js b/test/parallel/test-net-socket-timeout-unref.js index bbc2dffcc15336..fb4f6a658e21d2 100644 --- a/test/parallel/test-net-socket-timeout-unref.js +++ b/test/parallel/test-net-socket-timeout-unref.js @@ -9,7 +9,7 @@ const server = net.createServer(function(c) { c.write('hello'); c.unref(); }); -server.listen(common.PORT); +server.listen(0); server.unref(); var connections = 0; @@ -17,7 +17,7 @@ const sockets = []; const delays = [8, 5, 3, 6, 2, 4]; delays.forEach(function(T) { - const socket = net.createConnection(common.PORT, 'localhost'); + const socket = net.createConnection(server.address().port, 'localhost'); socket.on('connect', common.mustCall(function() { if (++connections === delays.length) { sockets.forEach(function(s) { diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index 7cae61d71bc4a5..cac562c5abb1ab 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -31,8 +31,8 @@ for (let i = 0; i < validDelays.length; i++) { var timedout = false; var server = net.Server(); -server.listen(common.PORT, function() { - var socket = net.createConnection(common.PORT); +server.listen(0, function() { + var socket = net.createConnection(this.address().port); socket.setTimeout(100, function() { timedout = true; socket.destroy(); diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 9075d99471540a..066c43f8903953 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -1,7 +1,6 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); - var net = require('net'); var s = new net.Stream(); @@ -38,8 +37,8 @@ var server = net.createServer(function(socket) { } socket.end(); -}).listen(common.PORT, function() { - var conn = net.connect(common.PORT); +}).listen(0, function() { + var conn = net.connect(this.address().port); conn.on('data', function(buf) { conn.pause(); setTimeout(function() { diff --git a/test/parallel/test-net-sync-cork.js b/test/parallel/test-net-sync-cork.js index a35a74a82153b1..1f82adba5e5e9a 100644 --- a/test/parallel/test-net-sync-cork.js +++ b/test/parallel/test-net-sync-cork.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -9,8 +9,8 @@ const server = net.createServer(handle); const N = 100; const buf = Buffer('aa'); -server.listen(common.PORT, function() { - const conn = net.connect(common.PORT); +server.listen(0, function() { + const conn = net.connect(this.address().port); conn.on('connect', () => { let res = true; diff --git a/test/parallel/test-net-write-after-close.js b/test/parallel/test-net-write-after-close.js index b9516b839263cf..243123da033be4 100644 --- a/test/parallel/test-net-write-after-close.js +++ b/test/parallel/test-net-write-after-close.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -28,8 +28,8 @@ var server = net.createServer(function(socket) { }, 250); }); -server.listen(common.PORT, function() { - var client = net.connect(common.PORT, function() { +server.listen(0, function() { + var client = net.connect(this.address().port, function() { client.end(); }); }); diff --git a/test/parallel/test-net-write-connect-write.js b/test/parallel/test-net-write-connect-write.js index 17b1b576d188be..b8edb0e3b39612 100644 --- a/test/parallel/test-net-write-connect-write.js +++ b/test/parallel/test-net-write-connect-write.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -7,8 +7,8 @@ var received = ''; var server = net.createServer(function(socket) { socket.pipe(socket); -}).listen(common.PORT, function() { - var conn = net.connect(common.PORT); +}).listen(0, function() { + var conn = net.connect(this.address().port); conn.setEncoding('utf8'); conn.write('before'); conn.on('connect', function() { diff --git a/test/parallel/test-net-write-slow.js b/test/parallel/test-net-write-slow.js index 3714ed906e4c71..cde44556e2d5c3 100644 --- a/test/parallel/test-net-write-slow.js +++ b/test/parallel/test-net-write-slow.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -28,8 +28,8 @@ var server = net.createServer(function(socket) { } socket.end(); -}).listen(common.PORT, function() { - var conn = net.connect(common.PORT); +}).listen(0, function() { + var conn = net.connect(this.address().port); conn.on('data', function(buf) { received += buf.length; conn.pause(); diff --git a/test/parallel/test-pipe-file-to-http.js b/test/parallel/test-pipe-file-to-http.js index 06c7d7997e179a..8d804f70b7b0e1 100644 --- a/test/parallel/test-pipe-file-to-http.js +++ b/test/parallel/test-pipe-file-to-http.js @@ -33,7 +33,7 @@ var server = http.createServer(function(req, res) { res.end(); }); }); -server.listen(common.PORT); +server.listen(0); server.on('listening', function() { var cmd = common.ddCommand(filename, 10240); @@ -46,7 +46,7 @@ server.on('listening', function() { function makeRequest() { var req = http.request({ - port: common.PORT, + port: server.address().port, path: '/', method: 'POST' }); diff --git a/test/parallel/test-process-getactivehandles.js b/test/parallel/test-process-getactivehandles.js index e257439f7ba035..a9222c984b30ca 100644 --- a/test/parallel/test-process-getactivehandles.js +++ b/test/parallel/test-process-getactivehandles.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); const NUM = 8; @@ -10,12 +10,12 @@ var clients_counter = 0; const server = net.createServer(function listener(c) { connections.push(c); -}).listen(common.PORT, makeConnection); +}).listen(0, makeConnection); function makeConnection() { if (clients_counter >= NUM) return; - net.connect(common.PORT, function connected() { + net.connect(server.address().port, function connected() { clientConnected(this); makeConnection(); }); diff --git a/test/parallel/test-regress-GH-1531.js b/test/parallel/test-regress-GH-1531.js index 79766934edec5b..ae48c907048428 100644 --- a/test/parallel/test-regress-GH-1531.js +++ b/test/parallel/test-regress-GH-1531.js @@ -22,12 +22,12 @@ var server = https.createServer(options, function(req, res) { res.end('hello world\n'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { console.error('listening'); https.get({ agent: false, path: '/', - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function(res) { console.error(res.statusCode, res.headers); diff --git a/test/parallel/test-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js index c6953eb78fa908..0317778787c2e2 100644 --- a/test/parallel/test-regress-GH-4948.js +++ b/test/parallel/test-regress-GH-4948.js @@ -1,7 +1,7 @@ 'use strict'; // https://github.com/joyent/node/issues/4948 -var common = require('../common'); +require('../common'); var http = require('http'); var reqCount = 0; @@ -17,7 +17,7 @@ var server = http.createServer(function(serverReq, serverRes) { // normally the use case would be to call an external site // does not require connecting locally or to itself to fail var r = http.request({hostname: 'localhost', - port: common.PORT}, function(res) { + port: this.address().port}, function(res) { // required, just needs to be in the client response somewhere serverRes.end(); @@ -29,15 +29,15 @@ var server = http.createServer(function(serverReq, serverRes) { r.end(); serverRes.write('some data'); -}).listen(common.PORT); +}).listen(0, function() { + // simulate a client request that closes early + var net = require('net'); -// simulate a client request that closes early -var net = require('net'); + var sock = new net.Socket(); + sock.connect(this.address().port, 'localhost'); -var sock = new net.Socket(); -sock.connect(common.PORT, 'localhost'); - -sock.on('connect', function() { - sock.write('GET / HTTP/1.1\r\n\r\n'); - sock.end(); + sock.on('connect', function() { + sock.write('GET / HTTP/1.1\r\n\r\n'); + sock.end(); + }); }); diff --git a/test/parallel/test-regress-GH-746.js b/test/parallel/test-regress-GH-746.js index 0070be30f8329f..4a5bba83085b92 100644 --- a/test/parallel/test-regress-GH-746.js +++ b/test/parallel/test-regress-GH-746.js @@ -2,7 +2,7 @@ // Just test that destroying stdin doesn't mess up listening on a server. // This is a regression test for GH-746. -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); @@ -17,10 +17,10 @@ var server = net.createServer(function(socket) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { console.log('listening...'); - net.createConnection(common.PORT); + net.createConnection(this.address().port); }); diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index c964951c2cacd8..93a25cc3022536 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -15,11 +15,12 @@ const server = net.createServer((conn) => { }); const host = common.localhostIPv4; -const port = common.PORT; +const port = 0; const options = { host, port }; var answer = ''; server.listen(options, function() { + options.port = this.address().port; const conn = net.connect(options); conn.setEncoding('utf8'); conn.on('data', (data) => answer += data); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 33530cf1058b0f..23a5a3d59fa3cb 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -324,10 +324,10 @@ function tcp_test() { repl.start(prompt_tcp, socket); }); - server_tcp.listen(common.PORT, function() { + server_tcp.listen(0, function() { var read_buffer = ''; - client_tcp = net.createConnection(common.PORT); + client_tcp = net.createConnection(this.address().port); client_tcp.on('connect', function() { assert.equal(true, client_tcp.readable); diff --git a/test/parallel/test-socket-write-after-fin-error.js b/test/parallel/test-socket-write-after-fin-error.js index 226440ec502670..480d5d2edc321e 100644 --- a/test/parallel/test-socket-write-after-fin-error.js +++ b/test/parallel/test-socket-write-after-fin-error.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); // This is similar to simple/test-socket-write-after-fin, except that @@ -31,30 +31,30 @@ var server = net.createServer(function(sock) { }); server.close(); }); -server.listen(common.PORT); +server.listen(0, function() { + var sock = net.connect(this.address().port); + sock.setEncoding('utf8'); + sock.on('data', function(c) { + clientData += c; + }); -var sock = net.connect(common.PORT); -sock.setEncoding('utf8'); -sock.on('data', function(c) { - clientData += c; -}); + sock.on('end', function() { + gotClientEnd = true; + }); -sock.on('end', function() { - gotClientEnd = true; -}); + process.on('exit', function() { + assert.equal(clientData, ''); + assert.equal(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); + assert(gotClientEnd); + assert(gotServerEnd); + assert(gotServerError); + assert.equal(gotServerError.code, 'EPIPE'); + assert.notEqual(gotServerError.message, 'write after end'); + console.log('ok'); + }); -process.on('exit', function() { - assert.equal(clientData, ''); - assert.equal(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); - assert(gotClientEnd); - assert(gotServerEnd); - assert(gotServerError); - assert.equal(gotServerError.code, 'EPIPE'); - assert.notEqual(gotServerError.message, 'write after end'); - console.log('ok'); + sock.write('hello1'); + sock.write('hello2'); + sock.write('hello3\n'); + sock.end('THUNDERMUSCLE!'); }); - -sock.write('hello1'); -sock.write('hello2'); -sock.write('hello3\n'); -sock.end('THUNDERMUSCLE!'); diff --git a/test/parallel/test-socket-write-after-fin.js b/test/parallel/test-socket-write-after-fin.js index ea8ac27b597ec4..f7e3d5fe4e78e8 100644 --- a/test/parallel/test-socket-write-after-fin.js +++ b/test/parallel/test-socket-write-after-fin.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var net = require('net'); var serverData = ''; @@ -18,27 +18,27 @@ var server = net.createServer({ allowHalfOpen: true }, function(sock) { server.close(); }); }); -server.listen(common.PORT); +server.listen(0, function() { + var sock = net.connect(this.address().port); + sock.setEncoding('utf8'); + sock.on('data', function(c) { + clientData += c; + }); -var sock = net.connect(common.PORT); -sock.setEncoding('utf8'); -sock.on('data', function(c) { - clientData += c; -}); + sock.on('end', function() { + gotClientEnd = true; + }); -sock.on('end', function() { - gotClientEnd = true; -}); + process.on('exit', function() { + assert.equal(serverData, clientData); + assert.equal(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); + assert(gotClientEnd); + assert(gotServerEnd); + console.log('ok'); + }); -process.on('exit', function() { - assert.equal(serverData, clientData); - assert.equal(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); - assert(gotClientEnd); - assert(gotServerEnd); - console.log('ok'); + sock.write('hello1'); + sock.write('hello2'); + sock.write('hello3\n'); + sock.end('THUNDERMUSCLE!'); }); - -sock.write('hello1'); -sock.write('hello2'); -sock.write('hello3\n'); -sock.end('THUNDERMUSCLE!'); diff --git a/test/parallel/test-stream2-httpclient-response-end.js b/test/parallel/test-stream2-httpclient-response-end.js index b778af58e2eec8..c71fbd7a374cd6 100644 --- a/test/parallel/test-stream2-httpclient-response-end.js +++ b/test/parallel/test-stream2-httpclient-response-end.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); var msg = 'Hello'; @@ -8,8 +8,8 @@ var end_event = false; var server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(msg); -}).listen(common.PORT, function() { - http.get({port: common.PORT}, function(res) { +}).listen(0, function() { + http.get({port: this.address().port}, function(res) { var data = ''; res.on('readable', function() { console.log('readable event'); diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js index 9373906c6f612a..55d4af9bc21d7d 100644 --- a/test/parallel/test-tcp-wrap-connect.js +++ b/test/parallel/test-tcp-wrap-connect.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var TCP = process.binding('tcp_wrap').TCP; var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; @@ -9,7 +9,7 @@ function makeConnection() { var client = new TCP(); var req = new TCPConnectWrap(); - var err = client.connect(req, '127.0.0.1', common.PORT); + var err = client.connect(req, '127.0.0.1', this.address().port); assert.equal(err, 0); req.oncomplete = function(status, client_, req_) { @@ -51,7 +51,7 @@ var server = require('net').Server(function(s) { }); }); -server.listen(common.PORT, makeConnection); +server.listen(0, makeConnection); process.on('exit', function() { assert.equal(1, shutdownCount); diff --git a/test/parallel/test-tcp-wrap-listen.js b/test/parallel/test-tcp-wrap-listen.js index aa9d810130fd43..15f3c7f717ce98 100644 --- a/test/parallel/test-tcp-wrap-listen.js +++ b/test/parallel/test-tcp-wrap-listen.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var TCP = process.binding('tcp_wrap').TCP; @@ -7,8 +7,11 @@ var WriteWrap = process.binding('stream_wrap').WriteWrap; var server = new TCP(); -var r = server.bind('0.0.0.0', common.PORT); +var r = server.bind('0.0.0.0', 0); assert.equal(0, r); +var port = {}; +server.getsockname(port); +port = port.port; server.listen(128); @@ -80,7 +83,7 @@ server.onconnection = function(err, client) { var net = require('net'); -var c = net.createConnection(common.PORT); +var c = net.createConnection(port); c.on('connect', function() { c.end('hello world'); }); diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js index 93da3e5b3b41c8..18b8fe401f8902 100644 --- a/test/parallel/test-tcp-wrap.js +++ b/test/parallel/test-tcp-wrap.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +require('../common'); var assert = require('assert'); var TCP = process.binding('tcp_wrap').TCP; @@ -7,12 +7,14 @@ var uv = process.binding('uv'); var handle = new TCP(); -// Should be able to bind to the common.PORT -var err = handle.bind('0.0.0.0', common.PORT); +// Should be able to bind to the port +var err = handle.bind('0.0.0.0', 0); assert.equal(err, 0); // Should not be able to bind to the same port again -err = handle.bind('0.0.0.0', common.PORT); +var out = {}; +handle.getsockname(out); +err = handle.bind('0.0.0.0', out.port); assert.equal(err, uv.UV_EINVAL); handle.close(); diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index a26b548385e5f6..8670c3c2b6e8f3 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -31,7 +31,7 @@ const server = net.createServer(function onClient(client) { } }); -server.listen(common.PORT, common.localhostIPv4, function() { +server.listen(0, common.localhostIPv4, function() { var nbClientsEnded = 0; function addEndedClient(client) { @@ -41,9 +41,9 @@ server.listen(common.PORT, common.localhostIPv4, function() { } } - const client1 = net.connect({ port: common.PORT }); + const client1 = net.connect({ port: this.address().port }); client1.on('end', addEndedClient); - const client2 = net.connect({ port: common.PORT }); + const client2 = net.connect({ port: this.address().port }); client2.on('end', addEndedClient); }); diff --git a/test/parallel/test-tls-0-dns-altname.js b/test/parallel/test-tls-0-dns-altname.js index bafbcd419a503d..019304a4ba8e4d 100644 --- a/test/parallel/test-tls-0-dns-altname.js +++ b/test/parallel/test-tls-0-dns-altname.js @@ -20,8 +20,8 @@ var server = tls.createServer({ c.destroy(); server.close(); }); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { requests++; diff --git a/test/parallel/test-tls-alert-handling.js b/test/parallel/test-tls-alert-handling.js index 7abde524bddd1c..3d2c9e92a781a6 100644 --- a/test/parallel/test-tls-alert-handling.js +++ b/test/parallel/test-tls-alert-handling.js @@ -41,13 +41,13 @@ var server = tls.createServer(opts, function(s) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { sendClient(); }); function sendClient() { - var client = tls.connect(common.PORT, { + var client = tls.connect(server.address().port, { rejectUnauthorized: false }); client.on('data', function(chunk) { @@ -72,7 +72,7 @@ function sendClient() { function sendBADTLSRecord() { var BAD_RECORD = new Buffer([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]); - var socket = net.connect(common.PORT); + var socket = net.connect(server.address().port); var client = tls.connect({ socket: socket, rejectUnauthorized: false diff --git a/test/parallel/test-tls-alert.js b/test/parallel/test-tls-alert.js index 20e77afda4a4be..db22443918453b 100644 --- a/test/parallel/test-tls-alert.js +++ b/test/parallel/test-tls-alert.js @@ -30,9 +30,9 @@ var server = tls.Server({ secureProtocol: 'TLSv1_2_server_method', key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert') -}, null).listen(common.PORT, function() { +}, null).listen(0, function() { var args = ['s_client', '-quiet', '-tls1_1', - '-connect', '127.0.0.1:' + common.PORT]; + '-connect', `127.0.0.1:${this.address().port}`]; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-async-cb-after-socket-end.js b/test/parallel/test-tls-async-cb-after-socket-end.js index 902d37951a2099..647d4ad1f8dd32 100644 --- a/test/parallel/test-tls-async-cb-after-socket-end.js +++ b/test/parallel/test-tls-async-cb-after-socket-end.js @@ -35,9 +35,9 @@ server.on('resumeSession', function(id, cb) { next(); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var clientOpts = { - port: common.PORT, + port: this.address().port, rejectUnauthorized: false, session: false }; diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js index 9a4ac91876bc17..16687b2692955c 100644 --- a/test/parallel/test-tls-cert-regression.js +++ b/test/parallel/test-tls-cert-regression.js @@ -37,7 +37,7 @@ function test(cert, key, cb) { var server = tls.createServer({ cert: cert, key: key - }).listen(common.PORT, function() { + }).listen(0, function() { server.close(cb); }); } diff --git a/test/parallel/test-tls-client-destroy-soon.js b/test/parallel/test-tls-client-destroy-soon.js index 9031f29e8d0f72..15e595c0a6e7f6 100644 --- a/test/parallel/test-tls-client-destroy-soon.js +++ b/test/parallel/test-tls-client-destroy-soon.js @@ -33,9 +33,9 @@ var server = tls.createServer(options, function(socket) { }); // start listening -server.listen(common.PORT, function() { +server.listen(0, function() { var client = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { client.on('readable', function() { diff --git a/test/parallel/test-tls-client-reject.js b/test/parallel/test-tls-client-reject.js index db53eb4b129ee5..ddfcafd2085b53 100644 --- a/test/parallel/test-tls-client-reject.js +++ b/test/parallel/test-tls-client-reject.js @@ -24,13 +24,13 @@ var server = tls.createServer(options, function(socket) { console.error(data.toString()); assert.equal(data, 'ok'); }); -}).listen(common.PORT, function() { +}).listen(0, function() { unauthorized(); }); function unauthorized() { var socket = tls.connect({ - port: common.PORT, + port: server.address().port, servername: 'localhost', rejectUnauthorized: false }, function() { @@ -45,7 +45,7 @@ function unauthorized() { } function rejectUnauthorized() { - var socket = tls.connect(common.PORT, { + var socket = tls.connect(server.address().port, { servername: 'localhost' }, function() { assert(false); @@ -58,7 +58,7 @@ function rejectUnauthorized() { } function authorized() { - var socket = tls.connect(common.PORT, { + var socket = tls.connect(server.address().port, { ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))], servername: 'localhost' }, function() { diff --git a/test/parallel/test-tls-client-resume.js b/test/parallel/test-tls-client-resume.js index b7fd2fc9d9fb46..141e0348a7955b 100644 --- a/test/parallel/test-tls-client-resume.js +++ b/test/parallel/test-tls-client-resume.js @@ -28,11 +28,11 @@ var server = tls.Server(options, function(socket) { }); // start listening -server.listen(common.PORT, function() { +server.listen(0, function() { var session1 = null; var client1 = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { console.log('connect1'); @@ -44,7 +44,7 @@ server.listen(common.PORT, function() { console.log('close1'); var opts = { - port: common.PORT, + port: server.address().port, rejectUnauthorized: false, session: session1 }; diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js index ed142b86529fd6..e566cafc8ca33b 100644 --- a/test/parallel/test-tls-client-verify.js +++ b/test/parallel/test-tls-client-verify.js @@ -75,10 +75,11 @@ function testServers(index, servers, clientOptions, cb) { s.end('hello world\n'); }); - server.listen(common.PORT, function() { + server.listen(0, function() { var b = ''; console.error('connecting...'); + clientOptions.port = this.address().port; var client = tls.connect(clientOptions, function() { var authorized = client.authorized || hosterr.test(client.authorizationError); @@ -109,7 +110,7 @@ function runTest(testIndex) { if (!tcase) return; var clientOptions = { - port: common.PORT, + port: undefined, ca: tcase.ca.map(loadPEM), key: loadPEM(tcase.key), cert: loadPEM(tcase.cert), diff --git a/test/parallel/test-tls-close-error.js b/test/parallel/test-tls-close-error.js index e338e8ecb7fd9f..407d2caa9ed7d0 100644 --- a/test/parallel/test-tls-close-error.js +++ b/test/parallel/test-tls-close-error.js @@ -18,8 +18,8 @@ var server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, function() { +}).listen(0, function() { + var c = tls.connect(this.address().port, function() { assert(false, 'should not be called'); }); diff --git a/test/parallel/test-tls-close-notify.js b/test/parallel/test-tls-close-notify.js index d06484af8b9942..2d747afd4057a6 100644 --- a/test/parallel/test-tls-close-notify.js +++ b/test/parallel/test-tls-close-notify.js @@ -19,8 +19,8 @@ var server = tls.createServer({ // Send close-notify without shutting down TCP socket if (c._handle.shutdownSSL() !== 1) c._handle.shutdownSSL(); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { // Ensure that we receive 'end' event anyway diff --git a/test/parallel/test-tls-cnnic-whitelist.js b/test/parallel/test-tls-cnnic-whitelist.js index 2b2a818969d9e9..f16698c736be39 100644 --- a/test/parallel/test-tls-cnnic-whitelist.js +++ b/test/parallel/test-tls-cnnic-whitelist.js @@ -31,7 +31,7 @@ var testCases = [ cert: loadPEM('agent7-cert') }, clientOpts: { - port: common.PORT, + port: undefined, rejectUnauthorized: true, ca: [loadPEM('fake-cnnic-root-cert')] }, @@ -50,7 +50,7 @@ var testCases = [ cert: loadPEM('agent6-cert') }, clientOpts: { - port: common.PORT, + port: undefined, rejectUnauthorized: true }, errorCode: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' @@ -64,7 +64,8 @@ function runTest(tindex) { var server = tls.createServer(tcase.serverOpts, function(s) { s.resume(); - }).listen(common.PORT, function() { + }).listen(0, function() { + tcase.clientOpts = this.address().port; var client = tls.connect(tcase.clientOpts); client.on('error', function(e) { assert.strictEqual(e.code, tcase.errorCode); diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js index 665a71dfe666d9..f069d21e54ad92 100644 --- a/test/parallel/test-tls-connect-address-family.js +++ b/test/parallel/test-tls-connect-address-family.js @@ -11,10 +11,10 @@ if (!common.hasIPv6) { const ciphers = 'AECDH-NULL-SHA'; tls.createServer({ ciphers }, function() { this.close(); -}).listen(common.PORT, '::1', function() { +}).listen(0, '::1', function() { const options = { host: 'localhost', - port: common.PORT, + port: this.address().port, family: 6, ciphers: ciphers, rejectUnauthorized: false, diff --git a/test/parallel/test-tls-connect-given-socket.js b/test/parallel/test-tls-connect-given-socket.js index 41ea94883ef74c..5329fcc4618cc5 100644 --- a/test/parallel/test-tls-connect-given-socket.js +++ b/test/parallel/test-tls-connect-given-socket.js @@ -23,7 +23,7 @@ var options = { var server = tls.createServer(options, function(socket) { serverConnected++; socket.end('Hello'); -}).listen(common.PORT, function() { +}).listen(0, function() { var waiting = 2; function establish(socket) { var client = tls.connect({ @@ -48,11 +48,11 @@ var server = tls.createServer(options, function(socket) { } // Immediate death socket - var immediateDeath = net.connect(common.PORT); + var immediateDeath = net.connect(this.address().port); establish(immediateDeath).destroy(); // Outliving - var outlivingTCP = net.connect(common.PORT); + var outlivingTCP = net.connect(this.address().port); outlivingTCP.on('connect', function() { outlivingTLS.destroy(); next(); @@ -61,12 +61,12 @@ var server = tls.createServer(options, function(socket) { function next() { // Already connected socket - var connected = net.connect(common.PORT, function() { + var connected = net.connect(server.address().port, function() { establish(connected); }); // Connecting socket - var connecting = net.connect(common.PORT); + var connecting = net.connect(server.address().port); establish(connecting); } diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js index 86203d7f42d5ef..e2e0238ff8d0ad 100644 --- a/test/parallel/test-tls-connect-no-host.js +++ b/test/parallel/test-tls-connect-no-host.js @@ -20,16 +20,16 @@ var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); tls.createServer({ key: key, cert: cert -}).listen(common.PORT); - -var socket = tls.connect({ - port: common.PORT, - ca: cert, - // No host set here. 'localhost' is the default, - // but tls.checkServerIdentity() breaks before the fix with: - // Error: Hostname/IP doesn't match certificate's altnames: - // "Host: undefined. is not cert's CN: localhost" -}, function() { - assert(socket.authorized); - process.exit(); +}).listen(0, function() { + var socket = tls.connect({ + port: this.address().port, + ca: cert, + // No host set here. 'localhost' is the default, + // but tls.checkServerIdentity() breaks before the fix with: + // Error: Hostname/IP doesn't match certificate's altnames: + // "Host: undefined. is not cert's CN: localhost" + }, function() { + assert(socket.authorized); + process.exit(); + }); }); diff --git a/test/parallel/test-tls-connect-simple.js b/test/parallel/test-tls-connect-simple.js index f21417cef8f311..5b18f7693ff7df 100644 --- a/test/parallel/test-tls-connect-simple.js +++ b/test/parallel/test-tls-connect-simple.js @@ -31,9 +31,9 @@ var server = tls.Server(options, function(socket) { } }); -server.listen(common.PORT, function() { +server.listen(0, function() { var client1 = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { ++clientConnected; @@ -41,7 +41,7 @@ server.listen(common.PORT, function() { }); var client2 = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); client2.on('secureConnect', function() { diff --git a/test/parallel/test-tls-connect-stream-writes.js b/test/parallel/test-tls-connect-stream-writes.js index 8fabc7edaeeda0..65da3e438727c1 100644 --- a/test/parallel/test-tls-connect-stream-writes.js +++ b/test/parallel/test-tls-connect-stream-writes.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const fs = require('fs'); const path = require('path'); @@ -21,8 +21,8 @@ server = tls.createServer(options, function(s) { recv_bufs.push(c); }); }); -server.listen(common.PORT, function() { - var raw = net.connect(common.PORT); +server.listen(0, function() { + var raw = net.connect(this.address().port); var pending = false; raw.on('readable', function() { diff --git a/test/parallel/test-tls-delayed-attach-error.js b/test/parallel/test-tls-delayed-attach-error.js index 0fef55ff7721ad..398178c58f7341 100644 --- a/test/parallel/test-tls-delayed-attach-error.js +++ b/test/parallel/test-tls-delayed-attach-error.js @@ -35,8 +35,8 @@ var server = net.createServer(function(c) { s.destroy(); }); }, 200); -}).listen(common.PORT, function() { - var c = net.connect({port: common.PORT}, function() { +}).listen(0, function() { + var c = net.connect({port: this.address().port}, function() { c.write(bonkers); }); }); diff --git a/test/parallel/test-tls-delayed-attach.js b/test/parallel/test-tls-delayed-attach.js index ba2002dde305ea..b1e4beb2313c9a 100644 --- a/test/parallel/test-tls-delayed-attach.js +++ b/test/parallel/test-tls-delayed-attach.js @@ -35,8 +35,8 @@ var server = net.createServer(function(c) { s.destroy(); }); }, 200); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { c.end(sent); diff --git a/test/parallel/test-tls-dhe.js b/test/parallel/test-tls-dhe.js index 4bf1b7bf2339fd..364be28db9e98e 100644 --- a/test/parallel/test-tls-dhe.js +++ b/test/parallel/test-tls-dhe.js @@ -40,8 +40,8 @@ function test(keylen, expectedCipher, cb) { if (cb) cb(); }); - server.listen(common.PORT, '127.0.0.1', function() { - var args = ['s_client', '-connect', '127.0.0.1:' + common.PORT, + server.listen(0, '127.0.0.1', function() { + var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`, '-cipher', ciphers]; // for the performance and stability issue in s_client on Windows diff --git a/test/parallel/test-tls-ecdh-disable.js b/test/parallel/test-tls-ecdh-disable.js index a7e18a319afae2..b6e060f35aed23 100644 --- a/test/parallel/test-tls-ecdh-disable.js +++ b/test/parallel/test-tls-ecdh-disable.js @@ -29,9 +29,9 @@ var server = tls.createServer(options, function(conn) { nconns++; }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + - ' -connect 127.0.0.1:' + common.PORT; + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-ecdh.js b/test/parallel/test-tls-ecdh.js index 9ecd5c16e010d3..54a5a382601ee7 100644 --- a/test/parallel/test-tls-ecdh.js +++ b/test/parallel/test-tls-ecdh.js @@ -32,9 +32,9 @@ var server = tls.createServer(options, function(conn) { nconns++; }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + - ' -connect 127.0.0.1:' + common.PORT; + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-econnreset.js b/test/parallel/test-tls-econnreset.js index 7acf98a35340d1..b5f8195adc105b 100644 --- a/test/parallel/test-tls-econnreset.js +++ b/test/parallel/test-tls-econnreset.js @@ -54,10 +54,10 @@ var server = tls.createServer({ ca: ca, cert: cert, key: key }, function(conn) { }).on('clientError', function(err, conn) { assert(!clientError && conn); clientError = err; -}).listen(common.PORT, function() { +}).listen(0, function() { var options = { ciphers: 'AES128-GCM-SHA256', - port: common.PORT, + port: this.address().port, ca: ca }; tls.connect(options).on('error', function(err) { diff --git a/test/parallel/test-tls-empty-sni-context.js b/test/parallel/test-tls-empty-sni-context.js index 3a1934ba3240c0..7759142d8aafc3 100644 --- a/test/parallel/test-tls-empty-sni-context.js +++ b/test/parallel/test-tls-empty-sni-context.js @@ -27,9 +27,9 @@ const server = tls.createServer(options, (c) => { }).on('clientError', common.mustCall((err, c) => { assert(/SSL_use_certificate:passed a null parameter/i.test(err.message)); server.close(); -})).listen(common.PORT, common.mustCall(() => { +})).listen(0, common.mustCall(() => { const c = tls.connect({ - port: common.PORT, + port: server.address().port, rejectUnauthorized: false, servername: 'any.name' }, () => { diff --git a/test/parallel/test-tls-fast-writing.js b/test/parallel/test-tls-fast-writing.js index 98156854c5fc8e..35420150483939 100644 --- a/test/parallel/test-tls-fast-writing.js +++ b/test/parallel/test-tls-fast-writing.js @@ -10,7 +10,6 @@ var tls = require('tls'); var fs = require('fs'); -var PORT = common.PORT; var dir = common.fixturesDir; var options = { key: fs.readFileSync(dir + '/test_key.pem'), cert: fs.readFileSync(dir + '/test_cert.pem'), @@ -41,10 +40,10 @@ function onconnection(conn) { }); } -server.listen(PORT, function() { +server.listen(0, function() { var chunk = new Buffer(1024); chunk.fill('x'); - var opt = { port: PORT, rejectUnauthorized: false }; + var opt = { port: this.address().port, rejectUnauthorized: false }; var conn = tls.connect(opt, function() { conn.on('drain', ondrain); write(); diff --git a/test/parallel/test-tls-friendly-error-message.js b/test/parallel/test-tls-friendly-error-message.js index 38197b6201770f..c53dd7cbc07205 100644 --- a/test/parallel/test-tls-friendly-error-message.js +++ b/test/parallel/test-tls-friendly-error-message.js @@ -16,7 +16,7 @@ var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); tls.createServer({ key: key, cert: cert }, function(conn) { conn.end(); this.close(); -}).listen(common.PORT, function() { +}).listen(0, function() { var options = { port: this.address().port, rejectUnauthorized: true }; tls.connect(options).on('error', common.mustCall(function(err) { assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); diff --git a/test/parallel/test-tls-getcipher.js b/test/parallel/test-tls-getcipher.js index 9e525b8c477792..100c4143c09c6d 100644 --- a/test/parallel/test-tls-getcipher.js +++ b/test/parallel/test-tls-getcipher.js @@ -28,10 +28,10 @@ var server = tls.createServer(options, function(cleartextStream) { nconns++; }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var client = tls.connect({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, ciphers: cipher_list.join(':'), rejectUnauthorized: false }, function() { diff --git a/test/parallel/test-tls-handshake-error.js b/test/parallel/test-tls-handshake-error.js index 3bb583bb2c7802..1b191d13a3d35b 100644 --- a/test/parallel/test-tls-handshake-error.js +++ b/test/parallel/test-tls-handshake-error.js @@ -19,9 +19,9 @@ var server = tls.createServer({ cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), rejectUnauthorized: true }, function(c) { -}).listen(common.PORT, function() { +}).listen(0, function() { var c = tls.connect({ - port: common.PORT, + port: this.address().port, ciphers: 'RC4' }, function() { assert(false, 'should not be called'); diff --git a/test/parallel/test-tls-hello-parser-failure.js b/test/parallel/test-tls-hello-parser-failure.js index e35fa5483010a3..c6fc97102af056 100644 --- a/test/parallel/test-tls-hello-parser-failure.js +++ b/test/parallel/test-tls-hello-parser-failure.js @@ -21,8 +21,8 @@ bonkers.fill(42); var server = tls.createServer(options, function(c) { -}).listen(common.PORT, function() { - var client = net.connect(common.PORT, function() { +}).listen(0, function() { + var client = net.connect(this.address().port, function() { client.write(bonkers); }); diff --git a/test/parallel/test-tls-honorcipherorder.js b/test/parallel/test-tls-honorcipherorder.js index dd3ead8d42db3d..81c2440fe26d23 100644 --- a/test/parallel/test-tls-honorcipherorder.js +++ b/test/parallel/test-tls-honorcipherorder.js @@ -37,7 +37,7 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { // it may hang for ~30 seconds in FIN_WAIT_1 state (at least on OSX). cleartextStream.end(); }); - server.listen(common.PORT, localhost, function() { + server.listen(0, localhost, function() { var coptions = { rejectUnauthorized: false, secureProtocol: SSL_Method @@ -45,7 +45,8 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { if (clientCipher) { coptions.ciphers = clientCipher; } - var client = tls.connect(common.PORT, localhost, coptions, function() { + const port = this.address().port; + var client = tls.connect(port, localhost, coptions, function() { var cipher = client.getCipher(); client.end(); server.close(); diff --git a/test/parallel/test-tls-inception.js b/test/parallel/test-tls-inception.js index 2f4429c41d93e2..0ddfab21365f1c 100644 --- a/test/parallel/test-tls-inception.js +++ b/test/parallel/test-tls-inception.js @@ -42,8 +42,8 @@ b = tls.createServer(options, function(socket) { socket.end(body); }); -a.listen(common.PORT, function() { - b.listen(common.PORT + 1, function() { +a.listen(0, function() { + b.listen(0, function() { options = { host: '127.0.0.1', port: a.address().port, diff --git a/test/parallel/test-tls-interleave.js b/test/parallel/test-tls-interleave.js index 0c78e3e71a20c4..d03ed249d53253 100644 --- a/test/parallel/test-tls-interleave.js +++ b/test/parallel/test-tls-interleave.js @@ -10,7 +10,6 @@ var tls = require('tls'); var fs = require('fs'); -var PORT = common.PORT; var dir = common.fixturesDir; var options = { key: fs.readFileSync(dir + '/test_key.pem'), cert: fs.readFileSync(dir + '/test_cert.pem'), @@ -27,8 +26,9 @@ var server = tls.createServer(options, function(c) { writes.forEach(function(str) { c.write(str); }); -}).listen(PORT, function() { - var c = tls.connect(PORT, { rejectUnauthorized: false }, function() { +}).listen(0, function() { + const connectOpts = { rejectUnauthorized: false }; + var c = tls.connect(this.address().port, connectOpts, function() { c.write('some client data'); c.on('readable', function() { var data = c.read(); diff --git a/test/parallel/test-tls-invoke-queued.js b/test/parallel/test-tls-invoke-queued.js index 8b0d0e1271d4b2..0e7d9a9a2c3ffe 100644 --- a/test/parallel/test-tls-invoke-queued.js +++ b/test/parallel/test-tls-invoke-queued.js @@ -26,8 +26,8 @@ var server = tls.createServer({ }); server.close(); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { c.on('data', function(chunk) { diff --git a/test/parallel/test-tls-js-stream.js b/test/parallel/test-tls-js-stream.js index ddfcaf94bf19c4..08095fa99538cf 100644 --- a/test/parallel/test-tls-js-stream.js +++ b/test/parallel/test-tls-js-stream.js @@ -24,8 +24,8 @@ var server = tls.createServer({ console.log('new client'); connected.server++; c.end('ohai'); -}).listen(common.PORT, function() { - var raw = net.connect(common.PORT); +}).listen(0, function() { + var raw = net.connect(this.address().port); var pending = false; raw.on('readable', function() { diff --git a/test/parallel/test-tls-junk-closes-server.js b/test/parallel/test-tls-junk-closes-server.js index 5e20e753395912..f12393515cbe47 100644 --- a/test/parallel/test-tls-junk-closes-server.js +++ b/test/parallel/test-tls-junk-closes-server.js @@ -20,8 +20,8 @@ var server = tls.createServer(options, function(s) { s.pipe(s); }); -server.listen(common.PORT, function() { - var c = net.createConnection(common.PORT); +server.listen(0, function() { + var c = net.createConnection(this.address().port); c.on('connect', function() { c.write('blah\nblah\nblah\n'); diff --git a/test/parallel/test-tls-junk-server.js b/test/parallel/test-tls-junk-server.js index af454730218f60..9b5ab6fdcc649d 100644 --- a/test/parallel/test-tls-junk-server.js +++ b/test/parallel/test-tls-junk-server.js @@ -18,8 +18,8 @@ const server = net.createServer(function(s) { }); }); -server.listen(common.PORT, function() { - const req = https.request({ port: common.PORT }); +server.listen(0, function() { + const req = https.request({ port: this.address().port }); req.end(); req.once('error', common.mustCall(function(err) { diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index 6151d503c4d0a5..6c4b03297c0631 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -20,9 +20,9 @@ var server = net.Server(function(raw) { success = true; }); require('_tls_legacy').pipe(pair, raw); -}).listen(common.PORT, function() { +}).listen(0, function() { tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false, servername: 'server' }, function() { diff --git a/test/parallel/test-tls-max-send-fragment.js b/test/parallel/test-tls-max-send-fragment.js index 29243c93177e3a..17ae270c248228 100644 --- a/test/parallel/test-tls-max-send-fragment.js +++ b/test/parallel/test-tls-max-send-fragment.js @@ -27,8 +27,8 @@ var server = tls.createServer({ assert(c.setMaxSendFragment(maxChunk)); c.end(buf); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { c.on('data', function(chunk) { diff --git a/test/parallel/test-tls-multi-key.js b/test/parallel/test-tls-multi-key.js index 8c8fd5ded4a0b6..ab2395058f27c1 100644 --- a/test/parallel/test-tls-multi-key.js +++ b/test/parallel/test-tls-multi-key.js @@ -24,13 +24,13 @@ var ciphers = []; var server = tls.createServer(options, function(conn) { conn.end('ok'); -}).listen(common.PORT, function() { - var ecdsa = tls.connect(common.PORT, { +}).listen(0, function() { + var ecdsa = tls.connect(this.address().port, { ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384', rejectUnauthorized: false }, function() { ciphers.push(ecdsa.getCipher()); - var rsa = tls.connect(common.PORT, { + var rsa = tls.connect(server.address().port, { ciphers: 'ECDHE-RSA-AES256-GCM-SHA384', rejectUnauthorized: false }, function() { diff --git a/test/parallel/test-tls-no-cert-required.js b/test/parallel/test-tls-no-cert-required.js index 72e24c59f63ae1..de723e73e8a335 100644 --- a/test/parallel/test-tls-no-cert-required.js +++ b/test/parallel/test-tls-no-cert-required.js @@ -10,6 +10,6 @@ var tls = require('tls'); // Omitting the cert or pfx option to tls.createServer() should not throw. // AECDH-NULL-SHA is a no-authentication/no-encryption cipher and hence // doesn't need a certificate. -tls.createServer({ ciphers: 'AECDH-NULL-SHA' }).listen(common.PORT, function() { +tls.createServer({ ciphers: 'AECDH-NULL-SHA' }).listen(0, function() { this.close(); }); diff --git a/test/parallel/test-tls-no-rsa-key.js b/test/parallel/test-tls-no-rsa-key.js index 2d2055eae8f5b5..cd1e15c1cd932b 100644 --- a/test/parallel/test-tls-no-rsa-key.js +++ b/test/parallel/test-tls-no-rsa-key.js @@ -19,8 +19,8 @@ var cert = null; var server = tls.createServer(options, function(conn) { conn.end('ok'); -}).listen(common.PORT, function() { - var c = tls.connect(common.PORT, { +}).listen(0, function() { + var c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { c.on('end', common.mustCall(function() { diff --git a/test/parallel/test-tls-no-sslv3.js b/test/parallel/test-tls-no-sslv3.js index 3ab62a26724149..40439ba33da497 100644 --- a/test/parallel/test-tls-no-sslv3.js +++ b/test/parallel/test-tls-no-sslv3.js @@ -22,7 +22,7 @@ var server = tls.createServer({ cert: cert, key: key }, common.fail); var errors = []; var stderr = ''; -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var address = this.address().address + ':' + this.address().port; var args = ['s_client', '-no_ssl2', diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js index 446d249c60856d..c203d950051112 100644 --- a/test/parallel/test-tls-npn-server-client.js +++ b/test/parallel/test-tls-npn-server-client.js @@ -38,30 +38,28 @@ var serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; -var serverPort = common.PORT; - var clientsOptions = [{ - port: serverPort, + port: undefined, key: serverOptions.key, cert: serverOptions.cert, crl: serverOptions.crl, NPNProtocols: ['a', 'b', 'c'], rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: serverOptions.key, cert: serverOptions.cert, crl: serverOptions.crl, NPNProtocols: ['c', 'b', 'e'], rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: serverOptions.key, cert: serverOptions.cert, crl: serverOptions.crl, rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: serverOptions.key, cert: serverOptions.cert, crl: serverOptions.crl, @@ -75,10 +73,11 @@ const clientsResults = []; var server = tls.createServer(serverOptions, function(c) { serverResults.push(c.npnProtocol); }); -server.listen(serverPort, startTest); +server.listen(0, startTest); function startTest() { function connectClient(options, callback) { + options.port = server.address().port; var client = tls.connect(options, function() { clientsResults.push(client.npnProtocol); client.destroy(); diff --git a/test/parallel/test-tls-ocsp-callback.js b/test/parallel/test-tls-ocsp-callback.js index 07ce53c53f02f8..330ed550e23189 100644 --- a/test/parallel/test-tls-ocsp-callback.js +++ b/test/parallel/test-tls-ocsp-callback.js @@ -71,9 +71,9 @@ function test(testOptions, cb) { testOptions.response ? new Buffer(testOptions.response) : null); }, 100); }); - server.listen(common.PORT, function() { + server.listen(0, function() { var client = tls.connect({ - port: common.PORT, + port: this.address().port, requestOCSP: testOptions.ocsp !== false, secureOptions: testOptions.ocsp === false ? constants.SSL_OP_NO_TICKET : 0, diff --git a/test/parallel/test-tls-on-empty-socket.js b/test/parallel/test-tls-on-empty-socket.js index 1b5a3f342f5cbc..58bc101333a583 100644 --- a/test/parallel/test-tls-on-empty-socket.js +++ b/test/parallel/test-tls-on-empty-socket.js @@ -18,7 +18,7 @@ var server = tls.createServer({ cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { c.end('hello'); -}).listen(common.PORT, function() { +}).listen(0, function() { var socket = new net.Socket(); var s = tls.connect({ @@ -34,7 +34,7 @@ var server = tls.createServer({ }); }); - socket.connect(common.PORT); + socket.connect(this.address().port); }); process.on('exit', function() { diff --git a/test/parallel/test-tls-over-http-tunnel.js b/test/parallel/test-tls-over-http-tunnel.js index eab72e411555b4..c030c7482ff6dd 100644 --- a/test/parallel/test-tls-over-http-tunnel.js +++ b/test/parallel/test-tls-over-http-tunnel.js @@ -12,7 +12,6 @@ var fs = require('fs'); var net = require('net'); var http = require('http'); -var proxyPort = common.PORT + 1; var gotRequest = false; var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); @@ -40,9 +39,9 @@ var proxy = net.createServer(function(clientSocket) { clientSocket.on('data', function(chunk) { if (!serverSocket) { // Verify the CONNECT request - assert.equal('CONNECT localhost:' + common.PORT + ' HTTP/1.1\r\n' + + assert.equal(`CONNECT localhost:${server.address().port} HTTP/1.1\r\n` + 'Proxy-Connections: keep-alive\r\n' + - 'Host: localhost:' + proxyPort + '\r\n' + + `Host: localhost:${proxy.address().port}\r\n` + 'Connection: close\r\n\r\n', chunk); @@ -50,13 +49,13 @@ var proxy = net.createServer(function(clientSocket) { console.log('PROXY: creating a tunnel'); // create the tunnel - serverSocket = net.connect(common.PORT, function() { + serverSocket = net.connect(server.address().port, function() { console.log('PROXY: replying to client CONNECT request'); // Send the response clientSocket.write('HTTP/1.1 200 OK\r\nProxy-Connections: keep' + '-alive\r\nConnections: keep-alive\r\nVia: ' + - 'localhost:' + proxyPort + '\r\n\r\n'); + `localhost:${proxy.address().port}\r\n\r\n`); }); serverSocket.on('data', function(chunk) { @@ -76,15 +75,15 @@ var proxy = net.createServer(function(clientSocket) { }); }); -server.listen(common.PORT); +server.listen(0); -proxy.listen(proxyPort, function() { +proxy.listen(0, function() { console.log('CLIENT: Making CONNECT request'); var req = http.request({ - port: proxyPort, + port: this.address().port, method: 'CONNECT', - path: 'localhost:' + common.PORT, + path: `localhost:${server.address().port}`, headers: { 'Proxy-Connections': 'keep-alive' } diff --git a/test/parallel/test-tls-passphrase.js b/test/parallel/test-tls-passphrase.js index f04c8e28076068..e877363642be32 100644 --- a/test/parallel/test-tls-passphrase.js +++ b/test/parallel/test-tls-passphrase.js @@ -26,9 +26,9 @@ var server = tls.Server({ }); var connectCount = 0; -server.listen(common.PORT, function() { +server.listen(0, function() { var c = tls.connect({ - port: common.PORT, + port: this.address().port, key: key, passphrase: 'passphrase', cert: cert, @@ -43,7 +43,7 @@ server.listen(common.PORT, function() { assert.throws(function() { tls.connect({ - port: common.PORT, + port: server.address().port, key: key, passphrase: 'invalid', cert: cert, diff --git a/test/parallel/test-tls-pause.js b/test/parallel/test-tls-pause.js index 4943cfdfefe883..63b3218782cc8b 100644 --- a/test/parallel/test-tls-pause.js +++ b/test/parallel/test-tls-pause.js @@ -27,10 +27,10 @@ var server = tls.Server(options, function(socket) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var resumed = false; var client = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { console.error('connected'); diff --git a/test/parallel/test-tls-peer-certificate-encoding.js b/test/parallel/test-tls-peer-certificate-encoding.js index 00f42c4065907b..b7e8c5ba45626c 100644 --- a/test/parallel/test-tls-peer-certificate-encoding.js +++ b/test/parallel/test-tls-peer-certificate-encoding.js @@ -22,9 +22,9 @@ var verified = false; var server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var socket = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { var peerCert = socket.getPeerCertificate(); diff --git a/test/parallel/test-tls-peer-certificate-multi-keys.js b/test/parallel/test-tls-peer-certificate-multi-keys.js index c70620389fa198..75779b19bf8d97 100644 --- a/test/parallel/test-tls-peer-certificate-multi-keys.js +++ b/test/parallel/test-tls-peer-certificate-multi-keys.js @@ -21,9 +21,9 @@ var verified = false; var server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var socket = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { var peerCert = socket.getPeerCertificate(); diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index a6618d5fc62d62..d3633a664b2e48 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -22,9 +22,9 @@ var verified = false; var server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); -server.listen(common.PORT, function() { +server.listen(0, function() { var socket = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }, function() { var peerCert = socket.getPeerCertificate(); diff --git a/test/parallel/test-tls-pfx-gh-5100-regr.js b/test/parallel/test-tls-pfx-gh-5100-regr.js index 4123efde71c7c6..385c09208ebd67 100644 --- a/test/parallel/test-tls-pfx-gh-5100-regr.js +++ b/test/parallel/test-tls-pfx-gh-5100-regr.js @@ -23,9 +23,9 @@ const server = tls.createServer({ }, common.mustCall(function(c) { assert(c.authorizationError === null, 'authorizationError must be null'); c.end(); -})).listen(common.PORT, function() { +})).listen(0, function() { var client = tls.connect({ - port: common.PORT, + port: this.address().port, pfx: pfx, passphrase: 'sample', rejectUnauthorized: false diff --git a/test/parallel/test-tls-regr-gh-5108.js b/test/parallel/test-tls-regr-gh-5108.js index af295fe0db170d..6371bb52136185 100644 --- a/test/parallel/test-tls-regr-gh-5108.js +++ b/test/parallel/test-tls-regr-gh-5108.js @@ -18,9 +18,9 @@ const options = { const server = tls.createServer(options, function(s) { s.end('hello'); -}).listen(common.PORT, function() { +}).listen(0, function() { const opts = { - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }; const client = tls.connect(opts, function() { diff --git a/test/parallel/test-tls-request-timeout.js b/test/parallel/test-tls-request-timeout.js index 6c24c0c2ce0ba1..22ba6904b496a5 100644 --- a/test/parallel/test-tls-request-timeout.js +++ b/test/parallel/test-tls-request-timeout.js @@ -28,9 +28,9 @@ var server = tls.Server(options, function(socket) { }); }); -server.listen(common.PORT, function() { +server.listen(0, function() { tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); }); diff --git a/test/parallel/test-tls-securepair-server.js b/test/parallel/test-tls-securepair-server.js index f846f36d3ff89a..e6d01b7048a382 100644 --- a/test/parallel/test-tls-securepair-server.js +++ b/test/parallel/test-tls-securepair-server.js @@ -91,10 +91,10 @@ var sentWorld = false; var gotWorld = false; var opensslExitCode = -1; -server.listen(common.PORT, function() { +server.listen(0, function() { // To test use: openssl s_client -connect localhost:8000 - var args = ['s_client', '-connect', '127.0.0.1:' + common.PORT]; + var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`]; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-server-connection-server.js b/test/parallel/test-tls-server-connection-server.js index 41847cb8b362d0..ee4bcbebfd31cd 100644 --- a/test/parallel/test-tls-server-connection-server.js +++ b/test/parallel/test-tls-server-connection-server.js @@ -17,9 +17,9 @@ const options = { const server = tls.createServer(options, function(s) { s.end('hello'); -}).listen(common.PORT, function() { +}).listen(0, function() { const opts = { - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }; diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index 684d71ef7cdec2..93866d2977414b 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -312,6 +312,7 @@ function runTest(port, testIndex) { } server.listen(port, function() { + port = server.address().port; if (tcase.debug) { console.error(prefix + 'TLS server running on port ' + port); } else { @@ -336,8 +337,8 @@ function runTest(port, testIndex) { var nextTest = 0; -runTest(common.PORT, nextTest++); -runTest(common.PORT + 1, nextTest++); +runTest(0, nextTest++); +runTest(0, nextTest++); process.on('exit', function() { diff --git a/test/parallel/test-tls-session-cache.js b/test/parallel/test-tls-session-cache.js index 4b4dbda4a6dca2..99badeb7f5a351 100644 --- a/test/parallel/test-tls-session-cache.js +++ b/test/parallel/test-tls-session-cache.js @@ -71,21 +71,21 @@ function doTest(testOptions, callback) { }, 100); }); - var args = [ - 's_client', - '-tls1', - '-connect', 'localhost:' + common.PORT, - '-servername', 'ohgod', - '-key', join(common.fixturesDir, 'agent.key'), - '-cert', join(common.fixturesDir, 'agent.crt'), - '-reconnect' - ].concat(testOptions.tickets ? [] : '-no_ticket'); + server.listen(0, function() { + var args = [ + 's_client', + '-tls1', + '-connect', `localhost:${this.address().port}`, + '-servername', 'ohgod', + '-key', join(common.fixturesDir, 'agent.key'), + '-cert', join(common.fixturesDir, 'agent.crt'), + '-reconnect' + ].concat(testOptions.tickets ? [] : '-no_ticket'); - // for the performance and stability issue in s_client on Windows - if (common.isWindows) - args.push('-no_rand_screen'); + // for the performance and stability issue in s_client on Windows + if (common.isWindows) + args.push('-no_rand_screen'); - server.listen(common.PORT, function() { var client = spawn(common.opensslCli, args, { stdio: [ 0, 1, 'pipe' ] }); diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js index efdd4260adbad3..c72a65980af937 100644 --- a/test/parallel/test-tls-set-ciphers.js +++ b/test/parallel/test-tls-set-ciphers.js @@ -36,9 +36,9 @@ var server = tls.createServer(options, function(conn) { nconns++; }); -server.listen(common.PORT, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', function() { var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + - ' -connect 127.0.0.1:' + common.PORT; + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-set-encoding.js b/test/parallel/test-tls-set-encoding.js index bd34ede8f5c188..103593d6ed7e02 100644 --- a/test/parallel/test-tls-set-encoding.js +++ b/test/parallel/test-tls-set-encoding.js @@ -26,9 +26,9 @@ var server = tls.Server(options, function(socket) { }); -server.listen(common.PORT, function() { +server.listen(0, function() { var client = tls.connect({ - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index 5a07225fb58b25..3bc02b5ea82232 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -60,38 +60,36 @@ var SNIContexts = { } }; -var serverPort = common.PORT; - var clientsOptions = [{ - port: serverPort, + port: undefined, key: loadPEM('agent1-key'), cert: loadPEM('agent1-cert'), ca: [loadPEM('ca1-cert')], servername: 'a.example.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: loadPEM('agent4-key'), cert: loadPEM('agent4-cert'), ca: [loadPEM('ca1-cert')], servername: 'a.example.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert'), ca: [loadPEM('ca2-cert')], servername: 'b.example.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: loadPEM('agent3-key'), cert: loadPEM('agent3-cert'), ca: [loadPEM('ca1-cert')], servername: 'c.wrong.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, key: loadPEM('agent3-key'), cert: loadPEM('agent3-cert'), ca: [loadPEM('ca1-cert')], @@ -115,7 +113,7 @@ server.on('clientError', function(err) { serverError = err.message; }); -server.listen(serverPort, startTest); +server.listen(0, startTest); function startTest() { function connectClient(i, callback) { @@ -123,6 +121,7 @@ function startTest() { clientError = null; serverError = null; + options.port = server.address().port; var client = tls.connect(options, function() { clientResults.push( /Hostname\/IP doesn't/.test(client.authorizationError || '')); diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js index 62b22b5289e8fa..d7c30f87c3231e 100644 --- a/test/parallel/test-tls-sni-server-client.js +++ b/test/parallel/test-tls-sni-server-client.js @@ -44,30 +44,28 @@ var SNIContexts = { } }; -var serverPort = common.PORT; - var clientsOptions = [{ - port: serverPort, + port: undefined, ca: [loadPEM('ca1-cert')], servername: 'a.example.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, ca: [loadPEM('ca2-cert')], servername: 'b.test.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, ca: [loadPEM('ca2-cert')], servername: 'a.b.test.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, ca: [loadPEM('ca1-cert')], servername: 'c.wrong.com', rejectUnauthorized: false }, { - port: serverPort, + port: undefined, ca: [loadPEM('ca1-cert')], servername: 'chain.example.com', rejectUnauthorized: false @@ -84,7 +82,7 @@ server.addContext('a.example.com', SNIContexts['a.example.com']); server.addContext('*.test.com', SNIContexts['asterisk.test.com']); server.addContext('chain.example.com', SNIContexts['chain.example.com']); -server.listen(serverPort, startTest); +server.listen(0, startTest); function startTest() { var i = 0; @@ -94,6 +92,7 @@ function startTest() { return server.close(); var options = clientsOptions[i++]; + options.port = server.address().port; var client = tls.connect(options, function() { clientResults.push( client.authorizationError && diff --git a/test/parallel/test-tls-socket-default-options.js b/test/parallel/test-tls-socket-default-options.js index 70f24ebf2b80ef..5c325570643225 100644 --- a/test/parallel/test-tls-socket-default-options.js +++ b/test/parallel/test-tls-socket-default-options.js @@ -31,9 +31,9 @@ function testSocketOptions(socket, socketOptions) { assert.equal(received, sent); setImmediate(runTests); }); - }).listen(common.PORT, function() { + }).listen(0, function() { const c = new tls.TLSSocket(socket, socketOptions); - c.connect(common.PORT, function() { + c.connect(this.address().port, function() { c.end(sent); }); }); diff --git a/test/parallel/test-tls-ticket.js b/test/parallel/test-tls-ticket.js index 0e43ffaeaea0cb..8457b15e0cd325 100644 --- a/test/parallel/test-tls-ticket.js +++ b/test/parallel/test-tls-ticket.js @@ -57,7 +57,7 @@ var servers = naturalServers.concat(naturalServers).concat(naturalServers); // Create one TCP server and balance sockets to multiple TLS server instances var shared = net.createServer(function(c) { servers.shift().emit('connection', c); -}).listen(common.PORT, function() { +}).listen(0, function() { start(function() { shared.close(); }); @@ -68,7 +68,7 @@ function start(callback) { var left = servers.length; function connect() { - var s = tls.connect(common.PORT, { + var s = tls.connect(shared.address().port, { session: sess, rejectUnauthorized: false }, function() { diff --git a/test/parallel/test-tls-timeout-server-2.js b/test/parallel/test-tls-timeout-server-2.js index 44847e057311dc..a054f41f623455 100644 --- a/test/parallel/test-tls-timeout-server-2.js +++ b/test/parallel/test-tls-timeout-server-2.js @@ -23,10 +23,10 @@ var server = tls.createServer(options, function(cleartext) { assert.ok(s instanceof tls.TLSSocket); }); -server.listen(common.PORT, function() { +server.listen(0, function() { tls.connect({ host: '127.0.0.1', - port: common.PORT, + port: this.address().port, rejectUnauthorized: false }); }); diff --git a/test/parallel/test-tls-timeout-server.js b/test/parallel/test-tls-timeout-server.js index 20cd2aa7207b96..3531b641b31038 100644 --- a/test/parallel/test-tls-timeout-server.js +++ b/test/parallel/test-tls-timeout-server.js @@ -31,6 +31,6 @@ server.on('clientError', function(err, conn) { clientErrors++; }); -server.listen(common.PORT, function() { - net.connect({ host: '127.0.0.1', port: common.PORT }); +server.listen(0, function() { + net.connect({ host: '127.0.0.1', port: this.address().port }); }); diff --git a/test/parallel/test-tls-wrap-timeout.js b/test/parallel/test-tls-wrap-timeout.js index c260a03bf37b28..ab0f307a970bb3 100644 --- a/test/parallel/test-tls-wrap-timeout.js +++ b/test/parallel/test-tls-wrap-timeout.js @@ -26,8 +26,8 @@ var server = tls.createServer(options, function(c) { }, 150); }); -server.listen(common.PORT, function() { - var socket = net.connect(common.PORT, function() { +server.listen(0, function() { + var socket = net.connect(this.address().port, function() { var s = socket.setTimeout(common.platformTimeout(240), function() { throw new Error('timeout'); }); diff --git a/test/parallel/test-tls-zero-clear-in.js b/test/parallel/test-tls-zero-clear-in.js index 7b50bbd81e729c..3437746162c332 100644 --- a/test/parallel/test-tls-zero-clear-in.js +++ b/test/parallel/test-tls-zero-clear-in.js @@ -25,12 +25,12 @@ var server = tls.createServer({ c.end(); server.close(); }, 20); -}).listen(common.PORT, function() { +}).listen(0, function() { var conn = tls.connect({ cert: cert, key: key, rejectUnauthorized: false, - port: common.PORT + port: this.address().port }, function() { setTimeout(function() { conn.destroy(); diff --git a/test/parallel/test-zerolengthbufferbug.js b/test/parallel/test-zerolengthbufferbug.js index c56240011d76dd..f7ab395cb1bee5 100644 --- a/test/parallel/test-zerolengthbufferbug.js +++ b/test/parallel/test-zerolengthbufferbug.js @@ -1,7 +1,7 @@ 'use strict'; // Serving up a zero-length buffer should work. -var common = require('../common'); +require('../common'); var assert = require('assert'); var http = require('http'); @@ -16,8 +16,8 @@ var server = http.createServer(function(req, res) { var gotResponse = false; var resBodySize = 0; -server.listen(common.PORT, function() { - http.get({ port: common.PORT }, function(res) { +server.listen(0, function() { + http.get({ port: this.address().port }, function(res) { gotResponse = true; res.on('data', function(d) { From 236491e6981fe4ef291e130122b3c8465bc3cc6c Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Mon, 16 May 2016 12:32:03 -0400 Subject: [PATCH 259/261] build: update build-addons when node-gyp changes Backported from https://github.com/nodejs/node/commit/99bf6face5a7eab6b600507c55b65b98033a4554 We can tell when `node-gyp` is changed by creating a prerequisite on `deps/npm/node_modules/node-gyp/package.json`. The prerequisite is added to the `test/addons/.buildstamp` since `build-addons` is .PHONY. Testing for this change was entirely manual. $ make clean test-build # Initial build $ make test-build # Make sure build-addons doesn't rebuild $ touch deps/npm/node_modules/node-gyp/package.json # simulate change $ make test-build # Ensure build-addons rebuilds PR-URL: https://github.com/nodejs/node/pull/6787 Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 28f8f808808123..fae09589f37d22 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,10 @@ ADDONS_BINDING_GYPS := \ $(wildcard test/addons/*/binding.gyp)) # Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale. -test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) test/addons/.docbuildstamp +# Depends on node-gyp package.json so that build-addons is (re)executed when +# node-gyp is updated as part of an npm update. +test/addons/.buildstamp: deps/npm/node_modules/node-gyp/package.json \ + $(ADDONS_BINDING_GYPS) test/addons/.docbuildstamp # Cannot use $(wildcard test/addons/*/) here, it's evaluated before # embedded addons have been generated from the documentation. for dirname in test/addons/*/; do \ @@ -154,7 +157,7 @@ test/addons/.buildstamp: $(ADDONS_BINDING_GYPS) test/addons/.docbuildstamp # if the subprocess touched anything so it pessimistically assumes that # .buildstamp and .docbuildstamp are out of date and need a rebuild. # Just goes to show that recursive make really is harmful... -# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update. +# TODO(bnoordhuis) Force rebuild after gyp update. build-addons: $(NODE_EXE) test/addons/.buildstamp test-gc: all test/gc/node_modules/weak/build/Release/weakref.node From 046d651118d91c2bc04ae3d9913eb2167d02ad43 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 31 May 2016 18:25:15 +0200 Subject: [PATCH 260/261] benchmark: fix child-process-exec-stdout on win This benchmark fails on Windows when trying to execute command which is more than 32k in size. This commits skips this one case when running under Windows. PR-URL: https://github.com/nodejs/node/pull/7178 Reviewed-By: Trott - Rich Trott Reviewed-By: orangemocha - Alexis Campailla --- benchmark/child_process/child-process-exec-stdout.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/benchmark/child_process/child-process-exec-stdout.js b/benchmark/child_process/child-process-exec-stdout.js index 79efb6fadf2aeb..6194f66b55d987 100644 --- a/benchmark/child_process/child-process-exec-stdout.js +++ b/benchmark/child_process/child-process-exec-stdout.js @@ -1,7 +1,12 @@ 'use strict'; const common = require('../common.js'); + +var messagesLength = [64, 256, 1024, 4096]; +// Windows does not support that long arguments +if (process.platform !== 'win32') + messagesLength.push(32768); const bench = common.createBenchmark(main, { - len: [64, 256, 1024, 4096, 32768], + len: messagesLength, dur: [5] }); From 50577fa38d82d1b9c8414df56c14ed7228378bd0 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 12 Jul 2016 11:05:19 -0700 Subject: [PATCH 261/261] 2016-08-15, Version 4.5.0 'Argon' (LTS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notable Changes: Semver Minor: * buffer: * backport new buffer constructor APIs to v4.x (Сковорода Никита Андреевич) https://github.com/nodejs/node/pull/7562 * backport --zero-fill-buffers cli option (James M Snell) https://github.com/nodejs/node/pull/5745 * build: * add Intel Vtune profiling support (Chunyang Dai) https://github.com/nodejs/node/pull/5527 * repl: * copying tabs shouldn't trigger completion (Eugene Obrezkov) https://github.com/nodejs/node/pull/5958 * src: * add node::FreeEnvironment public API (Cheng Zhao) https://github.com/nodejs/node/pull/3098 * test: * run v8 tests from node tree (Bryon Leung) https://github.com/nodejs/node/pull/4704 * V8: * Add post mortem data to improve object inspection and function's context variables inspection (Fedor Indutny) https://github.com/nodejs/node/pull/3779 Semver Patch: * **buffer**: * ignore negative allocation lengths (Anna Henningsen) https://github.com/nodejs/node/pull/7562 * **crypto**: * update root certificates (Ben Noordhuis) https://github.com/nodejs/node/pull/7363 * **libuv**: * upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) https://github.com/nodejs/node/pull/6796 * upgrade libuv to 1.9.0 (Saúl Ibarra Corretgé) https://github.com/nodejs/node/pull/5994 * **npm**: * upgrade to 2.15.9 (Kat Marchán) https://github.com/nodejs/node/pull/7692 --- CHANGELOG.md | 295 +++++++++++++++++++++++++++++++++++++++++++++ src/node_version.h | 6 +- 2 files changed, 298 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a76ff31c02b991..82aab33ad43ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,300 @@ # Node.js ChangeLog +## 2016-08-15, Version 4.5.0 'Argon' (LTS), @thealphanerd + +### Notable Changes + +Semver Minor: + +* **buffer**: + * backport new buffer constructor APIs to v4.x (Сковорода Никита Андреевич) [#7562](https://github.com/nodejs/node/pull/7562) + * backport --zero-fill-buffers cli option (James M Snell) [#5745](https://github.com/nodejs/node/pull/5745) +* **build**: + * add Intel Vtune profiling support (Chunyang Dai) [#5527](https://github.com/nodejs/node/pull/5527) +* **repl**: + * copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](https://github.com/nodejs/node/pull/5958) +* **src**: + * add node::FreeEnvironment public API (Cheng Zhao) [#3098](https://github.com/nodejs/node/pull/3098) +* **test**: + * run v8 tests from node tree (Bryon Leung) [#4704](https://github.com/nodejs/node/pull/4704) +* **V8**: + * Add post mortem data to improve object inspection and function's context variables inspection (Fedor Indutny) [#3779](https://github.com/nodejs/node/pull/3779) + +Semver Patch: + +* **buffer**: + * ignore negative allocation lengths (Anna Henningsen) [#7562](https://github.com/nodejs/node/pull/7562) +* **crypto**: + * update root certificates (Ben Noordhuis) [#7363](https://github.com/nodejs/node/pull/7363) +* **libuv**: + * upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](https://github.com/nodejs/node/pull/6796) + * upgrade libuv to 1.9.0 (Saúl Ibarra Corretgé) [#5994](https://github.com/nodejs/node/pull/5994) +* **npm**: + * upgrade to 2.15.9 (Kat Marchán) [#7692](https://github.com/nodejs/node/pull/7692) + +### Commits + +* [[`a4888926a2`](https://github.com/nodejs/node/commit/a4888926a2)] - **assert**: remove unneeded arguments special handling (Rich Trott) [#7413](https://github.com/nodejs/node/pull/7413) +* [[`39e24742f8`](https://github.com/nodejs/node/commit/39e24742f8)] - **assert**: allow circular references (Rich Trott) [#6432](https://github.com/nodejs/node/pull/6432) +* [[`271927f29e`](https://github.com/nodejs/node/commit/271927f29e)] - **async_wrap**: pass uid to JS as double (Trevor Norris) [#7096](https://github.com/nodejs/node/pull/7096) +* [[`747f107188`](https://github.com/nodejs/node/commit/747f107188)] - **async_wrap**: don't abort on callback exception (Trevor Norris) [#5756](https://github.com/nodejs/node/pull/5756) +* [[`c06e2b07b6`](https://github.com/nodejs/node/commit/c06e2b07b6)] - **async_wrap**: notify post if intercepted exception (Trevor Norris) [#5756](https://github.com/nodejs/node/pull/5756) +* [[`0642a146b3`](https://github.com/nodejs/node/commit/0642a146b3)] - **async_wrap**: setupHooks now accepts object (Trevor Norris) [#5756](https://github.com/nodejs/node/pull/5756) +* [[`75ecf8eb07`](https://github.com/nodejs/node/commit/75ecf8eb07)] - **async_wrap**: add parent uid to init hook (Andreas Madsen) [#4600](https://github.com/nodejs/node/pull/4600) +* [[`e10eebffa5`](https://github.com/nodejs/node/commit/e10eebffa5)] - **async_wrap**: make uid the first argument in init (Andreas Madsen) [#4600](https://github.com/nodejs/node/pull/4600) +* [[`13d465bcf6`](https://github.com/nodejs/node/commit/13d465bcf6)] - **async_wrap**: add uid to all asyncWrap hooks (Andreas Madsen) [#4600](https://github.com/nodejs/node/pull/4600) +* [[`046d651118`](https://github.com/nodejs/node/commit/046d651118)] - **benchmark**: fix child-process-exec-stdout on win (Bartosz Sosnowski) [#7178](https://github.com/nodejs/node/pull/7178) +* [[`4b464ce4bf`](https://github.com/nodejs/node/commit/4b464ce4bf)] - **benchmark**: remove unused variables (Rich Trott) [#7600](https://github.com/nodejs/node/pull/7600) +* [[`b95e5d7948`](https://github.com/nodejs/node/commit/b95e5d7948)] - **benchmark**: add benchmark for url.format() (Rich Trott) [#7250](https://github.com/nodejs/node/pull/7250) +* [[`1bd62c7c34`](https://github.com/nodejs/node/commit/1bd62c7c34)] - **benchmark**: add benchmark for Buffer.concat (Anna Henningsen) [#7054](https://github.com/nodejs/node/pull/7054) +* [[`08cd81b050`](https://github.com/nodejs/node/commit/08cd81b050)] - **benchmark**: add util.format benchmark (Evan Lucas) [#5360](https://github.com/nodejs/node/pull/5360) +* [[`7dbb0d0084`](https://github.com/nodejs/node/commit/7dbb0d0084)] - **buffer**: fix dataview-set benchmark (Ingvar Stepanyan) [#6922](https://github.com/nodejs/node/pull/6922) +* [[`200429e9e1`](https://github.com/nodejs/node/commit/200429e9e1)] - **buffer**: ignore negative allocation lengths (Anna Henningsen) [#7562](https://github.com/nodejs/node/pull/7562) +* [[`709048134c`](https://github.com/nodejs/node/commit/709048134c)] - **(SEMVER-MINOR)** **buffer**: backport new buffer constructor APIs to v4.x (Сковорода Никита Андреевич) [#7562](https://github.com/nodejs/node/pull/7562) +* [[`fb03e57de2`](https://github.com/nodejs/node/commit/fb03e57de2)] - **(SEMVER-MINOR)** **buffer**: backport --zero-fill-buffers cli option (James M Snell) [#5745](https://github.com/nodejs/node/pull/5745) +* [[`236491e698`](https://github.com/nodejs/node/commit/236491e698)] - **build**: update build-addons when node-gyp changes (Lance Ball) [#6787](https://github.com/nodejs/node/pull/6787) +* [[`8a7c5fdbd2`](https://github.com/nodejs/node/commit/8a7c5fdbd2)] - **build**: add REPLACEME tag for version info in docs (Ben Noordhuis) [#6864](https://github.com/nodejs/node/pull/6864) +* [[`da1e13fde7`](https://github.com/nodejs/node/commit/da1e13fde7)] - **build**: add Make `doc-only` target (Jesse McCarthy) [#3888](https://github.com/nodejs/node/pull/3888) +* [[`0db3aa9afa`](https://github.com/nodejs/node/commit/0db3aa9afa)] - **build**: remove unused files from CPPLINT_FILES (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`5290c9d38c`](https://github.com/nodejs/node/commit/5290c9d38c)] - **build**: use BUILDTYPE when building V8 in Makefile (Michaël Zasso) [#7482](https://github.com/nodejs/node/pull/7482) +* [[`79bd39c202`](https://github.com/nodejs/node/commit/79bd39c202)] - **build**: add v8 requirement to test-v8* in Makefile (Michaël Zasso) [#7482](https://github.com/nodejs/node/pull/7482) +* [[`65b75b51a6`](https://github.com/nodejs/node/commit/65b75b51a6)] - **build**: unbreak configure with python 2.6 (Ben Noordhuis) [#6874](https://github.com/nodejs/node/pull/6874) +* [[`8513232c82`](https://github.com/nodejs/node/commit/8513232c82)] - **build**: split CI rules in Makefile (João Reis) [#7317](https://github.com/nodejs/node/pull/7317) +* [[`13d0e463b0`](https://github.com/nodejs/node/commit/13d0e463b0)] - **build**: enable compilation for linuxOne (Michael Dawson) [#5941](https://github.com/nodejs/node/pull/5941) +* [[`834ea2c5c0`](https://github.com/nodejs/node/commit/834ea2c5c0)] - **(SEMVER-MINOR)** **build,src**: add Intel Vtune profiling support (Chunyang Dai) [#5527](https://github.com/nodejs/node/pull/5527) +* [[`ea20796e9d`](https://github.com/nodejs/node/commit/ea20796e9d)] - **build,test**: fix build-addons dependency chain (Ben Noordhuis) [#6652](https://github.com/nodejs/node/pull/6652) +* [[`6a08535dd1`](https://github.com/nodejs/node/commit/6a08535dd1)] - **child_process**: preserve argument type (Rich Trott) [#7391](https://github.com/nodejs/node/pull/7391) +* [[`fd05b0b289`](https://github.com/nodejs/node/commit/fd05b0b289)] - ***Revert*** "**child_process**: measure buffer length in bytes" (Rich Trott) [#7391](https://github.com/nodejs/node/pull/7391) +* [[`8eb18e4289`](https://github.com/nodejs/node/commit/8eb18e4289)] - **child_process**: measure buffer length in bytes (Rich Trott) [#6764](https://github.com/nodejs/node/pull/6764) +* [[`4ee863d956`](https://github.com/nodejs/node/commit/4ee863d956)] - **child_process**: allow buffer encoding in spawnSync (cjihrig) [#6939](https://github.com/nodejs/node/pull/6939) +* [[`0b8124f205`](https://github.com/nodejs/node/commit/0b8124f205)] - **child_process**: emit IPC messages on next tick (cjihrig) [#6909](https://github.com/nodejs/node/pull/6909) +* [[`20d3378969`](https://github.com/nodejs/node/commit/20d3378969)] - **cluster**: reset handle index on close (Santiago Gimeno) [#6981](https://github.com/nodejs/node/pull/6981) +* [[`09349a8b92`](https://github.com/nodejs/node/commit/09349a8b92)] - **cluster**: don't send messages if no IPC channel (Santiago Gimeno) [#7132](https://github.com/nodejs/node/pull/7132) +* [[`6ece2a0322`](https://github.com/nodejs/node/commit/6ece2a0322)] - **cluster**: rewrite debug ports consistently (cjihrig) [#7050](https://github.com/nodejs/node/pull/7050) +* [[`8cba3b2f72`](https://github.com/nodejs/node/commit/8cba3b2f72)] - **cluster**: guard against undefined message handlers (cjihrig) [#6902](https://github.com/nodejs/node/pull/6902) +* [[`f152adf5b7`](https://github.com/nodejs/node/commit/f152adf5b7)] - **cluster**: close ownerless handles on disconnect() (cjihrig) [#6909](https://github.com/nodejs/node/pull/6909) +* [[`65624440bf`](https://github.com/nodejs/node/commit/65624440bf)] - **crypto**: allow GCM ciphers to have longer IV length (Michael Wain) [#6376](https://github.com/nodejs/node/pull/6376) +* [[`1e0cede3a6`](https://github.com/nodejs/node/commit/1e0cede3a6)] - **crypto**: update root certificates (Ben Noordhuis) [#7363](https://github.com/nodejs/node/pull/7363) +* [[`3be5cdcd43`](https://github.com/nodejs/node/commit/3be5cdcd43)] - **debugger**: remove obsolete setTimeout (Rich Trott) [#7154](https://github.com/nodejs/node/pull/7154) +* [[`74a5e911c0`](https://github.com/nodejs/node/commit/74a5e911c0)] - **debugger**: propagate --debug-port= to debuggee (Ben Noordhuis) [#3470](https://github.com/nodejs/node/pull/3470) +* [[`af4940d63b`](https://github.com/nodejs/node/commit/af4940d63b)] - **deps**: upgrade npm in LTS to 2.15.9 (Kat Marchán) [#7692](https://github.com/nodejs/node/pull/7692) +* [[`da7b74b9bc`](https://github.com/nodejs/node/commit/da7b74b9bc)] - **deps**: upgrade libuv to 1.9.1 (Saúl Ibarra Corretgé) [#6796](https://github.com/nodejs/node/pull/6796) +* [[`94eb980ca5`](https://github.com/nodejs/node/commit/94eb980ca5)] - **deps**: upgrade libuv to 1.9.0 (Saúl Ibarra Corretgé) [#5994](https://github.com/nodejs/node/pull/5994) +* [[`4107b5d200`](https://github.com/nodejs/node/commit/4107b5d200)] - **deps**: backport 22c5e46 from V8 (Julien Gilli) [#7584](https://github.com/nodejs/node/pull/7584) +* [[`e06ab64705`](https://github.com/nodejs/node/commit/e06ab64705)] - **deps**: update to http-parser 2.7.0 (Fedor Indutny) [#6279](https://github.com/nodejs/node/pull/6279) +* [[`1164f542db`](https://github.com/nodejs/node/commit/1164f542db)] - **deps**: fix segfault during gc (Ali Ijaz Sheikh) [#7303](https://github.com/nodejs/node/pull/7303) +* [[`d9e9d9fb11`](https://github.com/nodejs/node/commit/d9e9d9fb11)] - **deps**: backport e7cc609 from upstream V8 (Ali Ijaz Sheikh) [#7303](https://github.com/nodejs/node/pull/7303) +* [[`9809992436`](https://github.com/nodejs/node/commit/9809992436)] - **(SEMVER-MINOR)** **deps**: backport 9c927d0f01 from V8 upstream (Myles Borins) [#7451](https://github.com/nodejs/node/pull/7451) +* [[`da9595fc47`](https://github.com/nodejs/node/commit/da9595fc47)] - **(SEMVER-MINOR)** **deps**: cherry-pick 68e89fb from v8's upstream (Fedor Indutny) [#3779](https://github.com/nodejs/node/pull/3779) +* [[`e9ff0f8fb2`](https://github.com/nodejs/node/commit/e9ff0f8fb2)] - **doc**: make doc-only -> fallback to user binary (Robert Jefe Lindstaedt) [#6906](https://github.com/nodejs/node/pull/6906) +* [[`b869cdb876`](https://github.com/nodejs/node/commit/b869cdb876)] - **doc**: fix deprecation warnings in addon examples (Ben Noordhuis) [#6652](https://github.com/nodejs/node/pull/6652) +* [[`ec25f38120`](https://github.com/nodejs/node/commit/ec25f38120)] - **doc**: add `added:` information for buffer (Anna Henningsen) [#6495](https://github.com/nodejs/node/pull/6495) +* [[`1e86d16812`](https://github.com/nodejs/node/commit/1e86d16812)] - **doc**: buffers are not sent over IPC with a socket (Tim Kuijsten) [#6951](https://github.com/nodejs/node/pull/6951) +* [[`5c1d8e1f0f`](https://github.com/nodejs/node/commit/5c1d8e1f0f)] - **doc**: add `added:` information for http (Anna Henningsen) [#7392](https://github.com/nodejs/node/pull/7392) +* [[`60c054bc11`](https://github.com/nodejs/node/commit/60c054bc11)] - **doc**: add information for IncomingMessage.destroy() (Rich Trott) [#7237](https://github.com/nodejs/node/pull/7237) +* [[`1a5c025f32`](https://github.com/nodejs/node/commit/1a5c025f32)] - **doc**: remove superfluos backticks in process.md (Anna Henningsen) [#7681](https://github.com/nodejs/node/pull/7681) +* [[`fcb4e410e4`](https://github.com/nodejs/node/commit/fcb4e410e4)] - **doc**: add `added:` information for process (Bryan English) [#6589](https://github.com/nodejs/node/pull/6589) +* [[`9b8565c42a`](https://github.com/nodejs/node/commit/9b8565c42a)] - **doc**: add `added:` information for tls (Italo A. Casas) [#7018](https://github.com/nodejs/node/pull/7018) +* [[`fd4aa6c16a`](https://github.com/nodejs/node/commit/fd4aa6c16a)] - **doc**: correct `added:` information for fs.access (Richard Lau) [#7299](https://github.com/nodejs/node/pull/7299) +* [[`1e9d27cbcc`](https://github.com/nodejs/node/commit/1e9d27cbcc)] - **doc**: add `added:` information for fs (Anna Henningsen) [#6717](https://github.com/nodejs/node/pull/6717) +* [[`2244a3c250`](https://github.com/nodejs/node/commit/2244a3c250)] - **doc**: adds 'close' events to fs.ReadStream and fs.WriteStream (Jenna Vuong) [#6499](https://github.com/nodejs/node/pull/6499) +* [[`88f46b886a`](https://github.com/nodejs/node/commit/88f46b886a)] - **doc**: add `added:` information for timers (Anna Henningsen) [#7493](https://github.com/nodejs/node/pull/7493) +* [[`a53253a232`](https://github.com/nodejs/node/commit/a53253a232)] - **doc**: add `added:` information for zlib (Anna Henningsen) [#6840](https://github.com/nodejs/node/pull/6840) +* [[`7abfb6e8dc`](https://github.com/nodejs/node/commit/7abfb6e8dc)] - **doc**: add `added:` information for vm (Anna Henningsen) [#7011](https://github.com/nodejs/node/pull/7011) +* [[`3e3471fb5f`](https://github.com/nodejs/node/commit/3e3471fb5f)] - **doc**: add `added:` information for v8 (Rich Trott) [#6684](https://github.com/nodejs/node/pull/6684) +* [[`1758f02ec1`](https://github.com/nodejs/node/commit/1758f02ec1)] - **doc**: add `added:` information for url (Bryan English) [#6593](https://github.com/nodejs/node/pull/6593) +* [[`3c8f19fcdf`](https://github.com/nodejs/node/commit/3c8f19fcdf)] - **doc**: add `added:` in for `tty` (Rich Trott) [#6783](https://github.com/nodejs/node/pull/6783) +* [[`5b50b1c255`](https://github.com/nodejs/node/commit/5b50b1c255)] - **doc**: add `added:` info for `string_decoder` (Rich Trott) [#6741](https://github.com/nodejs/node/pull/6741) +* [[`4474e83b78`](https://github.com/nodejs/node/commit/4474e83b78)] - **doc**: add `added:` information for repl (Anna Henningsen) [#7256](https://github.com/nodejs/node/pull/7256) +* [[`e6d7bfcbe7`](https://github.com/nodejs/node/commit/e6d7bfcbe7)] - **doc**: add `added:` information for readline (Julian Duque) [#6996](https://github.com/nodejs/node/pull/6996) +* [[`eec0c635ee`](https://github.com/nodejs/node/commit/eec0c635ee)] - **doc**: add `added:` information for querystring (Bryan English) [#6593](https://github.com/nodejs/node/pull/6593) +* [[`a870cdcd1f`](https://github.com/nodejs/node/commit/a870cdcd1f)] - **doc**: add `added:` information for punycode (Daniel Wang) [#6805](https://github.com/nodejs/node/pull/6805) +* [[`f1a37ad749`](https://github.com/nodejs/node/commit/f1a37ad749)] - **doc**: add `added:` information for path (Julian Duque) [#6985](https://github.com/nodejs/node/pull/6985) +* [[`8b53f4b27c`](https://github.com/nodejs/node/commit/8b53f4b27c)] - **doc**: add `added:` information for os (Bryan English) [#6609](https://github.com/nodejs/node/pull/6609) +* [[`78d361b22b`](https://github.com/nodejs/node/commit/78d361b22b)] - **doc**: add `added` information for net (Italo A. Casas) [#7038](https://github.com/nodejs/node/pull/7038) +* [[`b08ff33c01`](https://github.com/nodejs/node/commit/b08ff33c01)] - **doc**: add `added:` information for https (Anna Henningsen) [#7392](https://github.com/nodejs/node/pull/7392) +* [[`1d99059bb1`](https://github.com/nodejs/node/commit/1d99059bb1)] - **doc**: add `added:` information for dns (Julian Duque) [#7021](https://github.com/nodejs/node/pull/7021) +* [[`a0ca24b798`](https://github.com/nodejs/node/commit/a0ca24b798)] - **doc**: add `added:` information for console (Adrian Estrada) [#6995](https://github.com/nodejs/node/pull/6995) +* [[`eb08c17a20`](https://github.com/nodejs/node/commit/eb08c17a20)] - **doc**: add `added: ` data for cli.md (Rich Trott) [#6960](https://github.com/nodejs/node/pull/6960) +* [[`ec9038478f`](https://github.com/nodejs/node/commit/ec9038478f)] - **doc**: add `added:` information for child_process (Anna Henningsen) [#6927](https://github.com/nodejs/node/pull/6927) +* [[`e52b2b07d7`](https://github.com/nodejs/node/commit/e52b2b07d7)] - **doc**: add `added:` information for assert (Rich Trott) [#6688](https://github.com/nodejs/node/pull/6688) +* [[`75e4f74c54`](https://github.com/nodejs/node/commit/75e4f74c54)] - **doc**: fix cluster worker 'message' event (cjihrig) [#7309](https://github.com/nodejs/node/pull/7309) +* [[`de5e2357fc`](https://github.com/nodejs/node/commit/de5e2357fc)] - **doc**: dns.resolve fix callback argument description (Quentin Headen) [#7532](https://github.com/nodejs/node/pull/7532) +* [[`0f903bb722`](https://github.com/nodejs/node/commit/0f903bb722)] - **doc**: add benchmark who-to-CC info (Rich Trott) [#7604](https://github.com/nodejs/node/pull/7604) +* [[`700c6d9be8`](https://github.com/nodejs/node/commit/700c6d9be8)] - **doc**: added information on how to run the linter. (Diosney Sarmiento) [#7534](https://github.com/nodejs/node/pull/7534) +* [[`537f33351e`](https://github.com/nodejs/node/commit/537f33351e)] - **doc**: fix minor style issues in http.md (Rich Trott) [#7528](https://github.com/nodejs/node/pull/7528) +* [[`33a08b0414`](https://github.com/nodejs/node/commit/33a08b0414)] - **doc**: add bartosz sosnowski to colaborators (Bartosz Sosnowski) [#7567](https://github.com/nodejs/node/pull/7567) +* [[`186af29298`](https://github.com/nodejs/node/commit/186af29298)] - **doc**: fix detached child stdio example (cjihrig) [#7540](https://github.com/nodejs/node/pull/7540) +* [[`066cefb6de`](https://github.com/nodejs/node/commit/066cefb6de)] - **doc**: improve usage of `zero`/`0` (Rich Trott) [#7466](https://github.com/nodejs/node/pull/7466) +* [[`6c94c67b73`](https://github.com/nodejs/node/commit/6c94c67b73)] - **doc**: fix "sign.verify" typo in crypto doc. (Ruslan Iusupov) [#7411](https://github.com/nodejs/node/pull/7411) +* [[`35ee35cba2`](https://github.com/nodejs/node/commit/35ee35cba2)] - **doc**: clarify child_process stdout/stderr types (sartrey) [#7361](https://github.com/nodejs/node/pull/7361) +* [[`71ef71cff8`](https://github.com/nodejs/node/commit/71ef71cff8)] - **doc**: add CTC meeting minutes 2016-06-15 (Josh Gavant) [#7320](https://github.com/nodejs/node/pull/7320) +* [[`13d60cab7c`](https://github.com/nodejs/node/commit/13d60cab7c)] - **doc**: add lance to collaborators (Lance Ball) [#7407](https://github.com/nodejs/node/pull/7407) +* [[`9122b3b665`](https://github.com/nodejs/node/commit/9122b3b665)] - **doc**: update "who to cc in issues" chart (Jeremiah Senkpiel) [#6694](https://github.com/nodejs/node/pull/6694) +* [[`ccb278d330`](https://github.com/nodejs/node/commit/ccb278d330)] - **doc**: mention http request "aborted" events (Kyle E. Mitchell) [#7270](https://github.com/nodejs/node/pull/7270) +* [[`868af29f2b`](https://github.com/nodejs/node/commit/868af29f2b)] - **doc**: add RReverser to collaborators (Ingvar Stepanyan) [#7370](https://github.com/nodejs/node/pull/7370) +* [[`f8fe474825`](https://github.com/nodejs/node/commit/f8fe474825)] - **doc**: fixing minor typo in AtExit hooks section (Daniel Bevenius) [#7485](https://github.com/nodejs/node/pull/7485) +* [[`4a7e333287`](https://github.com/nodejs/node/commit/4a7e333287)] - **doc**: use `Buffer.byteLength` for Content-Length (kimown) [#7274](https://github.com/nodejs/node/pull/7274) +* [[`85f70b36e4`](https://github.com/nodejs/node/commit/85f70b36e4)] - **doc**: clarify use of `0` port value (Rich Trott) [#7206](https://github.com/nodejs/node/pull/7206) +* [[`57ba51ec46`](https://github.com/nodejs/node/commit/57ba51ec46)] - **doc**: fix IRC link (Ilkka Myller) [#7210](https://github.com/nodejs/node/pull/7210) +* [[`ef37a2e80f`](https://github.com/nodejs/node/commit/ef37a2e80f)] - **doc**: add internal link in GOVERNANCE.md (Rich Trott) [#7279](https://github.com/nodejs/node/pull/7279) +* [[`c9ef04a1b2`](https://github.com/nodejs/node/commit/c9ef04a1b2)] - **doc**: fix events typo (Greyson Parrelli) [#7329](https://github.com/nodejs/node/pull/7329) +* [[`0013af61de`](https://github.com/nodejs/node/commit/0013af61de)] - **doc**: fix header depth of util.isSymbol (James M Snell) [#7138](https://github.com/nodejs/node/pull/7138) +* [[`96de3f8820`](https://github.com/nodejs/node/commit/96de3f8820)] - **doc**: Add CII Best Practices badge to README.md (David A. Wheeler) [#6819](https://github.com/nodejs/node/pull/6819) +* [[`146cba1f60`](https://github.com/nodejs/node/commit/146cba1f60)] - **doc**: improve debugger doc prose (Rich Trott) [#7007](https://github.com/nodejs/node/pull/7007) +* [[`694e34458b`](https://github.com/nodejs/node/commit/694e34458b)] - **doc**: fix typos in WORKING_GROUPS.md (Joao Andrade) [#7032](https://github.com/nodejs/node/pull/7032) +* [[`fbdc16a8a4`](https://github.com/nodejs/node/commit/fbdc16a8a4)] - **doc**: update labels and CI info in onboarding doc (Rich Trott) [#7006](https://github.com/nodejs/node/pull/7006) +* [[`1c65f1e3f6`](https://github.com/nodejs/node/commit/1c65f1e3f6)] - **doc**: add info on what's used for fswatch on AIX (Michael Dawson) [#6837](https://github.com/nodejs/node/pull/6837) +* [[`72e8ee570a`](https://github.com/nodejs/node/commit/72e8ee570a)] - **doc**: improve server.listen() documentation prose (Rich Trott) [#7000](https://github.com/nodejs/node/pull/7000) +* [[`649d201d63`](https://github.com/nodejs/node/commit/649d201d63)] - **doc**: improve `server.address()` doc text (Rich Trott) [#7001](https://github.com/nodejs/node/pull/7001) +* [[`e2e85ced1d`](https://github.com/nodejs/node/commit/e2e85ced1d)] - **doc**: clarified use of sexual language in the CoC (Bryan Hughes) [#6973](https://github.com/nodejs/node/pull/6973) +* [[`f395f6f5b2`](https://github.com/nodejs/node/commit/f395f6f5b2)] - **doc**: add yorkie to collaborators (Yazhong Liu) [#7004](https://github.com/nodejs/node/pull/7004) +* [[`c5051ef643`](https://github.com/nodejs/node/commit/c5051ef643)] - **doc**: add firedfox to collaborators (Daniel Wang) [#6961](https://github.com/nodejs/node/pull/6961) +* [[`2ef08323c6`](https://github.com/nodejs/node/commit/2ef08323c6)] - **doc**: add bmeck to collaborators (Bradley Meck) [#6962](https://github.com/nodejs/node/pull/6962) +* [[`d1a0a146b3`](https://github.com/nodejs/node/commit/d1a0a146b3)] - **doc**: Add CTC meeting minutes for 2016-05-04 (Michael Dawson) [#6579](https://github.com/nodejs/node/pull/6579) +* [[`0a85987899`](https://github.com/nodejs/node/commit/0a85987899)] - **doc**: update build instructions for Windows (João Reis) [#7285](https://github.com/nodejs/node/pull/7285) +* [[`629a76f9fb`](https://github.com/nodejs/node/commit/629a76f9fb)] - **doc**: remove cluster.setupMaster() myth (cjihrig) [#7179](https://github.com/nodejs/node/pull/7179) +* [[`5b807ac791`](https://github.com/nodejs/node/commit/5b807ac791)] - **doc**: specify how to link issues in commit log (Luigi Pinca) [#7161](https://github.com/nodejs/node/pull/7161) +* [[`350f4cf292`](https://github.com/nodejs/node/commit/350f4cf292)] - **doc**: server.listen truncates socket path on unix (Jean Regisser) [#6659](https://github.com/nodejs/node/pull/6659) +* [[`7813af7f16`](https://github.com/nodejs/node/commit/7813af7f16)] - **doc**: Add resolveNaptr and naptr rrtype docs (Doug Wade) [#6586](https://github.com/nodejs/node/pull/6586) +* [[`5380743208`](https://github.com/nodejs/node/commit/5380743208)] - **doc**: document socket.destroyed (Tushar Mathur) [#6128](https://github.com/nodejs/node/pull/6128) +* [[`f0edf87df1`](https://github.com/nodejs/node/commit/f0edf87df1)] - **doc**: add vm example, be able to require modules (Robert Jefe Lindstaedt) [#5323](https://github.com/nodejs/node/pull/5323) +* [[`9121e94e62`](https://github.com/nodejs/node/commit/9121e94e62)] - **doc**: note that process.config can and will be changed (James M Snell) [#6266](https://github.com/nodejs/node/pull/6266) +* [[`c237ac3d68`](https://github.com/nodejs/node/commit/c237ac3d68)] - **doc**: git mv to .md (Robert Jefe Lindstaedt) [#4747](https://github.com/nodejs/node/pull/4747) +* [[`6324723cc1`](https://github.com/nodejs/node/commit/6324723cc1)] - **doc,dgram**: fix addMembership documentation (Santiago Gimeno) [#7244](https://github.com/nodejs/node/pull/7244) +* [[`15bb0beab2`](https://github.com/nodejs/node/commit/15bb0beab2)] - **doc,test**: add `How to write a Node.js test` guide (Santiago Gimeno) [#6984](https://github.com/nodejs/node/pull/6984) +* [[`9d13337183`](https://github.com/nodejs/node/commit/9d13337183)] - **http**: wait for both prefinish/end to keepalive (Fedor Indutny) [#7149](https://github.com/nodejs/node/pull/7149) +* [[`ece428ea63`](https://github.com/nodejs/node/commit/ece428ea63)] - **http**: fix no dumping after `maybeReadMore` (Fedor Indutny) [#7211](https://github.com/nodejs/node/pull/7211) +* [[`07fd52e5aa`](https://github.com/nodejs/node/commit/07fd52e5aa)] - **http**: skip body and next message of CONNECT res (Fedor Indutny) [#6279](https://github.com/nodejs/node/pull/6279) +* [[`6f312b3a91`](https://github.com/nodejs/node/commit/6f312b3a91)] - **http_parser**: use `MakeCallback` (Trevor Norris) [#5419](https://github.com/nodejs/node/pull/5419) +* [[`373ffc5bad`](https://github.com/nodejs/node/commit/373ffc5bad)] - **installer**: don't install node_internals.h (Ben Noordhuis) [#6913](https://github.com/nodejs/node/pull/6913) +* [[`5782ec2427`](https://github.com/nodejs/node/commit/5782ec2427)] - **module**: don't cache uninitialized builtins (Anna Henningsen) [#6907](https://github.com/nodejs/node/pull/6907) +* [[`c8e9adb135`](https://github.com/nodejs/node/commit/c8e9adb135)] - **repl**: fix tab completion for defined commands (Prince J Wesley) [#7364](https://github.com/nodejs/node/pull/7364) +* [[`a3fa5db5ca`](https://github.com/nodejs/node/commit/a3fa5db5ca)] - **(SEMVER-MINOR)** **repl**: copying tabs shouldn't trigger completion (Eugene Obrezkov) [#5958](https://github.com/nodejs/node/pull/5958) +* [[`d86332799c`](https://github.com/nodejs/node/commit/d86332799c)] - **src**: clean up string_search (Brian White) [#7174](https://github.com/nodejs/node/pull/7174) +* [[`3eea55167d`](https://github.com/nodejs/node/commit/3eea55167d)] - **src**: fix memory leak in WriteBuffers() error path (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`23797eb037`](https://github.com/nodejs/node/commit/23797eb037)] - **src**: remove obsolete NOLINT comments (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`5aff60e832`](https://github.com/nodejs/node/commit/5aff60e832)] - **src**: lint v8abbr.h (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`42e7c9d266`](https://github.com/nodejs/node/commit/42e7c9d266)] - **src**: lint node_lttng_tp.h (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`27c2d25be6`](https://github.com/nodejs/node/commit/27c2d25be6)] - **src**: lint node_win32_perfctr_provider.cc (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`4f4d3e77ef`](https://github.com/nodejs/node/commit/4f4d3e77ef)] - **src**: fix whitespace/indent cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`066064d65f`](https://github.com/nodejs/node/commit/066064d65f)] - **src**: fix whitespace/blank_line cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`44cbe0356d`](https://github.com/nodejs/node/commit/44cbe0356d)] - **src**: fix runtime/references cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`f530a36c65`](https://github.com/nodejs/node/commit/f530a36c65)] - **src**: fix runtime/int cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`d6595adcdb`](https://github.com/nodejs/node/commit/d6595adcdb)] - **src**: fix runtime/indentation_namespace warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`68db091aba`](https://github.com/nodejs/node/commit/68db091aba)] - **src**: fix readability/nolint cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`4748bed736`](https://github.com/nodejs/node/commit/4748bed736)] - **src**: fix readability/namespace cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`785211702a`](https://github.com/nodejs/node/commit/785211702a)] - **src**: fix readability/inheritance cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`c90ae7fb72`](https://github.com/nodejs/node/commit/c90ae7fb72)] - **src**: fix readability/constructors cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`16f2497994`](https://github.com/nodejs/node/commit/16f2497994)] - **src**: fix readability/braces cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`c8f78a2682`](https://github.com/nodejs/node/commit/c8f78a2682)] - **src**: fix build/header_guard cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`ccc701e1d5`](https://github.com/nodejs/node/commit/ccc701e1d5)] - **src**: fix build/c++tr1 cpplint warnings (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`dda81b44b0`](https://github.com/nodejs/node/commit/dda81b44b0)] - **src**: unify implementations of Utf8Value etc. (Anna Henningsen) [#6357](https://github.com/nodejs/node/pull/6357) +* [[`db2b23f06f`](https://github.com/nodejs/node/commit/db2b23f06f)] - **src**: fix sporadic deadlock in SIGUSR1 handler (Ben Noordhuis) [#5904](https://github.com/nodejs/node/pull/5904) +* [[`53a67ed6d7`](https://github.com/nodejs/node/commit/53a67ed6d7)] - **src**: fix bad logic in uid/gid checks (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`e6a27a70d8`](https://github.com/nodejs/node/commit/e6a27a70d8)] - **src**: fix use-after-return in zlib bindings (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`61de6e9b47`](https://github.com/nodejs/node/commit/61de6e9b47)] - **src**: remove deprecated HMAC_Init, use HMAC_Init_ex (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`7305e7b9d2`](https://github.com/nodejs/node/commit/7305e7b9d2)] - **src**: remove duplicate HMAC_Init calls (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`38baf6a0b7`](https://github.com/nodejs/node/commit/38baf6a0b7)] - **src**: remove unused md_ data members (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`e103044b68`](https://github.com/nodejs/node/commit/e103044b68)] - **src**: remove unused data member write_queue_size_ (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`67937bca0a`](https://github.com/nodejs/node/commit/67937bca0a)] - **src**: guard against starting fs watcher twice (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`c03bd57ac6`](https://github.com/nodejs/node/commit/c03bd57ac6)] - **src**: check uv_async_init() return value (Ben Noordhuis) [#7374](https://github.com/nodejs/node/pull/7374) +* [[`2b0dce5a5b`](https://github.com/nodejs/node/commit/2b0dce5a5b)] - **src**: don't use locale-sensitive strcasecmp() (Ben Noordhuis) [#6582](https://github.com/nodejs/node/pull/6582) +* [[`9c31c738fc`](https://github.com/nodejs/node/commit/9c31c738fc)] - **src**: remove unused #include statement (Ben Noordhuis) [#6582](https://github.com/nodejs/node/pull/6582) +* [[`426aa0a5e8`](https://github.com/nodejs/node/commit/426aa0a5e8)] - **src**: fix Windows segfault with `--eval` (Bryce Simonds) [#6938](https://github.com/nodejs/node/pull/6938) +* [[`b21d145c2a`](https://github.com/nodejs/node/commit/b21d145c2a)] - **(SEMVER-MINOR)** **src**: add node::FreeEnvironment public API (Cheng Zhao) [#3098](https://github.com/nodejs/node/pull/3098) +* [[`b9136c0c03`](https://github.com/nodejs/node/commit/b9136c0c03)] - **src**: add process.binding('config') (James M Snell) [#6266](https://github.com/nodejs/node/pull/6266) +* [[`c3d87eee49`](https://github.com/nodejs/node/commit/c3d87eee49)] - **src**: reword command and add ternary (Trevor Norris) [#5756](https://github.com/nodejs/node/pull/5756) +* [[`68f391bf3b`](https://github.com/nodejs/node/commit/68f391bf3b)] - **src**: remove unnecessary check (Brian White) [#5233](https://github.com/nodejs/node/pull/5233) +* [[`981bbcd925`](https://github.com/nodejs/node/commit/981bbcd925)] - **src**: remove TryCatch in MakeCallback (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`48b7b71352`](https://github.com/nodejs/node/commit/48b7b71352)] - **src**: remove unused TickInfo::in_tick() (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`d77b28c6b3`](https://github.com/nodejs/node/commit/d77b28c6b3)] - **src**: remove unused of TickInfo::last_threw() (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`cb291d5c7f`](https://github.com/nodejs/node/commit/cb291d5c7f)] - **src**: add AsyncCallbackScope (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`2eb097f212`](https://github.com/nodejs/node/commit/2eb097f212)] - **src**: fix MakeCallback error handling (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`63356df39c`](https://github.com/nodejs/node/commit/63356df39c)] - **src,http**: fix uncaughtException miss in http (Trevor Norris) [#5591](https://github.com/nodejs/node/pull/5591) +* [[`ee7040568d`](https://github.com/nodejs/node/commit/ee7040568d)] - **src,http_parser**: remove KickNextTick call (Trevor Norris) [#5756](https://github.com/nodejs/node/pull/5756) +* [[`9a8acad6ff`](https://github.com/nodejs/node/commit/9a8acad6ff)] - **test**: use random ports where possible (Brian White) [#7045](https://github.com/nodejs/node/pull/7045) +* [[`223c0e2010`](https://github.com/nodejs/node/commit/223c0e2010)] - **test**: skip doctool tests when js-yaml is missing (Anna Henningsen) [#7218](https://github.com/nodejs/node/pull/7218) +* [[`3681b9b868`](https://github.com/nodejs/node/commit/3681b9b868)] - **test**: refactor doctool tests (Rich Trott) [#6719](https://github.com/nodejs/node/pull/6719) +* [[`686d7b329c`](https://github.com/nodejs/node/commit/686d7b329c)] - **test**: build addons with V8_DEPRECATION_WARNINGS=1 (Ben Noordhuis) [#6652](https://github.com/nodejs/node/pull/6652) +* [[`8404e34665`](https://github.com/nodejs/node/commit/8404e34665)] - ***Revert*** "**test**: mark test-vm-timeout flaky on windows" (Anna Henningsen) [#7373](https://github.com/nodejs/node/pull/7373) +* [[`eab9ced2ee`](https://github.com/nodejs/node/commit/eab9ced2ee)] - **test**: fix flaky test-vm-timeout (Anna Henningsen) [#7373](https://github.com/nodejs/node/pull/7373) +* [[`a31d3161f5`](https://github.com/nodejs/node/commit/a31d3161f5)] - **test**: add test for exec() known issue (Rich Trott) [#7375](https://github.com/nodejs/node/pull/7375) +* [[`1baa145a16`](https://github.com/nodejs/node/commit/1baa145a16)] - **test**: remove internet/test-tls-connnect-cnnic (Ben Noordhuis) [#7363](https://github.com/nodejs/node/pull/7363) +* [[`e3097b7cdf`](https://github.com/nodejs/node/commit/e3097b7cdf)] - **test**: test isFullWidthCodePoint with invalid input (Rich Trott) [#7422](https://github.com/nodejs/node/pull/7422) +* [[`f0b0fc49f9`](https://github.com/nodejs/node/commit/f0b0fc49f9)] - **test**: update weak module for gc tests (Rich Trott) [#7014](https://github.com/nodejs/node/pull/7014) +* [[`1d100f6853`](https://github.com/nodejs/node/commit/1d100f6853)] - **test**: remove unused vars from http/https tests (Rich Trott) [#7598](https://github.com/nodejs/node/pull/7598) +* [[`3241536d95`](https://github.com/nodejs/node/commit/3241536d95)] - **test**: remove unused var in net-server-try-ports (Rich Trott) [#7597](https://github.com/nodejs/node/pull/7597) +* [[`7bd7c235fa`](https://github.com/nodejs/node/commit/7bd7c235fa)] - **test**: remove unused var from stream2 test (Rich Trott) [#7596](https://github.com/nodejs/node/pull/7596) +* [[`4d36a67738`](https://github.com/nodejs/node/commit/4d36a67738)] - **test**: remove unused var from child-process-fork (Rich Trott) [#7599](https://github.com/nodejs/node/pull/7599) +* [[`b5e516a42c`](https://github.com/nodejs/node/commit/b5e516a42c)] - **test**: remove unused var in test-tls-server-verify (Rich Trott) [#7595](https://github.com/nodejs/node/pull/7595) +* [[`db35efa6c1`](https://github.com/nodejs/node/commit/db35efa6c1)] - **test**: fix flaky test-net-write-slow (Rich Trott) [#7555](https://github.com/nodejs/node/pull/7555) +* [[`8273824ca3`](https://github.com/nodejs/node/commit/8273824ca3)] - **test**: remove common.PORT from http tests (Rich Trott) [#7467](https://github.com/nodejs/node/pull/7467) +* [[`5129f3f2cd`](https://github.com/nodejs/node/commit/5129f3f2cd)] - **test**: mark test-vm-timeout flaky on windows (Rich Trott) [#7359](https://github.com/nodejs/node/pull/7359) +* [[`79b45886c1`](https://github.com/nodejs/node/commit/79b45886c1)] - **test**: add tests for some stream.Readable uses (Anna Henningsen) [#7260](https://github.com/nodejs/node/pull/7260) +* [[`65b5cccee9`](https://github.com/nodejs/node/commit/65b5cccee9)] - **test**: fix spawn on windows (Brian White) [#7049](https://github.com/nodejs/node/pull/7049) +* [[`96ed883d2f`](https://github.com/nodejs/node/commit/96ed883d2f)] - **test**: enable test-debug-brk-no-arg (Rich Trott) [#7143](https://github.com/nodejs/node/pull/7143) +* [[`8724c442f3`](https://github.com/nodejs/node/commit/8724c442f3)] - **test**: add test for uid/gid setting in spawn (Rich Trott) [#7084](https://github.com/nodejs/node/pull/7084) +* [[`042e858dfb`](https://github.com/nodejs/node/commit/042e858dfb)] - **test**: make test-child-process-fork-net more robust (Rich Trott) [#7033](https://github.com/nodejs/node/pull/7033) +* [[`2a59e4e73d`](https://github.com/nodejs/node/commit/2a59e4e73d)] - **test**: improve debug-break-on-uncaught reliability (Rich Trott) [#6793](https://github.com/nodejs/node/pull/6793) +* [[`77325d585e`](https://github.com/nodejs/node/commit/77325d585e)] - **test**: remove disabled eio race test (Rich Trott) [#7083](https://github.com/nodejs/node/pull/7083) +* [[`5b1f54678b`](https://github.com/nodejs/node/commit/5b1f54678b)] - **test**: remove non-incremental common.PORT changes (Rich Trott) [#7055](https://github.com/nodejs/node/pull/7055) +* [[`44228dfdef`](https://github.com/nodejs/node/commit/44228dfdef)] - **test**: remove `common.PORT` from gc tests (Rich Trott) [#7013](https://github.com/nodejs/node/pull/7013) +* [[`644bfe14a6`](https://github.com/nodejs/node/commit/644bfe14a6)] - **test**: fix test-debug-port-numbers on OS X (Santiago Gimeno) [#7046](https://github.com/nodejs/node/pull/7046) +* [[`cde3014f78`](https://github.com/nodejs/node/commit/cde3014f78)] - **test**: remove modifcation to common.PORT (Rich Trott) [#6990](https://github.com/nodejs/node/pull/6990) +* [[`8c412af7ac`](https://github.com/nodejs/node/commit/8c412af7ac)] - **test**: verify cluster worker exit (cjihrig) [#6993](https://github.com/nodejs/node/pull/6993) +* [[`7d6acefbcc`](https://github.com/nodejs/node/commit/7d6acefbcc)] - **test**: listen on and connect to 127.0.0.1 (Ben Noordhuis) [#7524](https://github.com/nodejs/node/pull/7524) +* [[`ecf5c1cb25`](https://github.com/nodejs/node/commit/ecf5c1cb25)] - **test**: refactor spawnSync() cwd test (cjihrig) [#6939](https://github.com/nodejs/node/pull/6939) +* [[`9cccaa3c80`](https://github.com/nodejs/node/commit/9cccaa3c80)] - **test**: fix component printing on windows (Ben Noordhuis) [#6915](https://github.com/nodejs/node/pull/6915) +* [[`af4b56d6be`](https://github.com/nodejs/node/commit/af4b56d6be)] - **test**: pass python path to node-gyp (hefangshi) [#6646](https://github.com/nodejs/node/pull/6646) +* [[`7c55f59214`](https://github.com/nodejs/node/commit/7c55f59214)] - **test**: make stdout buffer test more robust (Rich Trott) [#6633](https://github.com/nodejs/node/pull/6633) +* [[`3aef9b813f`](https://github.com/nodejs/node/commit/3aef9b813f)] - **test**: unmark test-http-regr-gh-2928 as flaky (Rich Trott) [#6540](https://github.com/nodejs/node/pull/6540) +* [[`2259e5db69`](https://github.com/nodejs/node/commit/2259e5db69)] - **test**: avoid test-cluster-master-* flakiness (Stefan Budeanu) [#6531](https://github.com/nodejs/node/pull/6531) +* [[`5f444ed6a3`](https://github.com/nodejs/node/commit/5f444ed6a3)] - **test**: add tests for stream3 buffering using cork (Alex J Burke) [#6493](https://github.com/nodejs/node/pull/6493) +* [[`01b314d165`](https://github.com/nodejs/node/commit/01b314d165)] - **test**: test TTY problems by fakeing a TTY using openpty (Jeremiah Senkpiel) [#6895](https://github.com/nodejs/node/pull/6895) +* [[`55f8689711`](https://github.com/nodejs/node/commit/55f8689711)] - **test**: add test for responses to HTTP CONNECT req (Josh Leder) [#6279](https://github.com/nodejs/node/pull/6279) +* [[`9aec1ddb4f`](https://github.com/nodejs/node/commit/9aec1ddb4f)] - **test**: test cluster worker disconnection on error (Santiago Gimeno) [#6909](https://github.com/nodejs/node/pull/6909) +* [[`c0a42bc040`](https://github.com/nodejs/node/commit/c0a42bc040)] - **test**: verify IPC messages are emitted on next tick (Santiago Gimeno) [#6909](https://github.com/nodejs/node/pull/6909) +* [[`9606f768ea`](https://github.com/nodejs/node/commit/9606f768ea)] - **(SEMVER-MINOR)** **test**: run v8 tests from node tree (Bryon Leung) [#4704](https://github.com/nodejs/node/pull/4704) +* [[`efdeb69c9a`](https://github.com/nodejs/node/commit/efdeb69c9a)] - **test**: work around debugger not killing inferior (Ben Noordhuis) [#7037](https://github.com/nodejs/node/pull/7037) +* [[`e3f9bc893f`](https://github.com/nodejs/node/commit/e3f9bc893f)] - **test**: use strictEqual consistently in agent test (Ben Noordhuis) [#6654](https://github.com/nodejs/node/pull/6654) +* [[`1186b7a401`](https://github.com/nodejs/node/commit/1186b7a401)] - **test**: add addons test for MakeCallback (Trevor Norris) [#4507](https://github.com/nodejs/node/pull/4507) +* [[`8f76d7db03`](https://github.com/nodejs/node/commit/8f76d7db03)] - **test,tools**: test yaml parsing of doctool (Anna Henningsen) [#6495](https://github.com/nodejs/node/pull/6495) +* [[`e544b1c40c`](https://github.com/nodejs/node/commit/e544b1c40c)] - **test,win**: skip addons/load-long-path on WOW64 (Alexis Campailla) [#6675](https://github.com/nodejs/node/pull/6675) +* [[`b956635e41`](https://github.com/nodejs/node/commit/b956635e41)] - **tls**: catch `certCbDone` exceptions (Fedor Indutny) [#6887](https://github.com/nodejs/node/pull/6887) +* [[`06327e5eed`](https://github.com/nodejs/node/commit/06327e5eed)] - **tls**: use process.binding('config') to detect fips mode (James M Snell) [#7551](https://github.com/nodejs/node/pull/7551) +* [[`c807287e80`](https://github.com/nodejs/node/commit/c807287e80)] - **tls,https**: respect address family when connecting (Ben Noordhuis) [#6654](https://github.com/nodejs/node/pull/6654) +* [[`9ef6e23088`](https://github.com/nodejs/node/commit/9ef6e23088)] - **tools**: make sure doctool anchors respect includes (Anna Henningsen) [#6943](https://github.com/nodejs/node/pull/6943) +* [[`f9f85a006f`](https://github.com/nodejs/node/commit/f9f85a006f)] - **tools**: restore change of signatures to opts hashes (Jesse McCarthy) [#6690](https://github.com/nodejs/node/pull/6690) +* [[`607173bbac`](https://github.com/nodejs/node/commit/607173bbac)] - **tools**: fix regression in doctool (Myles Borins) [#6680](https://github.com/nodejs/node/pull/6680) +* [[`ed193ad8ae`](https://github.com/nodejs/node/commit/ed193ad8ae)] - **tools**: fix tools/doc/addon-verify.js regression (Anna Henningsen) [#6652](https://github.com/nodejs/node/pull/6652) +* [[`8b88c384f0`](https://github.com/nodejs/node/commit/8b88c384f0)] - **tools**: lint for object literal spacing (Rich Trott) [#6592](https://github.com/nodejs/node/pull/6592) +* [[`96b5aa8710`](https://github.com/nodejs/node/commit/96b5aa8710)] - **tools**: update marked dependency (Daniel Wang) [#6396](https://github.com/nodejs/node/pull/6396) +* [[`ea137637b7`](https://github.com/nodejs/node/commit/ea137637b7)] - **tools**: allow multiple added: version entries (Anna Henningsen) [#6495](https://github.com/nodejs/node/pull/6495) +* [[`2832a60426`](https://github.com/nodejs/node/commit/2832a60426)] - **tools**: parse documentation metadata (Tristian Flanagan) [#6495](https://github.com/nodejs/node/pull/6495) +* [[`0149cb0577`](https://github.com/nodejs/node/commit/0149cb0577)] - **tools**: add mock-y js-yaml dependency to doctool (Anna Henningsen) [#6495](https://github.com/nodejs/node/pull/6495) +* [[`68e9fd47c6`](https://github.com/nodejs/node/commit/68e9fd47c6)] - **tools**: fix -Wunused-variable warning (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`4a2bd2d515`](https://github.com/nodejs/node/commit/4a2bd2d515)] - **tools**: allow cpplint to run outside git repo (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`09e98a4457`](https://github.com/nodejs/node/commit/09e98a4457)] - **tools**: add back --mode=tap to cpplint (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`e74f199fe2`](https://github.com/nodejs/node/commit/e74f199fe2)] - **tools**: disable unwanted cpplint rules again (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`391fc80487`](https://github.com/nodejs/node/commit/391fc80487)] - **tools**: update cpplint to r456 (Ben Noordhuis) [#7462](https://github.com/nodejs/node/pull/7462) +* [[`efadf7639f`](https://github.com/nodejs/node/commit/efadf7639f)] - **tools**: update certdata.txt (Ben Noordhuis) [#7363](https://github.com/nodejs/node/pull/7363) +* [[`d7ce99214d`](https://github.com/nodejs/node/commit/d7ce99214d)] - **tools**: update ESLint, fix unused vars bug (Rich Trott) [#7601](https://github.com/nodejs/node/pull/7601) +* [[`242d6c7323`](https://github.com/nodejs/node/commit/242d6c7323)] - **tools**: remove unused variable (Rich Trott) [#7594](https://github.com/nodejs/node/pull/7594) +* [[`7182f5f876`](https://github.com/nodejs/node/commit/7182f5f876)] - **tools**: fix license builder to work with icu-small (Myles Borins) [#7119](https://github.com/nodejs/node/pull/7119) +* [[`140b84dd7d`](https://github.com/nodejs/node/commit/140b84dd7d)] - **tools**: print stderr on bad test.py `vmArch` check (Jeremiah Senkpiel) [#6786](https://github.com/nodejs/node/pull/6786) +* [[`4c423e649c`](https://github.com/nodejs/node/commit/4c423e649c)] - **tools**: explicit path for V8 test tap output (Myles Borins) [#7460](https://github.com/nodejs/node/pull/7460) +* [[`d50f16969d`](https://github.com/nodejs/node/commit/d50f16969d)] - **tools,doc**: add example usage for REPLACEME tag (Anna Henningsen) [#6864](https://github.com/nodejs/node/pull/6864) +* [[`b07c3a6ea6`](https://github.com/nodejs/node/commit/b07c3a6ea6)] - **tty**: use blocking mode on OS X (Jeremiah Senkpiel) [#6895](https://github.com/nodejs/node/pull/6895) +* [[`a1719a94e9`](https://github.com/nodejs/node/commit/a1719a94e9)] - **udp**: use libuv API to get file descriptor (Saúl Ibarra Corretgé) [#6908](https://github.com/nodejs/node/pull/6908) +* [[`7779639a11`](https://github.com/nodejs/node/commit/7779639a11)] - **unix,stream**: fix getting the correct fd for a handle (Saúl Ibarra Corretgé) [#6753](https://github.com/nodejs/node/pull/6753) +* [[`d0bf09d3ad`](https://github.com/nodejs/node/commit/d0bf09d3ad)] - **util**: improve format() performance further (Brian White) [#5360](https://github.com/nodejs/node/pull/5360) +* [[`72fb281961`](https://github.com/nodejs/node/commit/72fb281961)] - **util**: improve util.format performance (Evan Lucas) [#5360](https://github.com/nodejs/node/pull/5360) +* [[`855759757a`](https://github.com/nodejs/node/commit/855759757a)] - **vm**: don't print out arrow message for custom error (Anna Henningsen) [#7398](https://github.com/nodejs/node/pull/7398) +* [[`b9dfdfe1d3`](https://github.com/nodejs/node/commit/b9dfdfe1d3)] - **vm**: don't abort process when stack space runs out (Anna Henningsen) [#6907](https://github.com/nodejs/node/pull/6907) +* [[`0bfedd13a9`](https://github.com/nodejs/node/commit/0bfedd13a9)] - **win,build**: add creation of zip and 7z package (Bartosz Sosnowski) [#5995](https://github.com/nodejs/node/pull/5995) +* [[`7d66752f1f`](https://github.com/nodejs/node/commit/7d66752f1f)] - **zlib**: release callback and buffer after processing (Matt Lavin) [#6955](https://github.com/nodejs/node/pull/6955) + ## 2016-06-28, Version 4.4.7 'Argon' (LTS), @thealphanerd This LTS release comes with 89 commits. This includes 46 commits that are docs related, 11 commits that are test related, 8 commits that are build related, and 4 commits that are benchmark related. diff --git a/src/node_version.h b/src/node_version.h index 01436c9cc55278..2c35613c2fdabe 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -2,13 +2,13 @@ #define SRC_NODE_VERSION_H_ #define NODE_MAJOR_VERSION 4 -#define NODE_MINOR_VERSION 4 -#define NODE_PATCH_VERSION 8 +#define NODE_MINOR_VERSION 5 +#define NODE_PATCH_VERSION 0 #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Argon" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)