Author: [EMAIL PROTECTED]
Date: Wed Dec 3 07:51:16 2008
New Revision: 910
Modified:
branches/bleeding_edge/src/d8-readline.cc
branches/bleeding_edge/src/platform-freebsd.cc
branches/bleeding_edge/src/platform-linux.cc
branches/bleeding_edge/src/platform-macos.cc
branches/bleeding_edge/src/platform-win32.cc
branches/bleeding_edge/src/platform.h
Log:
Made d8 console=readline work on leopard.
Modified: branches/bleeding_edge/src/d8-readline.cc
==============================================================================
--- branches/bleeding_edge/src/d8-readline.cc (original)
+++ branches/bleeding_edge/src/d8-readline.cc Wed Dec 3 07:51:16 2008
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include <cstdio>
#include <readline/readline.h>
#include <readline/history.h>
@@ -33,6 +34,13 @@
#include "d8.h"
+// There are incompatibilities between different versions and different
+// implementations of readline. This smoothes out one known
incompatibility.
+#if RL_READLINE_VERSION >= 0x0500
+#define completion_matches rl_completion_matches
+#endif
+
+
namespace v8 {
@@ -85,7 +93,7 @@
char** ReadLineEditor::AttemptedCompletion(const char* text,
int start,
int end) {
- char** result = rl_completion_matches(text, CompletionGenerator);
+ char** result = completion_matches(text, CompletionGenerator);
rl_attempted_completion_over = true;
return result;
}
@@ -95,7 +103,7 @@
static unsigned current_index;
static Persistent<Array> current_completions;
if (state == 0) {
- i::SmartPointer<char> full_text(strndup(rl_line_buffer, rl_point));
+ i::SmartPointer<char> full_text(i::OS::StrNDup(rl_line_buffer,
rl_point));
HandleScope scope;
Handle<Array> completions =
Shell::GetCompletions(String::New(text), String::New(*full_text));
Modified: branches/bleeding_edge/src/platform-freebsd.cc
==============================================================================
--- branches/bleeding_edge/src/platform-freebsd.cc (original)
+++ branches/bleeding_edge/src/platform-freebsd.cc Wed Dec 3 07:51:16 2008
@@ -194,6 +194,11 @@
}
+char* OS::StrNDup(const char* str, size_t n) {
+ return strndup(str, n);
+}
+
+
double OS::nan_value() {
return NAN;
}
Modified: branches/bleeding_edge/src/platform-linux.cc
==============================================================================
--- branches/bleeding_edge/src/platform-linux.cc (original)
+++ branches/bleeding_edge/src/platform-linux.cc Wed Dec 3 07:51:16 2008
@@ -185,8 +185,13 @@
}
-char *OS::StrDup(const char* str) {
+char* OS::StrDup(const char* str) {
return strdup(str);
+}
+
+
+char* OS::StrNDup(const char* str, size_t n) {
+ return strndup(str, n);
}
Modified: branches/bleeding_edge/src/platform-macos.cc
==============================================================================
--- branches/bleeding_edge/src/platform-macos.cc (original)
+++ branches/bleeding_edge/src/platform-macos.cc Wed Dec 3 07:51:16 2008
@@ -190,8 +190,23 @@
}
-char *OS::StrDup(const char* str) {
+char* OS::StrDup(const char* str) {
return strdup(str);
+}
+
+
+char* OS::StrNDup(const char* str, size_t n) {
+ // Stupid implementation of strndup since macos isn't born with
+ // one.
+ size_t len = strlen(str);
+ if (len <= n)
+ return StrDup(str);
+ char* result = new char[n+1];
+ size_t i;
+ for (i = 0; i <= n; i++)
+ result[i] = str[i];
+ result[i] = '\0';
+ return result;
}
Modified: branches/bleeding_edge/src/platform-win32.cc
==============================================================================
--- branches/bleeding_edge/src/platform-win32.cc (original)
+++ branches/bleeding_edge/src/platform-win32.cc Wed Dec 3 07:51:16 2008
@@ -695,8 +695,23 @@
}
-char *OS::StrDup(const char* str) {
+char* OS::StrDup(const char* str) {
return _strdup(str);
+}
+
+
+char* OS::StrNDup(const char* str, size_t n) {
+ // Stupid implementation of strndup since windows isn't born with
+ // one.
+ size_t len = strlen(str);
+ if (len <= n)
+ return StrDup(str);
+ char* result = new char[n+1];
+ size_t i;
+ for (i = 0; i <= n; i++)
+ result[i] = str[i];
+ result[i] = '\0';
+ return result;
}
Modified: branches/bleeding_edge/src/platform.h
==============================================================================
--- branches/bleeding_edge/src/platform.h (original)
+++ branches/bleeding_edge/src/platform.h Wed Dec 3 07:51:16 2008
@@ -206,6 +206,7 @@
static void StrNCpy(Vector<char> dest, const char* src, size_t n);
static char* StrDup(const char* str);
+ static char* StrNDup(const char* str, size_t n);
// Support for profiler. Can do nothing, in which case ticks
// occuring in shared libraries will not be properly accounted
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---