diff --git a/libinterp/corefcn/oct-stream.cc b/libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc +++ b/libinterp/corefcn/oct-stream.cc @@ -134,8 +134,9 @@ get_size (double d, const std::string& w return retval; } +template static void -get_size (const Array& size, octave_idx_type& nr, octave_idx_type& nc, +get_size (const Array& size, T& nr, T& nc, bool& one_elt_size_spec, const std::string& who) { nr = -1; @@ -6458,8 +6459,8 @@ octave_stream::read (const Array { octave_value retval; - octave_idx_type nr = -1; - octave_idx_type nc = -1; + std::ptrdiff_t nr = -1; + std::ptrdiff_t nc = -1; bool one_elt_size_spec = false; @@ -6473,7 +6474,7 @@ octave_stream::read (const Array // data_type enum in the oct_data_conv class. // Expose this in a future version? - octave_idx_type char_count = 0; + std::ptrdiff_t char_count = 0; count = 0; @@ -6486,7 +6487,7 @@ octave_stream::read (const Array invalid_operation ("fread", "reading"); } - octave_idx_type elts_to_read; + std::ptrdiff_t elts_to_read; if (one_elt_size_spec) { @@ -6517,12 +6518,12 @@ octave_stream::read (const Array // FIXME: Ensure that this does not overflow. // Maybe try comparing nr * nc computed in double with - // std::numeric_limits::max (); + // std::numeric_limits::max (); elts_to_read = nr * nc; bool read_to_eof = elts_to_read < 0; - octave_idx_type input_buf_elts = -1; + std::ptrdiff_t input_buf_elts = -1; if (skip == 0) { @@ -6534,10 +6535,10 @@ octave_stream::read (const Array else input_buf_elts = block_size; - octave_idx_type input_elt_size + std::ptrdiff_t input_elt_size = oct_data_conv::data_type_size (input_type); - octave_idx_type input_buf_size = input_buf_elts * input_elt_size; + std::ptrdiff_t input_buf_size = input_buf_elts * input_elt_size; assert (input_buf_size >= 0); @@ -6558,7 +6559,7 @@ octave_stream::read (const Array { if (! read_to_eof) { - octave_idx_type remaining_elts = elts_to_read - count; + std::ptrdiff_t remaining_elts = elts_to_read - count; if (remaining_elts < input_buf_elts) input_buf_size = remaining_elts * input_elt_size; @@ -6572,7 +6573,7 @@ octave_stream::read (const Array char_count += gcount; - octave_idx_type nel = gcount / input_elt_size; + std::ptrdiff_t nel = gcount / input_elt_size; count += nel;