Bug 36783 - P1003.1-2001 -s -A -j -N -t options for od(1) (patch)
Summary: P1003.1-2001 -s -A -j -N -t options for od(1) (patch)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: 4.5-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-standards (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-05 12:20 UTC by Tim J. Robbins
Modified: 2002-05-17 10:13 UTC (History)
0 users

See Also:


Attachments
file.diff (13.37 KB, patch)
2002-04-05 12:20 UTC, Tim J. Robbins
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim J. Robbins 2002-04-05 12:20:03 UTC
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
Comment 1 Tim J. Robbins 2002-04-05 12:42:09 UTC
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
Comment 2 Tim J. Robbins 2002-04-12 11:05:39 UTC
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
Comment 3 Tim Robbins freebsd_committer freebsd_triage 2002-05-17 10:11:22 UTC
State Changed
From-To: open->closed

Committed to HEAD. I don't plan to MFC this.