Made d8 console=readline work on leopard.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@910 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
73398bcf17
commit
f56c10598b
@ -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 @@ void ReadLineEditor::AddHistory(const char* str) {
|
||||
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 @@ char* ReadLineEditor::CompletionGenerator(const char* text, int state) {
|
||||
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));
|
||||
|
@ -194,6 +194,11 @@ char *OS::StrDup(const char* str) {
|
||||
}
|
||||
|
||||
|
||||
char* OS::StrNDup(const char* str, size_t n) {
|
||||
return strndup(str, n);
|
||||
}
|
||||
|
||||
|
||||
double OS::nan_value() {
|
||||
return NAN;
|
||||
}
|
||||
|
@ -185,11 +185,16 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
double OS::nan_value() {
|
||||
return NAN;
|
||||
}
|
||||
|
@ -190,11 +190,26 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// We keep the lowest and highest addresses mapped as a quick way of
|
||||
// determining that pointers are outside the heap (used mostly in assertions
|
||||
// and verification). The estimate is conservative, ie, not all addresses in
|
||||
|
@ -695,11 +695,26 @@ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// We keep the lowest and highest addresses mapped as a quick way of
|
||||
// determining that pointers are outside the heap (used mostly in assertions
|
||||
// and verification). The estimate is conservative, ie, not all addresses in
|
||||
|
@ -206,6 +206,7 @@ class OS {
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user