Mercurial > hg > octave-avbm
changeset 7995:89dd4531b26a
fread: translate NA values
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 30 Jul 2008 12:08:03 -0400 |
parents | 8ccd9b0bf6bc |
children | 6a7db240b3a3 |
files | src/ChangeLog src/oct-stream.cc |
diffstat | 2 files changed, 18 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2008-07-30 John W. Eaton <jwe@octave.org> + + * oct-stream.cc (do_read): New arg, do_NA_conv. + Perform NA translation if do_NA_conv is true. + (DO_READ_VAL_TEMPLATE, read_fptr): Include the new arg for do_read + in decl. + (octave_stream::read): Pass do_NA_conv to do_read. + 2008-07-29 David Bateman <dbateman@free.fr> * data.cc (FNA): Add tests for conversion of single to double NA
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -3026,7 +3026,7 @@ template <class RET_T, class READ_T> octave_value do_read (octave_stream& strm, octave_idx_type nr, octave_idx_type nc, octave_idx_type block_size, - octave_idx_type skip, bool do_float_fmt_conv, + octave_idx_type skip, bool do_float_fmt_conv, bool do_NA_conv, oct_mach_info::float_format from_flt_fmt, octave_idx_type& count) { octave_value retval; @@ -3139,6 +3139,9 @@ dat = nda.fortran_vec (); } + if (do_NA_conv && __lo_ieee_is_old_NA (tmp)) + tmp = __lo_ieee_replace_old_NA (tmp); + dat[count++] = tmp; elts_read++; @@ -3190,7 +3193,7 @@ #define DO_READ_VAL_TEMPLATE(RET_T, READ_T) \ template octave_value \ - do_read<RET_T, READ_T> (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, \ + do_read<RET_T, READ_T> (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, \ oct_mach_info::float_format, octave_idx_type&) // FIXME -- should we only have float if it is a different @@ -3224,7 +3227,7 @@ INSTANTIATE_DO_READ (charNDArray); INSTANTIATE_DO_READ (boolNDArray); -typedef octave_value (*read_fptr) (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, +typedef octave_value (*read_fptr) (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, oct_mach_info::float_format ffmt, octave_idx_type&); NO_INSTANTIATE_ARRAY_SORT (read_fptr); @@ -3314,10 +3317,13 @@ || input_type == oct_data_conv::dt_single) && ffmt != float_format ()); + bool do_NA_conv = (output_type == oct_data_conv::dt_double); + if (fcn) { retval = (*fcn) (*this, nr, nc, block_size, skip, - do_float_fmt_conv, ffmt, char_count); + do_float_fmt_conv, do_NA_conv, + ffmt, char_count); // FIXME -- kluge!