# HG changeset patch # User jwe # Date 1132598672 0 # Node ID 2286fa5f2e5dda7ed8661f7e9a3073e7dc7abe81 # Parent 4d52e637a72aa08d668d6e5a7b9c63d82bb134d6 [project @ 2005-11-21 18:44:31 by jwe] diff -r 4d52e637a72a -r 2286fa5f2e5d src/ChangeLog --- a/src/ChangeLog Mon Nov 21 16:13:47 2005 +0000 +++ b/src/ChangeLog Mon Nov 21 18:44:32 2005 +0000 @@ -1,3 +1,15 @@ +2005-11-21 John W. Eaton + + * pr-output.cc (pr_int): Fix thinko in byte-swapping for bit format. + + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): + Use C++ static_cast instead of C-style casts. + +2005-11-21 William Poetra Yoga H + + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): + Docstring and error message fixes. + 2005-11-17 John W. Eaton * DLD-FUNCTIONS/minmax.cc (MINMAX_BODY): Don't cast arg1 to diff -r 4d52e637a72a -r 2286fa5f2e5d src/DLD-FUNCTIONS/cellfun.cc --- a/src/DLD-FUNCTIONS/cellfun.cc Mon Nov 21 16:13:47 2005 +0000 +++ b/src/DLD-FUNCTIONS/cellfun.cc Mon Nov 21 18:44:32 2005 +0000 @@ -147,21 +147,21 @@ { NDArray result (f_args.dims ()); for (int count= 0; count < k ; count++) - result(count) = double (f_args.elem(count).length ()); + result(count) = static_cast (f_args.elem(count).length ()); retval = result; } else if (name == "ndims") { NDArray result (f_args.dims ()); for (int count = 0; count < k ; count++) - result(count) = double (f_args.elem(count).ndims ()); + result(count) = static_cast (f_args.elem(count).ndims ()); retval = result; } else if (name == "prodofsize") { NDArray result (f_args.dims ()); for (int count = 0; count < k ; count++) - result(count) = double (f_args.elem(count).numel ()); + result(count) = static_cast (f_args.elem(count).numel ()); retval = result; } else if (name == "size") @@ -180,7 +180,7 @@ { dim_vector dv = f_args.elem(count).dims (); if (d < dv.length ()) - result(count) = double (dv(d)); + result(count) = static_cast (dv(d)); else result(count) = 1.0; } diff -r 4d52e637a72a -r 2286fa5f2e5d src/pr-output.cc --- a/src/pr-output.cc Mon Nov 21 16:13:47 2005 +0000 +++ b/src/pr-output.cc Mon Nov 21 18:44:32 2005 +0000 @@ -1106,6 +1106,12 @@ { if (fmt) { + // Unless explicitly asked for, always print in big-endian + // format for hex and bit formats. + // + // {bit,hex}_format == 1: print big-endian + // {bit,hex}_format == 2: print native + if (hex_format) { equiv tmp; @@ -1151,9 +1157,6 @@ equiv tmp; tmp.d = d; - // Unless explicitly asked for, always print in big-endian - // format. - // XXX FIXME XXX -- is it correct to swap bytes for VAX // formats and not for Cray? @@ -2125,6 +2128,12 @@ size_t sz = d.byte_size(); const unsigned char * tmpi = d.iptr(); + // Unless explicitly asked for, always print in big-endian + // format for hex and bit formats. + // + // {bit,hex}_format == 1: print big-endian + // {bit,hex}_format == 2: print native + if (hex_format) { char ofill = os.fill ('0'); @@ -2148,15 +2157,23 @@ } else if (bit_format) { - if (bit_format > 1 || oct_mach_info::words_big_endian ()) + if (oct_mach_info::words_big_endian ()) { for (size_t i = 0; i < sz; i++) - PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); + PRINT_CHAR_BITS (os, tmpi[i]); } else { - for (int i = sz - 1; i >= 0; i--) - PRINT_CHAR_BITS (os, tmpi[i]); + if (bit_format > 1) + { + for (size_t i = 0; i < sz; i++) + PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); + } + else + { + for (int i = sz - 1; i >= 0; i--) + PRINT_CHAR_BITS (os, tmpi[i]); + } } } else