# HG changeset patch # User Mike Miller # Date 1464204119 25200 # Node ID 1e81dd035639a8da963982f6a98e6e742b7eea22 # Parent 7496bd7265d9deae5826e3c036c0217bb55fbd57 Write integers with correct byte order on big-endian systems (bug #47434) * oct-stream.cc (convert_data, octave_stream::write): Fix logic error in determination of whether to swap bytes on big-endian systems. diff -r 7496bd7265d9 -r 1e81dd035639 libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Tue May 24 11:44:45 2016 -0700 +++ b/libinterp/corefcn/oct-stream.cc Wed May 25 12:21:59 2016 -0700 @@ -3631,10 +3631,12 @@ { bool retval = true; - bool swap - = ((oct_mach_info::words_big_endian () - && flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian) - || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); + bool swap = false; + + if (oct_mach_info::words_big_endian ()) + swap = (flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian); + else + swap = (flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); bool do_float_conversion = flt_fmt != oct_mach_info::float_format (); @@ -3800,9 +3802,12 @@ octave_idx_type skip, oct_mach_info::float_format flt_fmt) { - bool swap = ((oct_mach_info::words_big_endian () - && flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian) - || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); + bool swap = false; + + if (oct_mach_info::words_big_endian ()) + swap = (flt_fmt == oct_mach_info::flt_fmt_ieee_little_endian); + else + swap = (flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian); bool do_data_conversion = (swap || ! is_equivalent_type (output_type) || flt_fmt != oct_mach_info::float_format ());