9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] xd bug
@ 2008-07-10 21:26 Pietro Gagliardi
  2008-07-14 16:43 ` Russ Cox
  0 siblings, 1 reply; 6+ messages in thread
From: Pietro Gagliardi @ 2008-07-10 21:26 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello. Regarding my previous question, the file /n/sources/contrib/
pietro/xd.out shows a bug in xd regarding characters that can't be
printed with the %c format. There should be no space between a non-
printing and a printing character; but the two spaces screw the rest
of the line up. This shows a deficiency in the table-based
implementation. I'll do my best to fix it in a clean way. Thanks.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] xd bug
  2008-07-10 21:26 [9fans] xd bug Pietro Gagliardi
@ 2008-07-14 16:43 ` Russ Cox
  2008-07-14 17:02   ` Pietro Gagliardi
  0 siblings, 1 reply; 6+ messages in thread
From: Russ Cox @ 2008-07-14 16:43 UTC (permalink / raw)
  To: 9fans

> Hello. Regarding my previous question, the file /n/sources/contrib/
> pietro/xd.out shows a bug in xd regarding characters that can't be
> printed with the %c format. There should be no space between a non-
> printing and a printing character; but the two spaces screw the rest
> of the line up. This shows a deficiency in the table-based
> implementation. I'll do my best to fix it in a clean way. Thanks.

It would help a lot if (1) you cut and pasted things into email
instead of making us go look on sources for four-line files
and (2) you told us exactly what you thought was wrong.

Your xd.out says:

% xd -c -x bad
0000000  e0  Q  R  S \n
      0  e0515253 0a000000
0000005

which looks fine to me.  If I create the same file and add some
more text just to fill things out, I get:

% xd -c -b -x a | sed 6q
0000000  e0  Q  R  S \n  L  o  r  e  m     i  p  s  u  m
      0  e0 51 52 53 0a 4c 6f 72 65 6d 20 69 70 73 75 6d
      0  e0515253 0a4c6f72 656d2069 7073756d
0000010      d  o  l  o  r     s  i  t     a  m  e  t  ,
     10  20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c
     10  20646f6c 6f722073 69742061 6d65742c

which still looks just fine.  In particular I don't see any
alignment difference between the first line and the second line.

Russ



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] xd bug
  2008-07-14 16:43 ` Russ Cox
@ 2008-07-14 17:02   ` Pietro Gagliardi
  2008-07-14 17:13     ` erik quanstrom
  2008-07-14 17:22     ` Russ Cox
  0 siblings, 2 replies; 6+ messages in thread
From: Pietro Gagliardi @ 2008-07-14 17:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

If you look more closely at the alignment of the characters to the hex
values you will see that xd thinks Q has character code 0x525 and R
has character code 3. It should look more like

% xd -c -x bad
0000000  e0Q R S  \n
      0  e0515253 0a000000
0000005

On Jul 14, 2008, at 12:43 PM, Russ Cox wrote:

>> Hello. Regarding my previous question, the file /n/sources/contrib/
>> pietro/xd.out shows a bug in xd regarding characters that can't be
>> printed with the %c format. There should be no space between a non-
>> printing and a printing character; but the two spaces screw the rest
>> of the line up. This shows a deficiency in the table-based
>> implementation. I'll do my best to fix it in a clean way. Thanks.
>
> It would help a lot if (1) you cut and pasted things into email
> instead of making us go look on sources for four-line files
> and (2) you told us exactly what you thought was wrong.
>
> Your xd.out says:
>
> % xd -c -x bad
> 0000000  e0  Q  R  S \n
>      0  e0515253 0a000000
> 0000005
>
> which looks fine to me.  If I create the same file and add some
> more text just to fill things out, I get:
>
> % xd -c -b -x a | sed 6q
> 0000000  e0  Q  R  S \n  L  o  r  e  m     i  p  s  u  m
>      0  e0 51 52 53 0a 4c 6f 72 65 6d 20 69 70 73 75 6d
>      0  e0515253 0a4c6f72 656d2069 7073756d
> 0000010      d  o  l  o  r     s  i  t     a  m  e  t  ,
>     10  20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c
>     10  20646f6c 6f722073 69742061 6d65742c
>
> which still looks just fine.  In particular I don't see any
> alignment difference between the first line and the second line.
>
> Russ
>
>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] xd bug
  2008-07-14 17:02   ` Pietro Gagliardi
@ 2008-07-14 17:13     ` erik quanstrom
  2008-07-14 21:10       ` Pietro Gagliardi
  2008-07-14 17:22     ` Russ Cox
  1 sibling, 1 reply; 6+ messages in thread
From: erik quanstrom @ 2008-07-14 17:13 UTC (permalink / raw)
  To: 9fans

> If you look more closely at the alignment of the characters to the hex
> values you will see that xd thinks Q has character code 0x525 and R
> has character code 3. It should look more like
>
> % xd -c -x bad
> 0000000  e0Q R S  \n
>       0  e0515253 0a000000
> 0000005

-x by itself doesn't output the hex codes
for bytes, it outputs the hex codes for 4 byte
integers.  i think you're thinking of this command
line instead

; xd -c -1x bad
0000000  e0  Q  R  S \n
      0  e0 51 52 53 0a

- erik




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] xd bug
  2008-07-14 17:02   ` Pietro Gagliardi
  2008-07-14 17:13     ` erik quanstrom
@ 2008-07-14 17:22     ` Russ Cox
  1 sibling, 0 replies; 6+ messages in thread
From: Russ Cox @ 2008-07-14 17:22 UTC (permalink / raw)
  To: 9fans

> If you look more closely at the alignment of the characters to the hex
> values you will see that xd thinks Q has character code 0x525 and R
> has character code 3. It should look more like
>
> % xd -c -x bad
> 0000000  e0Q R S  \n
>       0  e0515253 0a000000
> 0000005

The -c and -x formats are not intended to align.
If you want hex codes aligned with characters, use -b.

% echo ABCD | xd -c -x
0000000   A  B  C  D \n
      0  41424344 0a000000
0000005
%

Russ



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] xd bug
  2008-07-14 17:13     ` erik quanstrom
@ 2008-07-14 21:10       ` Pietro Gagliardi
  0 siblings, 0 replies; 6+ messages in thread
From: Pietro Gagliardi @ 2008-07-14 21:10 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Jul 14, 2008, at 1:13 PM, erik quanstrom wrote:
> -x by itself doesn't output the hex codes
> for bytes, it outputs the hex codes for 4 byte
> integers.  i think you're thinking of this command
> line instead
>
> ; xd -c -1x bad
> 0000000  e0  Q  R  S \n
>      0  e0 51 52 53 0a


On Jul 14, 2008, at 1:22 PM, Russ Cox wrote:
> The -c and -x formats are not intended to align.
> If you want hex codes aligned with characters, use -b.

Thanks for the clarifications. -b == -1x, so both solve this
misunderstanding.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-14 21:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-10 21:26 [9fans] xd bug Pietro Gagliardi
2008-07-14 16:43 ` Russ Cox
2008-07-14 17:02   ` Pietro Gagliardi
2008-07-14 17:13     ` erik quanstrom
2008-07-14 21:10       ` Pietro Gagliardi
2008-07-14 17:22     ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).