From 6c5c8085693ebf3105caa3b41f683a9aaa2c09e3 Mon Sep 17 00:00:00 2001 From: Vanilla Hsu Date: Wed, 13 Jan 2010 11:23:21 +0800 Subject: [PATCH 01/24] use SUN_LEN to calculate length of unix address @ FreeBSD. --- deps/evcom/evcom.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/deps/evcom/evcom.c b/deps/evcom/evcom.c index ed9e2b5215b..9490168921b 100644 --- a/deps/evcom/evcom.c +++ b/deps/evcom/evcom.c @@ -849,21 +849,27 @@ static inline socklen_t address_length (struct sockaddr *address) { struct sockaddr_un* unix_address = (struct sockaddr_un*)address; + int length = 0; switch (address->sa_family) { case AF_INET: - return sizeof(struct sockaddr_in); - + length = sizeof(struct sockaddr_in); + break; case AF_INET6: - return sizeof(struct sockaddr_in6); - + length = sizeof(struct sockaddr_in6); + break; case AF_UNIX: - return strlen(unix_address->sun_path) + sizeof(unix_address->sun_family); +#ifdef SUN_LEN + length = SUN_LEN(unix_address); +#else + length = strlen(unix_address->sun_path) + sizeof(unix_address->sun_family); +#endif + break; default: assert(0 && "Unsupported socket family"); } - return 0; + return length; } int From 8e6dd52683fee931235994c415aa4b9d303b1a32 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 15 Jan 2010 10:45:04 -0800 Subject: [PATCH 02/24] Hack to display more useful SyntaxError exceptions. For some reason v8 doesn't include the frame with the syntax error in the stack trace - so have to special case it. --- src/node.cc | 22 +++++++++++++++------- src/node.js | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/node.cc b/src/node.cc index 30802665e5d..96f131939fa 100644 --- a/src/node.cc +++ b/src/node.cc @@ -316,7 +316,7 @@ const char* ToCString(const v8::String::Utf8Value& value) { return *value ? *value : ""; } -static void ReportException(TryCatch *try_catch) { +static void ReportException(TryCatch *try_catch, bool show_line = false) { Handle message = try_catch->Message(); if (message.IsEmpty()) { fprintf(stderr, "Error: (no message)\n"); @@ -333,7 +333,7 @@ static void ReportException(TryCatch *try_catch) { if (raw_stack->IsString()) stack = Handle::Cast(raw_stack); } - if (stack.IsEmpty()) { + if (show_line) { // Print (filename):(line number): (message). String::Utf8Value filename(message->GetScriptResourceName()); const char* filename_string = ToCString(filename); @@ -353,7 +353,9 @@ static void ReportException(TryCatch *try_catch) { fprintf(stderr, "^"); } fprintf(stderr, "\n"); + } + if (stack.IsEmpty()) { message->PrintCurrentStackTrace(stderr); } else { String::Utf8Value trace(stack); @@ -736,7 +738,7 @@ Handle DLOpen(const v8::Arguments& args) { return Undefined(); } -v8::Handle Compile(const v8::Arguments& args) { +Handle Compile(const Arguments& args) { HandleScope scope; if (args.Length() < 2) { @@ -747,11 +749,17 @@ v8::Handle Compile(const v8::Arguments& args) { Local source = args[0]->ToString(); Local filename = args[1]->ToString(); - Handle