Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

@@ -1,5 +1,5 @@
{
"version": "1.1.62",
"version": "1.1.63",
"name": "npm",
"publishConfig": {
"proprietary-attribs": false
@@ -15,7 +15,7 @@
"config": {
"publishtest": false
},
"homepage": "http://npmjs.org/",
"homepage": "https://npmjs.org/doc/",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"repository": {
"type": "git",
@@ -34,8 +34,8 @@
"main": "./lib/npm.js",
"bin": "./bin/npm-cli.js",
"dependencies": {
"semver": "~1.0.14",
"ini": "1",
"semver": "~1.1.0",
"ini": "~1.0.5",
"slide": "1",
"abbrev": "1",
"graceful-fs": "~1.1.1",
@@ -51,22 +51,21 @@
"mkdirp": "~0.3.3",
"read": "~1.0.4",
"lru-cache": "~2.0.0",
"node-gyp": "~0.6.4",
"node-gyp": "~0.7.0",
"fstream-npm": "0.1",
"uid-number": "0",
"archy": "0",
"chownr": "0",
"npmlog": "0",
"ansi": "~0.1.2",
"npm-registry-client": "~0.2.6",
"read-package-json": "~0.1.3",
"read-installed": "0",
"glob": "~3.1.12",
"init-package-json": "0",
"npm-registry-client": "~0.2.9",
"read-package-json": "~0.1.7",
"read-installed": "0.0.3",
"glob": "~3.1.13",
"init-package-json": "0.0.6",
"osenv": "0",
"lockfile": ">=0.2",
"retry": "~0.6.0",
"couch-login": "~0.1.9",
"once": "~1.1.1",
"npmconf": "0",
"opener": "~1.3.0"
@@ -104,7 +103,6 @@
"osenv",
"lockfile",
"retry",
"couch-login",
"once",
"npmconf",
"opener"
@@ -126,7 +124,7 @@
"licenses": [
{
"type": "MIT +no-false-attribs",
"url": "http://github.com/isaacs/npm/raw/master/LICENSE"
"url": "https://github.com/isaacs/npm/raw/master/LICENSE"
}
]
}
@@ -17,7 +17,7 @@ if [ "x$0" = "xsh" ]; then
# on some systems, you can just do cat>npm-install.sh
# which is a bit cuter. But on others, &1 is already closed,
# so catting to another script file won't do anything.
curl -s http://npmjs.org/install.sh > npm-install-$$.sh
curl -s https://npmjs.org/install.sh > npm-install-$$.sh
sh npm-install-$$.sh
ret=$?
rm npm-install-$$.sh
@@ -1,4 +1,5 @@
{ "name":"npm-test-blerg"
, "version" : "0.0.0"
, "scripts" : { "test" : "node test.js" }
, "publishConfig": {"tag": "foo"}
}
@@ -1137,9 +1137,12 @@ static void fs__utime(uv_fs_t* req) {

if (fs__utime_handle(handle, req->atime, req->mtime) != 0) {
SET_REQ_WIN32_ERROR(req, GetLastError());
CloseHandle(handle);
return;
}

CloseHandle(handle);

req->result = 0;
}

@@ -24,8 +24,9 @@
#include <malloc.h>
#include <stdio.h>
#include <process.h>
#include <windows.h>
#if !defined(__MINGW32__)
# include <crtdbg.h>
#include <crtdbg.h>
#endif


@@ -1,6 +1,7 @@
# Crypto

Stability: 3 - Stable
Stability: 2 - Unstable; API changes are being discussed for
future versions. Breaking changes will be minimized. See below.

Use `require('crypto')` to access this module.

@@ -390,6 +391,37 @@ Generates cryptographically strong pseudo-random data. Usage:
// handle error
}

## Proposed API Changes in Future Versions of Node

The Crypto module was added to Node before there was the concept of a
unified Stream API, and before there were Buffer objects for handling
binary data.

As such, the streaming classes don't have the typical methods found on
other Node classes, and many methods accept and return Binary-encoded
strings by default rather than Buffers.

A future version of node will make Buffers the default data type.
This will be a breaking change for some use cases, but not all.

For example, if you currently use the default arguments to the Sign
class, and then pass the results to the Verify class, without ever
inspecting the data, then it will continue to work as before. Where
you now get a binary string and then present the binary string to the
Verify object, you'll get a Buffer, and present the Buffer to the
Verify object.

However, if you are doing things with the string data that will not
work properly on Buffers (such as, concatenating them, storing in
databases, etc.), or you are passing binary strings to the crypto
functions without an encoding arguemnt, then you will need to start
providing encoding arguments to specify which encoding you'd like to
use.

Also, a Streaming API will be provided, but this will be done in such
a way as to preserve the legacy API surface.


[createCipher()]: #crypto_crypto_createcipher_algorithm_password
[createCipheriv()]: #crypto_crypto_createcipheriv_algorithm_key_iv
[crypto.createDiffieHellman()]: #crypto_crypto_creatediffiehellman_prime_encoding
@@ -184,9 +184,9 @@ from that one, and bound to this one instead.
The opposite of `domain.add(emitter)`. Removes domain handling from the
specified emitter.

### domain.bind(cb)
### domain.bind(callback)

* `cb` {Function} The callback function
* `callback` {Function} The callback function
* return: {Function} The bound function

The returned function will be a wrapper around the supplied callback
@@ -210,16 +210,16 @@ thrown will be routed to the domain's `error` event.
// with the normal line number and stack message.
});

### domain.intercept(cb)
### domain.intercept(callback)

* `cb` {Function} The callback function
* `callback` {Function} The callback function
* return: {Function} The intercepted function

This method is almost identical to `domain.bind(cb)`. However, in
This method is almost identical to `domain.bind(callback)`. However, in
addition to catching thrown errors, it will also intercept `Error`
objects sent as the first argument to the function.

In this way, the common `if (er) return cb(er);` pattern can be replaced
In this way, the common `if (er) return callback(er);` pattern can be replaced
with a single error handler in a single place.

#### Example
@@ -159,10 +159,10 @@ This function is asynchronous. The last parameter `callback` will be added as
a listener for the ['listening'][] event. See also [net.Server.listen(path)][].


### server.listen(handle, [listeningListener])
### server.listen(handle, [callback])

* `handle` {Object}
* `listeningListener` {Function}
* `callback` {Function}

The `handle` object can be set to either a server or socket (anything
with an underlying `_handle` member), or a `{fd: <n>}` object.
@@ -175,9 +175,9 @@ Listening on a file descriptor is not supported on Windows.

This function is asynchronous. The last parameter `callback` will be added as
a listener for the ['listening'](net.html#event_listening_) event.
See also [net.Server.listen()](net.html#server.listen).
See also [net.Server.listen()](net.html#net_server_listen_handle_callback).

### server.close([cb])
### server.close([callback])

Stops the server from accepting new connections. See [net.Server.close()][].

@@ -873,16 +873,23 @@ Note that the __data will be lost__ if there is no listener when a

`function () { }`

Emitted exactly once for each message. No arguments. After
emitted no other events will be emitted on the response.
Emitted exactly once for each response. After that, no more `'data'` events
will be emitted on the response.


### Event: 'close'

`function (err) { }`
`function () { }`

Indicates that the underlaying connection was terminated before
`end` event was emitted.
See [http.ServerRequest][]'s `'close'` event for more information.
`response.end()` was called or able to flush.

Just like `'end'`, this event occurs only once per response, and no more
`'data'` events will fire afterwards. See [http.ServerResponse][]'s `'close'`
event for more information.

Note: `'close'` can fire after `'end'`, but not vice versa.


### response.statusCode

@@ -924,9 +931,9 @@ Resumes a paused response.
[http.request()]: #http_http_request_options_callback
[http.ServerRequest]: #http_class_http_serverrequest
['listening']: net.html#net_event_listening
[net.Server.close()]: net.html#net_server_close_cb
[net.Server.listen(path)]: net.html#net_server_listen_path_listeninglistener
[net.Server.listen(port)]: net.html#net_server_listen_port_host_backlog_listeninglistener
[net.Server.close()]: net.html#net_server_close_callback
[net.Server.listen(path)]: net.html#net_server_listen_path_callback
[net.Server.listen(port)]: net.html#net_server_listen_port_host_backlog_callback
[Readable Stream]: stream.html#stream_readable_stream
[socket.setKeepAlive()]: net.html#net_socket_setkeepalive_enable_initialdelay
[socket.setNoDelay()]: net.html#net_socket_setnodelay_nodelay
@@ -46,6 +46,17 @@ Or
res.end("hello world\n");
}).listen(8000);


### server.listen(port, [host], [backlog], [callback])
### server.listen(path, [callback])
### server.listen(handle, [callback])

See [http.listen()][] for details.

### server.close([callback])

See [http.close()][] for details.

## https.request(options, callback)

Makes a request to a secure web server.
@@ -193,6 +204,8 @@ Global instance of [https.Agent][] for all HTTPS client requests.

[Agent]: #https_class_https_agent
[globalAgent]: #https_https_globalagent
[http.listen()]: http.html#http_server_listen_port_hostname_backlog_callback
[http.close()]: http.html#http_server_close_callback
[http.Agent]: http.html#http_class_http_agent
[http.request()]: http.html#http_http_request_options_callback
[https.Agent]: #https_class_https_agent
@@ -118,7 +118,7 @@ The `connectListener` parameter will be added as an listener for the
This class is used to create a TCP or UNIX server.
A server is a `net.Socket` that can listen for new incoming connections.

### server.listen(port, [host], [backlog], [listeningListener])
### server.listen(port, [host], [backlog], [callback])

Begin accepting connections on the specified `port` and `host`. If the
`host` is omitted, the server will accept connections directed to any
@@ -130,7 +130,7 @@ The actual length will be determined by your OS through sysctl settings such as
parameter is 511 (not 512).

This function is asynchronous. When the server has been bound,
['listening'][] event will be emitted. The last parameter `listeningListener`
['listening'][] event will be emitted. The last parameter `callback`
will be added as an listener for the ['listening'][] event.

One issue some users run into is getting `EADDRINUSE` errors. This means that
@@ -150,18 +150,18 @@ would be to wait a second and then try again. This can be done with
(Note: All sockets in Node set `SO_REUSEADDR` already)


### server.listen(path, [listeningListener])
### server.listen(path, [callback])

Start a UNIX socket server listening for connections on the given `path`.

This function is asynchronous. When the server has been bound,
['listening'][] event will be emitted. The last parameter `listeningListener`
['listening'][] event will be emitted. The last parameter `callback`
will be added as an listener for the ['listening'][] event.

### server.listen(handle, [listeningListener])
### server.listen(handle, [callback])

* `handle` {Object}
* `listeningListener` {Function}
* `callback` {Function}

The `handle` object can be set to either a server or socket (anything
with an underlying `_handle` member), or a `{fd: <n>}` object.
@@ -174,10 +174,10 @@ Listening on a file descriptor is not supported on Windows.

This function is asynchronous. When the server has been bound,
['listening'](#event_listening_) event will be emitted.
the last parameter `listeningListener` will be added as an listener for the
the last parameter `callback` will be added as an listener for the
['listening'](#event_listening_) event.

### server.close([cb])
### server.close([callback])

Stops the server from accepting new connections and keeps existing
connections. This function is asynchronous, the server is finally
@@ -489,14 +489,15 @@ primary use is for measuring performance between intervals.
You may pass in the result of a previous call to `process.hrtime()` to get
a diff reading, useful for benchmarks and measuring intervals:

var t = process.hrtime();
var time = process.hrtime();
// [ 1800216, 927643717 ]

setTimeout(function() {
t = process.hrtime(t);
var diff = process.hrtime(time);
// [ 1, 6962306 ]

console.log('benchmark took %d seconds and %d nanoseconds', t[0], t[1]);
console.log('benchmark took %d seconds and %d nanoseconds',
diff[0], diff[1]);
// benchmark took 1 seconds and 6962306 nanoseconds
}, 1000);

@@ -120,8 +120,12 @@ A `Writable Stream` has the following methods, members, and events.

`function () { }`

After a `write()` method returned `false`, this event is emitted to
indicate that it is safe to write again.
Emitted when the stream's write queue empties and it's safe to write without
buffering again. Listen for it when `stream.write()` returns `false`.

The `'drain'` event can happen at *any* time, regardless of whether or not
`stream.write()` has previously returned `false`. To avoid receiving unwanted
`'drain'` events, listen using `stream.once()`.

### Event: 'error'

@@ -146,20 +150,14 @@ Emitted when the stream is passed to a readable stream's pipe method.
A boolean that is `true` by default, but turns `false` after an
`'error'` occurred or `end()` / `destroy()` was called.

### stream.write(string, [encoding], [fd])
### stream.write(string, [encoding])

Writes `string` with the given `encoding` to the stream. Returns `true`
if the string has been flushed to the kernel buffer. Returns `false` to
indicate that the kernel buffer is full, and the data will be sent out
in the future. The `'drain'` event will indicate when the kernel buffer
is empty again. The `encoding` defaults to `'utf8'`.

If the optional `fd` parameter is specified, it is interpreted as an
integral file descriptor to be sent over the stream. This is only
supported for UNIX streams, and is silently ignored otherwise. When
writing a file descriptor in this manner, closing the descriptor before
the stream drains risks sending an invalid (closed) FD.

### stream.write(buffer)

Same as the above except with a raw buffer.
@@ -208,8 +208,8 @@ You can test this server by connecting to it with `openssl s_client`:
openssl s_client -connect 127.0.0.1:8000


## tls.connect(options, [secureConnectListener])
## tls.connect(port, [host], [options], [secureConnectListener])
## tls.connect(options, [callback])
## tls.connect(port, [host], [options], [callback])

Creates a new client connection to the given `port` and `host` (old API) or
`options.port` and `options.host`. (If `host` is omitted, it defaults to
@@ -249,7 +249,7 @@ Creates a new client connection to the given `port` and `host` (old API) or

- `servername`: Servername for SNI (Server Name Indication) TLS extension.

The `secureConnectListener` parameter will be added as a listener for the
The `callback` parameter will be added as a listener for the
['secureConnect'][] event.

`tls.connect()` returns a [CleartextStream][] object.
@@ -114,6 +114,19 @@ Predefined color codes are: `white`, `grey`, `black`, `blue`, `cyan`,
`green`, `magenta`, `red` and `yellow`.
There are also `bold`, `italic`, `underline` and `inverse` codes.

Objects also may define their own `inspect(depth)` function which `util.inspect()`
will invoke and use the result of when inspecting the object:

var util = require('util');

var obj = { name: 'nate' };
obj.inspect = function(depth) {
return '{' + this.name + '}';
};

util.inspect(obj);
// "{nate}"


## util.isArray(object)

@@ -8,6 +8,7 @@ body {
font-size: 14px;
line-height: 180%;
color: black;
background-color: white;
margin: 0; padding: 49px 0 0 0;
border-top: 6px #8CC84B solid;
}
@@ -0,0 +1,73 @@
category: release
version: v0.8.12
date: Fri Oct 12 08:52:06 PDT 2012
slug: node-v0.8.12
title: Node v0.8.12 (Stable)

2012.10.12, Version 0.8.12 (Stable)

* npm: Upgrade to 1.1.63

* crypto: Reduce stability index to 2-Unstable (isaacs)

* windows: fix handle leak in uv_fs_utime (Bert Belder)

* windows: fix application crashed popup in debug version (Bert Belder)

* buffer: report proper retained size in profiler (Ben Noordhuis)

* buffer: fix byteLength with UTF-16LE (koichik)

* repl: make "end of input" JSON.parse() errors throw in the REPL (Nathan Rajlich)

* repl: make invalid RegExp modifiers throw in the REPL (Nathan Rajlich)

* http: handle multiple Proxy-Authenticate values (Willi Eggeling)


Source Code: http://nodejs.org/dist/v0.8.12/node-v0.8.12.tar.gz

Macintosh Installer (Universal): http://nodejs.org/dist/v0.8.12/node-v0.8.12.pkg

Windows Installer: http://nodejs.org/dist/v0.8.12/node-v0.8.12-x86.msi

Windows x64 Installer: http://nodejs.org/dist/v0.8.12/x64/node-v0.8.12-x64.msi

Windows x64 Files: http://nodejs.org/dist/v0.8.12/x64/

Linux 32-bit Binary: http://nodejs.org/dist/v0.8.12/node-v0.8.12-linux-x86.tar.gz

Linux 64-bit Binary: http://nodejs.org/dist/v0.8.12/node-v0.8.12-linux-x64.tar.gz

Solaris 32-bit Binary: http://nodejs.org/dist/v0.8.12/node-v0.8.12-sunos-x86.tar.gz

Solaris 64-bit Binary: http://nodejs.org/dist/v0.8.12/node-v0.8.12-sunos-x64.tar.gz

Other release files: http://nodejs.org/dist/v0.8.12/

Website: http://nodejs.org/docs/v0.8.12/

Documentation: http://nodejs.org/docs/v0.8.12/api/

Shasums:

```
2d40157436b34e9e347c587de9945e7022eb9acc node-v0.8.12-darwin-x64.tar.gz
b6ba1d2e478881e0a5248cb319ce0913ca39a51b node-v0.8.12-darwin-x86.tar.gz
5353dfab2005992deee13e6e00a30509c8c86d4b node-v0.8.12-linux-x64.tar.gz
9e501b995469d554e3356b6f5f85b72abed83310 node-v0.8.12-linux-x86.tar.gz
b3e8e655b3c6f0a2c641dcb0e22372edb6f45ffd node-v0.8.12-sunos-x64.tar.gz
82c46d12a52e09bda3ad4bd0cdb8ad18480e679a node-v0.8.12-sunos-x86.tar.gz
d70e7bc718699651281110cd9f3f13ae50ac36be node-v0.8.12-x86.msi
d24d17d34425eb86cc237b8e68fdd5d199cb0ad8 node-v0.8.12.pkg
719397c7f65365b2ec6510863ac62bd291784910 node-v0.8.12.tar.gz
ac7151c05730982eb37a7f390386219c4d05b57d node.exe
000771bbc1e26f8ac5d11183b6538f25214b64a6 node.exp
b036c368ff65f96ca44ac0ccf8d742c41ce00a95 node.lib
98edc84132157d44df7a4d08b6788843fe542961 node.pdb
d1cccae53dcb54e08a8771ef0f9406e327ac4db3 x64/node-v0.8.12-x64.msi
0aa3088bd6a55864d25e84091b3a3b796ce20ce9 x64/node.exe
1d6dc06515cead63a2e547aacc73cfb7ad8003a2 x64/node.exp
7f55dd2367523c151e4d8492c596f076e0e5d151 x64/node.lib
e34d679b61c77026dd0f437d3d91a84b83a422d3 x64/node.pdb
```
@@ -0,0 +1,13 @@
title: Bert Belder - libuv at LXJS 2012
slug: bert-belder-libuv-lxjs-2012
category: video
date: Sun Sep 30 10:28:45 PDT 2012

Node core committer Bert Belder gave a talk at
[LXJS](http://2012.lxjs.org/). If you are interested in how Node does
asynchronous I/O across platforms, then you should definitely watch
this video.

<iframe width="640" height="360"
src="http://www.youtube.com/embed/nGn60vDSxQ4" frameborder="0"
allowfullscreen></iframe>
@@ -58,8 +58,6 @@ function hasOwnProperty(obj, prop) {
}


var context;

// hack for require.resolve("./relative") to work properly.
module.filename = path.resolve('repl');

@@ -267,17 +265,6 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
finish(null);
}

function isSyntaxError(e) {
// Convert error to string
e = e && (e.stack || e.toString());
return e && e.match(/^SyntaxError/) &&
// RegExp syntax error
!e.match(/^SyntaxError: Invalid regular expression/) &&
// JSON.parse() error
!(e.match(/^SyntaxError: Unexpected token .*\n/) &&
e.match(/\n at Object.parse \(native\)\n/));
}

function finish(e, ret) {

self.memory(cmd);
@@ -338,14 +325,15 @@ exports.start = function(prompt, source, eval_, useGlobal, ignoreUndefined) {


REPLServer.prototype.createContext = function() {
if (!this.useGlobal) {
var context = vm.createContext();
var context;
if (this.useGlobal) {
context = global;
} else {
context = vm.createContext();
for (var i in global) context[i] = global[i];
context.console = new Console(this.outputStream);
context.global = context;
context.global.global = context;
} else {
var context = global;
}

context.module = module;
@@ -357,13 +345,9 @@ REPLServer.prototype.createContext = function() {
return context;
};

REPLServer.prototype.resetContext = function(force) {
if (!context || force) {
context = this.createContext();
for (var i in require.cache) delete require.cache[i];
}

this.context = context;
REPLServer.prototype.resetContext = function() {
for (var i in require.cache) delete require.cache[i];
this.context = this.createContext();
};

REPLServer.prototype.displayPrompt = function(preserveCursor) {
@@ -808,7 +792,7 @@ function defineDefaultCommands(repl) {
this.bufferedCommand = '';
if (!this.useGlobal) {
this.outputStream.write('Clearing context...\n');
this.resetContext(true);
this.resetContext();
}
this.displayPrompt();
}
@@ -914,3 +898,21 @@ REPLServer.prototype.convertToContext = function(cmd) {

return cmd;
};


/**
* Returns `true` if "e" is a SyntaxError, `false` otherwise.
* This function filters out false positives likes JSON.parse() errors and
* RegExp syntax errors.
*/
function isSyntaxError(e) {
// Convert error to string
e = e && (e.stack || e.toString());
return e && e.match(/^SyntaxError/) &&
// RegExp syntax error
!e.match(/^SyntaxError: Invalid regular expression/) &&
!e.match(/^SyntaxError: Invalid flags supplied to RegExp constructor/) &&
// JSON.parse() error
!(e.match(/^SyntaxError: Unexpected (token .*|end of input)/) &&
e.match(/\n at Object.parse \(native\)\n/));
}
@@ -1065,6 +1065,10 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
return UCS2;
} else if (strcasecmp(*encoding, "ucs-2") == 0) {
return UCS2;
} else if (strcasecmp(*encoding, "utf16le") == 0) {
return UCS2;
} else if (strcasecmp(*encoding, "utf-16le") == 0) {
return UCS2;
} else if (strcasecmp(*encoding, "binary") == 0) {
return BINARY;
} else if (strcasecmp(*encoding, "buffer") == 0) {
@@ -2731,7 +2735,7 @@ char** Init(int argc, char *argv[]) {
// a breakpoint on the first line of the startup script
v8argc += 2;
v8argv = new char*[v8argc];
memcpy(v8argv, argv, sizeof(argv) * option_end_index);
memcpy(v8argv, argv, sizeof(*argv) * option_end_index);
v8argv[option_end_index] = const_cast<char*>("--expose_debug_as");
v8argv[option_end_index + 1] = const_cast<char*>("v8debug");
}
@@ -24,6 +24,7 @@
#include "node_buffer.h"

#include "v8.h"
#include "v8-profiler.h"

#include <assert.h>
#include <stdlib.h> // malloc, free
@@ -33,9 +34,10 @@
# include <arpa/inet.h> // htons, htonl
#endif


#define MIN(a,b) ((a) < (b) ? (a) : (b))

#define BUFFER_CLASS_ID (0xBABE)

namespace node {

using namespace v8;
@@ -188,6 +190,7 @@ Buffer::Buffer(Handle<Object> wrapper, size_t length) : ObjectWrap() {

length_ = 0;
callback_ = NULL;
handle_.SetWrapperClassId(BUFFER_CLASS_ID);

Replace(NULL, length, NULL, NULL);
}
@@ -730,6 +733,61 @@ bool Buffer::HasInstance(v8::Handle<v8::Value> val) {
}


class RetainedBufferInfo: public v8::RetainedObjectInfo {
public:
RetainedBufferInfo(Buffer* buffer);
virtual void Dispose();
virtual bool IsEquivalent(RetainedObjectInfo* other);
virtual intptr_t GetHash();
virtual const char* GetLabel();
virtual intptr_t GetSizeInBytes();
private:
Buffer* buffer_;
static const char label[];
};

const char RetainedBufferInfo::label[] = "Buffer";


RetainedBufferInfo::RetainedBufferInfo(Buffer* buffer): buffer_(buffer) {
}


void RetainedBufferInfo::Dispose() {
buffer_ = NULL;
delete this;
}


bool RetainedBufferInfo::IsEquivalent(RetainedObjectInfo* other) {
return label == other->GetLabel() &&
buffer_ == static_cast<RetainedBufferInfo*>(other)->buffer_;
}


intptr_t RetainedBufferInfo::GetHash() {
return reinterpret_cast<intptr_t>(buffer_);
}


const char* RetainedBufferInfo::GetLabel() {
return label;
}


intptr_t RetainedBufferInfo::GetSizeInBytes() {
return Buffer::Length(buffer_);
}


RetainedObjectInfo* WrapperInfo(uint16_t class_id, Handle<Value> wrapper) {
assert(class_id == BUFFER_CLASS_ID);
assert(Buffer::HasInstance(wrapper));
Buffer* buffer = Buffer::Unwrap<Buffer>(wrapper.As<Object>());
return new RetainedBufferInfo(buffer);
}


void Buffer::Initialize(Handle<Object> target) {
HandleScope scope;

@@ -777,6 +835,8 @@ void Buffer::Initialize(Handle<Object> target) {
Buffer::MakeFastBuffer);

target->Set(String::NewSymbol("SlowBuffer"), constructor_template->GetFunction());

HeapProfiler::DefineWrapperClass(BUFFER_CLASS_ID, WrapperInfo);
}


@@ -4492,8 +4492,6 @@ Handle<Value> PBKDF2(const Arguments& args) {
}


typedef int (*RandomBytesGenerator)(unsigned char* buf, int size);

struct RandomBytesRequest {
~RandomBytesRequest();
Persistent<Object> obj_;
@@ -4516,26 +4514,26 @@ void RandomBytesFree(char* data, void* hint) {
}


template <RandomBytesGenerator generator>
template <bool pseudoRandom>
void RandomBytesWork(uv_work_t* work_req) {
RandomBytesRequest* req =
container_of(work_req, RandomBytesRequest, work_req_);

int r = generator(reinterpret_cast<unsigned char*>(req->data_), req->size_);

switch (r) {
case 0:
// RAND_bytes() returns 0 on error, RAND_pseudo_bytes() returns 0
// when the result is not cryptographically strong - the latter
// sucks but is not an error
if (generator == RAND_bytes)
req->error_ = ERR_get_error();
break;
RandomBytesRequest* req = container_of(work_req,
RandomBytesRequest,
work_req_);
int r;

if (pseudoRandom == true) {
r = RAND_pseudo_bytes(reinterpret_cast<unsigned char*>(req->data_),
req->size_);
} else {
r = RAND_bytes(reinterpret_cast<unsigned char*>(req->data_), req->size_);
}

case -1:
// not supported - can this actually happen?
req->error_ = (unsigned long) -1;
break;
// RAND_bytes() returns 0 on error. RAND_pseudo_bytes() returns 0 when the
// result is not cryptographically strong - but that's not an error.
if (r == 0 && pseudoRandom == false) {
req->error_ = ERR_get_error();
} else if (r == -1) {
req->error_ = static_cast<unsigned long>(-1);
}
}

@@ -4560,10 +4558,10 @@ void RandomBytesCheck(RandomBytesRequest* req, Local<Value> argv[2]) {
}


template <RandomBytesGenerator generator>
void RandomBytesAfter(uv_work_t* work_req) {
RandomBytesRequest* req =
container_of(work_req, RandomBytesRequest, work_req_);
RandomBytesRequest* req = container_of(work_req,
RandomBytesRequest,
work_req_);

HandleScope scope;
Local<Value> argv[2];
@@ -4574,7 +4572,7 @@ void RandomBytesAfter(uv_work_t* work_req) {
}


template <RandomBytesGenerator generator>
template <bool pseudoRandom>
Handle<Value> RandomBytes(const Arguments& args) {
HandleScope scope;

@@ -4598,14 +4596,14 @@ Handle<Value> RandomBytes(const Arguments& args) {

uv_queue_work(uv_default_loop(),
&req->work_req_,
RandomBytesWork<generator>,
RandomBytesAfter<generator>);
RandomBytesWork<pseudoRandom>,
RandomBytesAfter);

return req->obj_;
}
else {
Local<Value> argv[2];
RandomBytesWork<generator>(&req->work_req_);
RandomBytesWork<pseudoRandom>(&req->work_req_);
RandomBytesCheck(req, argv);
delete req;

@@ -4700,8 +4698,8 @@ void InitCrypto(Handle<Object> target) {
Verify::Initialize(target);

NODE_SET_METHOD(target, "PBKDF2", PBKDF2);
NODE_SET_METHOD(target, "randomBytes", RandomBytes<RAND_bytes>);
NODE_SET_METHOD(target, "pseudoRandomBytes", RandomBytes<RAND_pseudo_bytes>);
NODE_SET_METHOD(target, "randomBytes", RandomBytes<false>);
NODE_SET_METHOD(target, "pseudoRandomBytes", RandomBytes<true>);
NODE_SET_METHOD(target, "getCiphers", GetCiphers);
NODE_SET_METHOD(target, "getHashes", GetHashes);

@@ -265,24 +265,26 @@ var f = new Buffer('über', 'ascii');
console.error('f.length: %d (should be 4)', f.length);
assert.deepEqual(f, new Buffer([252, 98, 101, 114]));

var f = new Buffer('über', 'ucs2');
console.error('f.length: %d (should be 8)', f.length);
assert.deepEqual(f, new Buffer([252, 0, 98, 0, 101, 0, 114, 0]));

var f = new Buffer('привет', 'ucs2');
console.error('f.length: %d (should be 12)', f.length);
assert.deepEqual(f, new Buffer([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]));
assert.equal(f.toString('ucs2'), 'привет');

var f = new Buffer([0, 0, 0, 0, 0]);
assert.equal(f.length, 5);
var size = f.write('あいうえお', 'ucs2');
var charsWritten = Buffer._charsWritten; // Copy value out.
console.error('bytes written to buffer: %d (should be 4)', size);
console.error('chars written to buffer: %d (should be 2)', charsWritten);
assert.equal(size, 4);
assert.equal(charsWritten, 2);
assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));
['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) {
var f = new Buffer('über', encoding);
console.error('f.length: %d (should be 8)', f.length);
assert.deepEqual(f, new Buffer([252, 0, 98, 0, 101, 0, 114, 0]));

var f = new Buffer('привет', encoding);
console.error('f.length: %d (should be 12)', f.length);
assert.deepEqual(f, new Buffer([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]));
assert.equal(f.toString(encoding), 'привет');

var f = new Buffer([0, 0, 0, 0, 0]);
assert.equal(f.length, 5);
var size = f.write('あいうえお', encoding);
var charsWritten = Buffer._charsWritten; // Copy value out.
console.error('bytes written to buffer: %d (should be 4)', size);
console.error('chars written to buffer: %d (should be 2)', charsWritten);
assert.equal(size, 4);
assert.equal(charsWritten, 2);
assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));
});

var f = new Buffer('\uD83D\uDC4D', 'utf-16le'); // THUMBS UP SIGN (U+1F44D)
assert.equal(f.length, 4);
@@ -474,7 +476,9 @@ assert.equal('bcde', b.slice(1).toString());
// byte length
assert.equal(14, Buffer.byteLength('Il était tué'));
assert.equal(14, Buffer.byteLength('Il était tué', 'utf8'));
assert.equal(24, Buffer.byteLength('Il était tué', 'ucs2'));
['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) {
assert.equal(24, Buffer.byteLength('Il était tué', encoding));
});
assert.equal(12, Buffer.byteLength('Il était tué', 'ascii'));
assert.equal(12, Buffer.byteLength('Il était tué', 'binary'));

@@ -599,9 +603,11 @@ for (var i = 0; i < 16; i++) assert.equal(0, b[i]);
for (; i < 32; i++) assert.equal(1, b[i]);
for (; i < b.length; i++) assert.equal(0, b[i]);

var b = new SlowBuffer(10);
b.write('あいうえお', 'ucs2');
assert.equal(b.toString('ucs2'), 'あいうえお');
['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) {
var b = new SlowBuffer(10);
b.write('あいうえお', encoding);
assert.equal(b.toString(encoding), 'あいうえお');
});

// Binary encoding should write only one byte per character.
var b = Buffer([0xde, 0xad, 0xbe, 0xef]);
@@ -706,14 +712,16 @@ assert.equal(buf[1], 0xAB);
assert.equal(buf[2], 0xCD);
assert.equal(buf[3], 0xFF);

buf.fill(0xFF);
written = buf.write('abcd', 0, 2, 'ucs2');
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);
['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 for buffer overrun
buf = new Buffer([0, 0, 0, 0, 0]); // length: 5
@@ -726,8 +734,10 @@ assert.equal(buf[4], 0);
buf = new Buffer(9);
buf.write('あいうえ', 'utf8'); // 3bytes * 4
assert.equal(Buffer._charsWritten, 3);
buf.write('あいうえお', 'ucs2'); // 2bytes * 5
assert.equal(Buffer._charsWritten, 4);
['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) {
buf.write('あいうえお', encoding); // 2bytes * 5
assert.equal(Buffer._charsWritten, 4);
});
buf.write('0123456789', 'ascii');
assert.equal(Buffer._charsWritten, 9);
buf.write('0123456789', 'binary');
@@ -126,10 +126,18 @@ function error_test() {
// should throw
{ client: client_unix, send: 'JSON.parse(\'{invalid: \\\'json\\\'}\');',
expect: /^SyntaxError: Unexpected token i/ },
// end of input to JSON.parse error is special case of syntax error,
// should throw
{ client: client_unix, send: 'JSON.parse(\'{\');',
expect: /^SyntaxError: Unexpected end of input/ },
// invalid RegExps are a special case of syntax error,
// should throw
{ client: client_unix, send: '/(/;',
expect: /^SyntaxError: Invalid regular expression\:/ },
// invalid RegExp modifiers are a special case of syntax error,
// should throw (GH-4012)
{ client: client_unix, send: 'new RegExp("foo", "wrong modifier");',
expect: /^SyntaxError: Invalid flags supplied to RegExp constructor/ },
// Named functions can be used:
{ client: client_unix, send: 'function blah() { return 1; }',
expect: prompt_unix },
@@ -233,7 +241,12 @@ function unix_test() {
socket.end();
});

repl.start(prompt_unix, socket).context.message = message;
repl.start({
prompt: prompt_unix,
input: socket,
output: socket,
useGlobal: true
}).context.message = message;
});

server_unix.on('listening', function() {