From owner-freebsd-bugs Thu Apr 4 23:50:10 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EC42337B405 for ; Thu, 4 Apr 2002 23:50:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g357o2k99607; Thu, 4 Apr 2002 23:50:02 -0800 (PST) (envelope-from gnats) Date: Thu, 4 Apr 2002 23:50:02 -0800 (PST) Message-Id: <200204050750.g357o2k99607@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Crist J. Clark" Subject: Re: i386/36774: The hexdump & od commands doesn't present the input data in the same order among their various formats on the IBM PC Reply-To: "Crist J. Clark" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR i386/36774; it has been noted by GNATS. From: "Crist J. Clark" To: Gerald Stoller Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: i386/36774: The hexdump & od commands doesn't present the input data in the same order among their various formats on the IBM PC Date: Thu, 4 Apr 2002 23:40:18 -0800 On Thu, Apr 04, 2002 at 08:40:45PM -0800, Gerald Stoller wrote: [snip] > The hexdump & od commands doesn't present the input data in > the same order among their various formats on the IBM PC (due to the > order-difference between bytes in byte-pairs and shorts [little-endian]). hexdump(8) doesn't know where the data came from. It just sees a stream of bytes. > For hexdump , look at the pipeline > echo -123- | hexdump -cxo > whose output is > 0000000 - 1 2 3 - \n > 0000000 312d 3332 0a2d > 0000000 030455 031462 005055 > 0000006 > and you can see the reversal of the pairs of bytes between the first > three lines, and also that the columns don't line up. But that is the correct and expected output. > >How-To-Repeat: > Just execute the pipeline > echo -123- | hexdump -cxo > >Fix: > Don't use shorts (or the like) to pick up data in hexdump , use bytes only. 'Twould be better if the first three lines of the output were > 0000000 - 1 2 3 - \n > 0000000 2d 31 32 33 2d 0a # echo -123- | hexdump -e '"%07.7_ao" 16/1 " %02x " "\n"' > 0000000 055 061 062 063 055 012 # echo -123- | hexdump -b As to the other point, if you don't do the endian swap it breaks reading binary data. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message