From d77ce4b9989d143c7b5ab7640bd6c0cbe261e458 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 11 Oct 2011 16:06:40 -0700 Subject: [PATCH] Fixes #1860. Remove process.writeError Breaks a few tests in "make test-message" --- lib/console.js | 3 +-- lib/util.js | 4 ++-- src/node.cc | 34 ---------------------------------- test/simple/test-buffer.js | 6 +++--- 4 files changed, 6 insertions(+), 41 deletions(-) diff --git a/lib/console.js b/lib/console.js index 7c6134a47e8..ac8912f828e 100644 --- a/lib/console.js +++ b/lib/console.js @@ -19,7 +19,6 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -var writeError = process.writeError; var util = require('util'); exports.log = function() { @@ -31,7 +30,7 @@ exports.info = exports.log; exports.warn = function() { - writeError(util.format.apply(this, arguments) + '\n'); + process.stderr.write(util.format.apply(this, arguments) + '\n'); }; diff --git a/lib/util.js b/lib/util.js index 07d14213994..a13a70d3d84 100644 --- a/lib/util.js +++ b/lib/util.js @@ -72,13 +72,13 @@ exports.puts = function() { exports.debug = function(x) { - process.writeError('DEBUG: ' + x + '\n'); + process.stderr.write('DEBUG: ' + x + '\n'); }; var error = exports.error = function(x) { for (var i = 0, len = arguments.length; i < len; ++i) { - process.writeError(arguments[i] + '\n'); + process.stderr.write(arguments[i] + '\n'); } }; diff --git a/src/node.cc b/src/node.cc index cd3bef5d40a..4cfcb317b54 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1330,38 +1330,6 @@ Local ExecuteString(Handle source, Handle filename) { } -/* STDERR IS ALWAY SYNC ALWAYS UTF8 */ -static Handle WriteError (const Arguments& args) { - HandleScope scope; - - if (args.Length() < 1) { - return Undefined(); - } - - String::Utf8Value msg(args[0]->ToString()); - - ssize_t r; - size_t written = 0; - while (written < (size_t) msg.length()) { - r = write(STDERR_FILENO, (*msg) + written, msg.length() - written); - if (r < 0) { - if (errno == EAGAIN || errno == EIO) { -#ifdef __POSIX__ - usleep(100); -#else - Sleep(100); -#endif - continue; - } - return ThrowException(ErrnoException(errno, "write")); - } - written += (size_t)r; - } - - return True(); -} - - static Handle Chdir(const Arguments& args) { HandleScope scope; @@ -2174,8 +2142,6 @@ Handle SetupProcessObject(int argc, char *argv[]) { NODE_SET_METHOD(process, "chdir", Chdir); NODE_SET_METHOD(process, "cwd", Cwd); - NODE_SET_METHOD(process, "writeError", WriteError); - NODE_SET_METHOD(process, "umask", Umask); #ifdef __POSIX__ diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 23a0d84a14b..b9f6ee042df 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -259,11 +259,11 @@ 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)', - Buffer._charsWritten); +console.error('chars written to buffer: %d (should be 2)', charsWritten); assert.equal(size, 4); -assert.equal(Buffer._charsWritten, 2); +assert.equal(charsWritten, 2); assert.deepEqual(f, new Buffer([0x42, 0x30, 0x44, 0x30, 0x00]));