Browse Source

Fixes #1860. Remove process.writeError

Breaks a few tests in "make test-message"
v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
d77ce4b998
  1. 3
      lib/console.js
  2. 4
      lib/util.js
  3. 34
      src/node.cc
  4. 6
      test/simple/test-buffer.js

3
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');
};

4
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');
}
};

34
src/node.cc

@ -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;
@ -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__

6
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]));

Loading…
Cancel
Save