# HG changeset patch # User John W. Eaton # Date 1217434083 14400 # Node ID 89dd4531b26a0c8654ce6e9d5ffddcbbb37921d0 # Parent 8ccd9b0bf6bcc747aa43ade83e2a863f562bef2c fread: translate NA values diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2008-07-30 John W. Eaton + + * 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 * data.cc (FNA): Add tests for conversion of single to double NA diff --git a/src/oct-stream.cc b/src/oct-stream.cc --- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -3026,7 +3026,7 @@ template 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 (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, \ + do_read (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!