unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
@ 2010-12-15 20:58 Joel J. Adamson
  2010-12-19 11:51 ` Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: Joel J. Adamson @ 2010-12-15 20:58 UTC (permalink / raw)
  To: Joel J. Adamson, bug-guile


URL:
  <http://savannah.gnu.org/bugs/?31893>

                 Summary: ice-9 format produces control characters and
non-printable characters for numeric output
                 Project: Guile
            Submitted by: trashbird1240
            Submitted on: Wed 15 Dec 2010 03:58:34 PM EST
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Format produces non-printable output for certain expressions:

In an Emacs *shell* buffer:

scheme@(guile-user)> (format #t "~{~9,8,,,0g ~}~%" '(0.001 2.8 0.00))




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 15 Dec 2010 03:58:34 PM EST  Name: ss_theory_scm.tar.gz  Size: 4kB 
 By: trashbird1240

<http://savannah.gnu.org/bugs/download.php?file_id=22211>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31893>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




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

* [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
  2010-12-15 20:58 [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output Joel J. Adamson
@ 2010-12-19 11:51 ` Andy Wingo
  2010-12-19 12:14   ` Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2010-12-19 11:51 UTC (permalink / raw)
  To: Andy Wingo, Joel J. Adamson, bug-guile


Follow-up Comment #1, bug #31893 (project guile):

Very interesting! We can make the test case shorter:

> (format #f "~9,8,,,0g" 0.001)
$1 = "x00x00x00x00x00x00x00x00x00"


I think the x00 bytes are because of the recent make-string change
(3ef6650def28f7c29a2cc983086468d3195167d4). The control chars you were seeing
previously were just random bytes from memory (!), whatever was there before
make-string was called.

I'm on it!

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31893>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




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

* [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
  2010-12-19 11:51 ` Andy Wingo
@ 2010-12-19 12:14   ` Andy Wingo
  2010-12-20  2:55     ` Joel J. Adamson
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2010-12-19 12:14 UTC (permalink / raw)
  To: Andy Wingo, Joel J. Adamson, bug-guile


Update of bug #31893 (project guile):

                  Status:                    None => Invalid                
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #2:

Actually I think this problem is less exciting. Your format was:

~9,8,,,0g

So you are specifying a width of 9 chars, 8 mantissa digits, and an "overflow
character" of zero, which also has the effect of making the width a hard
limit. Also note that your overflow char is (integer->char 0), not #  -- the
nul byte, indeed a control character.

In this case the width of the whole thing will always be more than 9
characters, so we always splat in the overflow char, which is #nul -- leading
to the result given in my first comment.

In the future for debugging these things, don't print to the terminal --
print to a string instead. That will be clearer.

Cheers,

Andy

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31893>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




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

* Re: [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
  2010-12-19 12:14   ` Andy Wingo
@ 2010-12-20  2:55     ` Joel J. Adamson
  2010-12-20 17:26       ` Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: Joel J. Adamson @ 2010-12-20  2:55 UTC (permalink / raw)
  To: Andy Wingo; +Cc: bug-guile

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Andy Wingo <INVALID.NOREPLY@gnu.org> writes:

> Actually I think this problem is less exciting.

This is exactly what I was hoping for!

> Your format was:
>
> ~9,8,,,0g
>
> So you are specifying a width of 9 chars, 8 mantissa digits, and an
> "overflow character" of zero, which also has the effect of making the
> width a hard limit. Also note that your overflow char is
> (integer->char 0), not # -- the nul byte, indeed a control character.

This makes sense.  Using just "~f " fixed some of the output, but not
all.  I will work more with the format strings.

Thanks,

Joel

-- 
Joel J. Adamson	-- http://www.unc.edu/~adamsonj
University of North Carolina at Chapel Hill
CB #3280, Coker Hall
Chapel Hill, NC 27599-3280

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
  2010-12-20  2:55     ` Joel J. Adamson
@ 2010-12-20 17:26       ` Andy Wingo
  2010-12-21  2:36         ` Joel J. Adamson
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2010-12-20 17:26 UTC (permalink / raw)
  To: Joel J. Adamson; +Cc: bug-guile

On Mon 20 Dec 2010 03:55, adamsonj@email.unc.edu (Joel J. Adamson) writes:

> Andy Wingo <INVALID.NOREPLY@gnu.org> writes:
>
>> ~9,8,,,0g
>
> Using just "~f " fixed some of the output, but not
> all.  I will work more with the format strings.

Note that '0 instead of 0 will pad with #\0 instead of #\nul.

Happy hacking,

Andy
-- 
http://wingolog.org/



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

* Re: [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output
  2010-12-20 17:26       ` Andy Wingo
@ 2010-12-21  2:36         ` Joel J. Adamson
  0 siblings, 0 replies; 6+ messages in thread
From: Joel J. Adamson @ 2010-12-21  2:36 UTC (permalink / raw)
  To: Andy Wingo; +Cc: bug-guile

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

Andy Wingo <wingo@pobox.com> writes:

> On Mon 20 Dec 2010 03:55, adamsonj@email.unc.edu (Joel J. Adamson) writes:
>
>> Andy Wingo <INVALID.NOREPLY@gnu.org> writes:
>>
>>> ~9,8,,,0g
>>
>> Using just "~f " fixed some of the output, but not
>> all.  I will work more with the format strings.
>
> Note that '0 instead of 0 will pad with #\0 instead of #\nul.

Thanks: I think what I really need is some gauze to pad the empty spaces
inside my brain.

Joel

-- 
Joel J. Adamson	-- http://www.unc.edu/~adamsonj
University of North Carolina at Chapel Hill
CB #3280, Coker Hall
Chapel Hill, NC 27599-3280

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2010-12-21  2:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-15 20:58 [bug #31893] ice-9 format produces control characters and non-printable characters for numeric output Joel J. Adamson
2010-12-19 11:51 ` Andy Wingo
2010-12-19 12:14   ` Andy Wingo
2010-12-20  2:55     ` Joel J. Adamson
2010-12-20 17:26       ` Andy Wingo
2010-12-21  2:36         ` Joel J. Adamson

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 read-only IMAP folder(s) and NNTP newsgroup(s).