Mercurial > hg > octave-lyh
comparison src/zfstream.cc @ 10317:42d098307c30
untabify additional source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 13:30:42 -0500 |
parents | cd96d29c5efa |
children | fd0a3ac60b0e |
comparison
equal
deleted
inserted
replaced
10316:9966f1f71c32 | 10317:42d098307c30 |
---|---|
222 gzfilebuf::pbackfail (gzfilebuf::int_type c) | 222 gzfilebuf::pbackfail (gzfilebuf::int_type c) |
223 { | 223 { |
224 if (this->is_open()) | 224 if (this->is_open()) |
225 { | 225 { |
226 if (gzseek (file, this->gptr() - this->egptr() - 1, SEEK_CUR) < 0) | 226 if (gzseek (file, this->gptr() - this->egptr() - 1, SEEK_CUR) < 0) |
227 return traits_type::eof(); | 227 return traits_type::eof(); |
228 | 228 |
229 // Invalidates contents of the buffer | 229 // Invalidates contents of the buffer |
230 enable_buffer (); | 230 enable_buffer (); |
231 | 231 |
232 // Attempt to fill internal buffer from gzipped file | 232 // Attempt to fill internal buffer from gzipped file |
233 // (buffer must be guaranteed to exist...) | 233 // (buffer must be guaranteed to exist...) |
234 int bytes_read = gzread(file, buffer, buffer_size); | 234 int bytes_read = gzread(file, buffer, buffer_size); |
235 // Indicates error or EOF | 235 // Indicates error or EOF |
236 if (bytes_read <= 0) | 236 if (bytes_read <= 0) |
237 { | 237 { |
238 // Reset get area | 238 // Reset get area |
239 this->setg(buffer, buffer, buffer); | 239 this->setg(buffer, buffer, buffer); |
240 return traits_type::eof(); | 240 return traits_type::eof(); |
241 } | 241 } |
242 | 242 |
243 // Make all bytes read from file available as get area | 243 // Make all bytes read from file available as get area |
244 this->setg(buffer, buffer, buffer + bytes_read); | 244 this->setg(buffer, buffer, buffer + bytes_read); |
245 | 245 |
246 // If next character in get area differs from putback character | 246 // If next character in get area differs from putback character |
247 // flag a failure | 247 // flag a failure |
248 gzfilebuf::int_type ret = traits_type::to_int_type(*(this->gptr())); | 248 gzfilebuf::int_type ret = traits_type::to_int_type(*(this->gptr())); |
249 if (ret != c) | 249 if (ret != c) |
250 return traits_type::eof(); | 250 return traits_type::eof(); |
251 else | 251 else |
252 return ret; | 252 return ret; |
253 } | 253 } |
254 else | 254 else |
255 return traits_type::eof(); | 255 return traits_type::eof(); |
256 } | 256 } |
257 | 257 |
274 if (this->eback() && buffer && buffer_size > STASHED_CHARACTERS) | 274 if (this->eback() && buffer && buffer_size > STASHED_CHARACTERS) |
275 { | 275 { |
276 char_type *ptr1 = buffer; | 276 char_type *ptr1 = buffer; |
277 char_type *ptr2 = this->egptr() - STASHED_CHARACTERS + 1; | 277 char_type *ptr2 = this->egptr() - STASHED_CHARACTERS + 1; |
278 if (ptr2 > this->eback()) | 278 if (ptr2 > this->eback()) |
279 while (stash++ <= STASHED_CHARACTERS) | 279 while (stash++ <= STASHED_CHARACTERS) |
280 *ptr1++ = *ptr2++; | 280 *ptr1++ = *ptr2++; |
281 } | 281 } |
282 | 282 |
283 // Attempt to fill internal buffer from gzipped file | 283 // Attempt to fill internal buffer from gzipped file |
284 // (buffer must be guaranteed to exist...) | 284 // (buffer must be guaranteed to exist...) |
285 int bytes_read = gzread(file, buffer + stash, buffer_size - stash); | 285 int bytes_read = gzread(file, buffer + stash, buffer_size - stash); |
460 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 460 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
461 | 461 |
462 // Seek functions | 462 // Seek functions |
463 gzfilebuf::pos_type | 463 gzfilebuf::pos_type |
464 gzfilebuf::seekoff(off_type off, std::ios_base::seekdir way, | 464 gzfilebuf::seekoff(off_type off, std::ios_base::seekdir way, |
465 std::ios_base::openmode) | 465 std::ios_base::openmode) |
466 { | 466 { |
467 pos_type ret = pos_type (off_type (-1)); | 467 pos_type ret = pos_type (off_type (-1)); |
468 | 468 |
469 if (this->is_open()) | 469 if (this->is_open()) |
470 { | 470 { |
471 off_type computed_off = off; | 471 off_type computed_off = off; |
472 | 472 |
473 if ((io_mode & std::ios_base::in) && way == std::ios_base::cur) | 473 if ((io_mode & std::ios_base::in) && way == std::ios_base::cur) |
474 computed_off += this->gptr() - this->egptr(); | 474 computed_off += this->gptr() - this->egptr(); |
475 | 475 |
476 if (way == std::ios_base::beg) | 476 if (way == std::ios_base::beg) |
477 ret = pos_type (gzseek (file, computed_off, SEEK_SET)); | 477 ret = pos_type (gzseek (file, computed_off, SEEK_SET)); |
478 else if (way == std::ios_base::cur) | 478 else if (way == std::ios_base::cur) |
479 ret = pos_type (gzseek (file, computed_off, SEEK_CUR)); | 479 ret = pos_type (gzseek (file, computed_off, SEEK_CUR)); |
480 else | 480 else |
481 // Can't seek from end of a gzipped file, so this will give -1 | 481 // Can't seek from end of a gzipped file, so this will give -1 |
482 ret = pos_type (gzseek (file, computed_off, SEEK_END)); | 482 ret = pos_type (gzseek (file, computed_off, SEEK_END)); |
483 | 483 |
484 if (io_mode & std::ios_base::in) | 484 if (io_mode & std::ios_base::in) |
485 // Invalidates contents of the buffer | 485 // Invalidates contents of the buffer |
486 enable_buffer (); | 486 enable_buffer (); |
487 else | 487 else |
488 // flush contents of buffer to file | 488 // flush contents of buffer to file |
489 overflow (); | 489 overflow (); |
490 } | 490 } |
491 | 491 |
492 return ret; | 492 return ret; |
493 } | 493 } |
494 | 494 |
500 if (this->is_open ()) | 500 if (this->is_open ()) |
501 { | 501 { |
502 ret = pos_type (gzseek (file, sp, SEEK_SET)); | 502 ret = pos_type (gzseek (file, sp, SEEK_SET)); |
503 | 503 |
504 if (io_mode & std::ios_base::in) | 504 if (io_mode & std::ios_base::in) |
505 // Invalidates contents of the buffer | 505 // Invalidates contents of the buffer |
506 enable_buffer (); | 506 enable_buffer (); |
507 else | 507 else |
508 // flush contents of buffer to file | 508 // flush contents of buffer to file |
509 overflow (); | 509 overflow (); |
510 } | 510 } |
511 | 511 |
512 return ret; | 512 return ret; |
513 } | 513 } |
514 | 514 |