Tony Kocurko <[EMAIL PROTECTED]> wrote: > Hi, > > I believe that lines 137 and 138 of od.c ought to be changed > from this: > > sizeof (long int), > sizeof (float), > > to this: > > sizeof (long int), > sizeof (long long), > sizeof (float), > > Without that change on our RedHat Linux 7.2 Intel systems, the > "od -t f8" command complains about an incorrect size and > substitutes a size of 12 for a double, rather than using the 8 > that it should.
Thanks a lot for the reports and patch. Here's how I've fixed it: This bug was introduced with my change of 2000-10-22 (textutils-2.0.8). * src/od.c (ulonglong_t): Move declaration to precede new use. [enum size_spec] (N_SIZE_SPECS): New member. (width_bytes): Add initializer corresponding to ulonglong_t type. (struct assert_width_bytes_matches_size_spec_decl): Declare. Based on a patch from Tony Kocurko. Index: od.c =================================================================== RCS file: /fetish/textutils/src/od.c,v retrieving revision 1.125 retrieving revision 1.126 diff -u -p -u -r1.125 -r1.126 --- od.c 16 Feb 2002 07:37:15 -0000 1.125 +++ od.c 14 May 2002 21:31:42 -0000 1.126 @@ -66,6 +66,14 @@ typedef double LONG_DOUBLE; # define LDBL_DIG DBL_DIG #endif +#if HAVE_UNSIGNED_LONG_LONG +typedef unsigned long long ulonglong_t; +#else +/* This is just a place-holder to avoid a few `#if' directives. + In this case, the type isn't actually used. */ +typedef unsigned long int ulonglong_t; +#endif + enum size_spec { NO_SIZE, @@ -77,7 +85,8 @@ enum size_spec /* FIXME: add INTMAX support, too */ FLOAT_SINGLE, FLOAT_DOUBLE, - FLOAT_LONG_DOUBLE + FLOAT_LONG_DOUBLE, + N_SIZE_SPECS }; enum output_format @@ -136,11 +145,20 @@ static const int width_bytes[] = sizeof (short int), sizeof (int), sizeof (long int), + sizeof (ulonglong_t), sizeof (float), sizeof (double), sizeof (LONG_DOUBLE) }; +/* Ensure that for each member of `enum size_spec' there is an + initializer in the width_bytes array. */ +struct assert_width_bytes_matches_size_spec_decl +{ + int t1[sizeof width_bytes / sizeof width_bytes[0] - N_SIZE_SPECS]; + int t2[N_SIZE_SPECS - sizeof width_bytes / sizeof width_bytes[0]]; +}; + /* Names for some non-printing characters. */ static const char *const charname[33] = { @@ -230,14 +248,6 @@ static FILE *in_stream; /* If nonzero, at least one of the files we read was standard input. */ static int have_read_stdin; - -#if HAVE_UNSIGNED_LONG_LONG -typedef unsigned long long ulonglong_t; -#else -/* This is just a place-holder to avoid a few `#if' directives. - In this case, the type isn't actually used. */ -typedef unsigned long int ulonglong_t; -#endif #define MAX_INTEGRAL_TYPE_SIZE sizeof (ulonglong_t) static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1]; _______________________________________________ Bug-textutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-textutils