Mercurial > hg > octave-lyh
comparison src/zfstream.cc @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
11585:1473d0cf86d2 | 11586:12df7854fa7c |
---|---|
1 /* | 1 /* |
2 | 2 |
3 Copyright (C) 2005-2011 Ludwig Schwardt, Kevin Ruland | 3 Copyright (C) 2005-2011 Ludwig Schwardt, Kevin Ruland |
4 | 4 |
5 | 5 |
6 This file is part of Octave. | 6 This file is part of Octave. |
7 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | 8 Octave is free software; you can redistribute it and/or modify it |
44 #include <cstring> // for strcpy, strcat, strlen (mode strings) | 44 #include <cstring> // for strcpy, strcat, strlen (mode strings) |
45 #include <cstdio> // for BUFSIZ | 45 #include <cstdio> // for BUFSIZ |
46 | 46 |
47 // Internal buffer sizes (default and "unbuffered" versions) | 47 // Internal buffer sizes (default and "unbuffered" versions) |
48 #define STASHED_CHARACTERS 16 | 48 #define STASHED_CHARACTERS 16 |
49 #define BIGBUFSIZE (256 * 1024 + STASHED_CHARACTERS) | 49 #define BIGBUFSIZE (256 * 1024 + STASHED_CHARACTERS) |
50 #define SMALLBUFSIZE 1 | 50 #define SMALLBUFSIZE 1 |
51 | 51 |
52 /*****************************************************************************/ | 52 /*****************************************************************************/ |
53 | 53 |
54 // Default constructor | 54 // Default constructor |
214 return 0; | 214 return 0; |
215 } | 215 } |
216 | 216 |
217 // Puts back a character to the stream in two cases. Firstly, when there | 217 // Puts back a character to the stream in two cases. Firstly, when there |
218 // is no putback position available, and secondly when the character putback | 218 // is no putback position available, and secondly when the character putback |
219 // differs from the one in the file. We can only support the first case | 219 // differs from the one in the file. We can only support the first case |
220 // with gzipped files. | 220 // with gzipped files. |
221 gzfilebuf::int_type | 221 gzfilebuf::int_type |
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...) |
459 | 459 |
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()) |
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 |