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
parent f7c799f0
...@@ -179,15 +179,15 @@ Handle<Value> Shell::Read(const Arguments& args) { ...@@ -179,15 +179,15 @@ Handle<Value> Shell::Read(const Arguments& args) {
Handle<Value> Shell::ReadLine(const Arguments& args) { Handle<Value> Shell::ReadLine(const Arguments& args) {
char line_buf[256]; i::SmartPointer<char> line(i::ReadLine(""));
if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) { if (*line == NULL) {
return ThrowException(String::New("Error reading line")); return Null();
} }
int len = strlen(line_buf); size_t len = strlen(*line);
if (line_buf[len - 1] == '\n') { if (len > 0 && line[len - 1] == '\n') {
--len; --len;
} }
return String::New(line_buf, len); return String::New(*line, len);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment