------------------------------------------------------------------------------ Internal function to read in a line up to 256 characters. Returns zero if there was an error.
| 252 | // Internal function to read in a line up to 256 characters. |
| 253 | // Returns zero if there was an error. |
| 254 | int vtkDataReader::ReadLine(char result[256]) |
| 255 | { |
| 256 | this->IS->getline(result, 256); |
| 257 | if (this->IS->fail()) |
| 258 | { |
| 259 | if (this->IS->eof()) |
| 260 | { |
| 261 | return 0; |
| 262 | } |
| 263 | if (this->IS->gcount() == 255) |
| 264 | { |
| 265 | // Read 256 chars; ignoring the rest of the line. |
| 266 | this->IS->clear(); |
| 267 | this->IS->ignore(VTK_INT_MAX, '\n'); |
| 268 | } |
| 269 | } |
| 270 | // remove '\r', if present. |
| 271 | size_t slen = strlen(result); |
| 272 | if (slen > 0 && result[slen - 1] == '\r') |
| 273 | { |
| 274 | result[slen - 1] = '\0'; |
| 275 | } |
| 276 | return 1; |
| 277 | } |
| 278 | |
| 279 | //------------------------------------------------------------------------------ |
| 280 | // Internal function to read in a string up to 256 characters. |
no test coverage detected