Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Issue 7537023: Fixed: regression in issue 1579 concerning readline() in d8. (Closed)

Created:
9 years, 4 months ago by Yang
Modified:
9 years, 4 months ago
Reviewers:
Sven Panne
CC:
v8-dev
Visibility:
Public.

Description

Fixed: regression in issue 1579 concerning readline() in d8. BUG=v8:1579 Committed: http://code.google.com/p/v8/source/detail?r=8771

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -8 lines) Patch
M src/d8.cc View 1 chunk +14 lines, -8 lines 2 comments Download

Messages

Total messages: 2 (0 generated)
Yang
PTAL. The bug: readline() did not continue reading from a line that exceeded the buffer ...
9 years, 4 months ago (2011-08-01 09:40:49 UTC) #1
Sven Panne
9 years, 4 months ago (2011-08-01 11:25:05 UTC) #2
LGTM modulo stylistic comments

http://codereview.chromium.org/7537023/diff/1/src/d8.cc
File src/d8.cc (right):

http://codereview.chromium.org/7537023/diff/1/src/d8.cc#newcode235
src/d8.cc:235: length = static_cast<int>(strlen(buffer));
Using size_t for length gets rid of the cast. Furthermore, move declation into
this loop, keeping the scope as small as possible.

http://codereview.chromium.org/7537023/diff/1/src/d8.cc#newcode236
src/d8.cc:236: if (length == 0) return accumulator;
In general, a simple if-then-else cascade is easier to read than nested logic,
e.g. in our concrete example:

if (length == 0) {
  // should never happen, but anyway...
  return accumulator;
} else if (buffer[length-1] != '\n') {
  // line doesn't fit into buffer, continue reading
  String::Concat(accumulator, String::New(buffer, length));
} else if (length >= 2 && buffer[length-2] == '\\') {
  // continuation line: replace backslash by newline and continue reading
  buffer[length-2] = '\n';
  String::Concat(accumulator, String::New(buffer, length - 1));
} else {
  // normal line, fitting into buffer
  return String::Concat(accumulator, String::New(buffer, length - 1));
}

Powered by Google App Engine
This is Rietveld 408576698