4.4BSD's (and FreeBSD's) hexdump utility is missing the -s, -A, -j, -N, and -t options in its od compatibility mode. Here is a patch to add them. Fix: I've renamed the `deprecated' variable to `odmode' and removed everything to do with deprecation from the program and manual pages, added the -t option then rewritten all the other output-format options in terms of that. I've also written a manual page that is much more complete than the old one. long double output (-t fL) is not supported. This bug is documented in the new manual page. Adding support for long double would require changes all over the place, I thought it would be best to get it pretty close, then add long double support for hexdump, then od. How-To-Repeat: od -Ax -tx1 /dev/null
On Fri, Apr 05, 2002 at 09:13:39PM +1000, Tim J. Robbins wrote: > + n = (1ULL << (8 * size)) - 1; > + digits = 0; > + while (n != 0) { > + digits++; > + n >>= (fchar == 'o' || fchar == 'd') ? 3 : 4; > + } Oops. There is a little problem here with output of unsigned decimal numbers. --- odsyntax.c.old Fri Apr 5 21:37:47 2002 +++ odsyntax.c Fri Apr 5 21:41:07 2002 @@ -333,10 +333,11 @@ digits = 0; while (n != 0) { digits++; - n >>= (fchar == 'o' || fchar == 'd') ? 3 : 4; + n >>= (fchar == 'x') ? 4 : 3; } asprintf(&hdfmt, "%d/%d \"%%%s%d%c \" \"\\n\"", - 16 / size, size, fchar == 'd' ? "" : "0", + 16 / size, size, + (fchar == 'd' || fchar == 'u') ? "" : "0", digits, fchar); if (hdfmt == NULL) err(1, NULL); Tim
An improve version of ths patch is here for review. http://people.freebsd.org/~tjr/36783-od.diff The most notable changes from the previous patch I posted are some clarifications to the manual page, support for `long double' than I wimped out of adding before, and a WARNS=2 cleanup. I'd appreciate it if someone who knows IEEE floating point well could comment on at least the following: + case sizeof(long double): + odadd("1/12 \" %21.14e \" \"\\n\""); + break; This format string for long double is the same as that used for double. <machine/float.h> says #define LDBL_DIG DBL_DIG , but it seems odd to be printing out long doubles with no more precision than doubles. Tim
State Changed From-To: open->closed Committed to HEAD. I don't plan to MFC this.