From 46ebaa00ce4fdf2e44ddb419088d813bf83c8ffe Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 22 Feb 2010 12:07:07 -0800 Subject: [PATCH] Encoding 0 length data, returns '' instead of null --- src/node.cc | 2 +- src/node_child_process.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node.cc b/src/node.cc index 3f00c5313f..fb874e5210 100644 --- a/src/node.cc +++ b/src/node.cc @@ -170,7 +170,7 @@ enum encoding ParseEncoding(Handle encoding_v, enum encoding _default) { Local Encode(const void *buf, size_t len, enum encoding encoding) { HandleScope scope; - if (!len) return scope.Close(Null()); + if (!len) return scope.Close(String::Empty()); if (encoding == BINARY) { const unsigned char *cbuf = static_cast(buf); diff --git a/src/node_child_process.cc b/src/node_child_process.cc index 95d363e473..4dc3d437af 100644 --- a/src/node_child_process.cc +++ b/src/node_child_process.cc @@ -200,7 +200,9 @@ void ChildProcess::on_read(evcom_reader *r, const void *buf, size_t len) { enum encoding encoding = isSTDOUT ? child->stdout_encoding_ : child->stderr_encoding_; - Local data = Encode(buf, len, encoding); + // TODO emit 'end' event instead of null. + + Local data = len ? Encode(buf, len, encoding) : Local::New(Null()); child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data); child->MaybeShutdown(); }