Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fixes #1860. Remove process.writeError
Browse files Browse the repository at this point in the history
Breaks a few tests in "make test-message"
  • Loading branch information
ry committed Oct 18, 2011
1 parent d2698d1 commit d77ce4b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
3 changes: 1 addition & 2 deletions lib/console.js
Expand Up @@ -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() {
Expand All @@ -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');
};


Expand Down
4 changes: 2 additions & 2 deletions lib/util.js
Expand Up @@ -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');
}
};

Expand Down
34 changes: 0 additions & 34 deletions src/node.cc
Expand Up @@ -1330,38 +1330,6 @@ Local<Value> ExecuteString(Handle<String> source, Handle<Value> filename) {
}


/* STDERR IS ALWAY SYNC ALWAYS UTF8 */
static Handle<Value> 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<Value> Chdir(const Arguments& args) {
HandleScope scope;

Expand Down Expand Up @@ -2174,8 +2142,6 @@ Handle<Object> 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__
Expand Down
6 changes: 3 additions & 3 deletions test/simple/test-buffer.js
Expand Up @@ -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]));


Expand Down

0 comments on commit d77ce4b

Please sign in to comment.