Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 2002 23:50:02 -0800 (PST)
From:      "Crist J. Clark" <cjc@FreeBSD.ORG>
To:        freebsd-bugs@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
Message-ID:  <200204050750.g357o2k99607@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR i386/36774; it has been noted by GNATS.

From: "Crist J. Clark" <cjc@FreeBSD.ORG>
To: Gerald Stoller <Gerald_Stoller@hotmail.com>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204050750.g357o2k99607>