| 57 | } |
| 58 | |
| 59 | Status BufferedInputStream::ReadLineHelper(string* result, bool include_eol) { |
| 60 | result->clear(); |
| 61 | Status s; |
| 62 | while (true) { |
| 63 | if (pos_ == limit_) { |
| 64 | // Get more data into buffer |
| 65 | s = FillBuffer(); |
| 66 | if (limit_ == 0) { |
| 67 | break; |
| 68 | } |
| 69 | } |
| 70 | char c = buf_[pos_++]; |
| 71 | if (c == '\n') { |
| 72 | if (include_eol) { |
| 73 | *result += c; |
| 74 | } |
| 75 | return Status::OK(); |
| 76 | } |
| 77 | // We don't append '\r' to *result |
| 78 | if (c != '\r') { |
| 79 | *result += c; |
| 80 | } |
| 81 | } |
| 82 | if (errors::IsOutOfRange(s) && !result->empty()) { |
| 83 | return Status::OK(); |
| 84 | } |
| 85 | return s; |
| 86 | } |
| 87 | |
| 88 | Status BufferedInputStream::ReadNBytes(int64 bytes_to_read, string* result) { |
| 89 | if (bytes_to_read < 0) { |