Modifies readline() to behave in the same way as it does in TraceMonkey.
Author: abdulla <abdulla.kamar@gmail.com> Review URL: http://codereview.chromium.org/173262 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2838 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
f7c799f0a2
commit
223973ef9b
12
src/d8.cc
12
src/d8.cc
@ -179,15 +179,15 @@ Handle<Value> Shell::Read(const Arguments& args) {
|
||||
|
||||
|
||||
Handle<Value> Shell::ReadLine(const Arguments& args) {
|
||||
char line_buf[256];
|
||||
if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) {
|
||||
return ThrowException(String::New("Error reading line"));
|
||||
i::SmartPointer<char> line(i::ReadLine(""));
|
||||
if (*line == NULL) {
|
||||
return Null();
|
||||
}
|
||||
int len = strlen(line_buf);
|
||||
if (line_buf[len - 1] == '\n') {
|
||||
size_t len = strlen(*line);
|
||||
if (len > 0 && line[len - 1] == '\n') {
|
||||
--len;
|
||||
}
|
||||
return String::New(line_buf, len);
|
||||
return String::New(*line, len);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user