Browse Source

Encoding 0 length data, returns '' instead of null

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
46ebaa00ce
  1. 2
      src/node.cc
  2. 4
      src/node_child_process.cc

2
src/node.cc

@ -170,7 +170,7 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) { Local<Value> Encode(const void *buf, size_t len, enum encoding encoding) {
HandleScope scope; HandleScope scope;
if (!len) return scope.Close(Null()); if (!len) return scope.Close(String::Empty());
if (encoding == BINARY) { if (encoding == BINARY) {
const unsigned char *cbuf = static_cast<const unsigned char*>(buf); const unsigned char *cbuf = static_cast<const unsigned char*>(buf);

4
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 ? enum encoding encoding = isSTDOUT ?
child->stdout_encoding_ : child->stderr_encoding_; child->stdout_encoding_ : child->stderr_encoding_;
Local<Value> data = Encode(buf, len, encoding); // TODO emit 'end' event instead of null.
Local<Value> data = len ? Encode(buf, len, encoding) : Local<Value>::New(Null());
child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data); child->Emit(isSTDOUT ? output_symbol : error_symbol, 1, &data);
child->MaybeShutdown(); child->MaybeShutdown();
} }

Loading…
Cancel
Save