Mercurial > octave-nkf
comparison libinterp/corefcn/oct-stream.cc @ 18515:bc31d9359cf9
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 21 Feb 2014 18:20:35 -0500 |
parents | 775e7874b38d fdd27f68b011 |
children | f958e8cd6348 |
comparison
equal
deleted
inserted
replaced
18506:146ce31e5d28 | 18515:bc31d9359cf9 |
---|---|
3273 std::list <void *> input_buf_list; | 3273 std::list <void *> input_buf_list; |
3274 | 3274 |
3275 while (is && ! is.eof () | 3275 while (is && ! is.eof () |
3276 && (read_to_eof || count < elts_to_read)) | 3276 && (read_to_eof || count < elts_to_read)) |
3277 { | 3277 { |
3278 if (! read_to_eof) | |
3279 { | |
3280 octave_idx_type remaining_elts = elts_to_read - count; | |
3281 | |
3282 if (remaining_elts < input_buf_elts) | |
3283 input_buf_size = remaining_elts * input_elt_size; | |
3284 } | |
3285 | |
3278 char *input_buf = new char [input_buf_size]; | 3286 char *input_buf = new char [input_buf_size]; |
3279 | 3287 |
3280 is.read (input_buf, input_buf_size); | 3288 is.read (input_buf, input_buf_size); |
3281 | 3289 |
3282 size_t gcount = is.gcount (); | 3290 size_t gcount = is.gcount (); |
3283 | 3291 |
3284 char_count += gcount; | 3292 char_count += gcount; |
3285 | 3293 |
3286 count += gcount / input_elt_size; | 3294 size_t nel = gcount / input_elt_size; |
3295 | |
3296 count += nel; | |
3287 | 3297 |
3288 input_buf_list.push_back (input_buf); | 3298 input_buf_list.push_back (input_buf); |
3289 | 3299 |
3290 if (is && skip != 0 && count == block_size) | 3300 if (is && skip != 0 && nel == block_size) |
3291 { | 3301 { |
3292 int seek_status = seek (skip, SEEK_CUR); | 3302 // Seek to skip. If skip would move past EOF, |
3293 | 3303 // position at EOF. |
3294 if (seek_status < 0) | 3304 |
3305 off_t orig_pos = tell (); | |
3306 | |
3307 seek (0, SEEK_END); | |
3308 | |
3309 off_t eof_pos = tell (); | |
3310 | |
3311 // Is it possible for this to fail to return us to | |
3312 // the original position? | |
3313 seek (orig_pos, SEEK_SET); | |
3314 | |
3315 size_t remaining = eof_pos - orig_pos; | |
3316 | |
3317 if (remaining < skip) | |
3318 seek (0, SEEK_END); | |
3319 else | |
3320 seek (skip, SEEK_CUR); | |
3321 | |
3322 if (! is) | |
3295 break; | 3323 break; |
3296 } | 3324 } |
3297 } | 3325 } |
3298 | 3326 |
3299 if (read_to_eof) | 3327 if (read_to_eof) |