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:
christian.plesner.hansen@gmail.com 2009-09-07 12:37:56 +00:00
parent f7c799f0a2
commit 223973ef9b

View File

@ -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);
}