bugGuile - Bugs: bug #31893, ice-9 format produces control...

 
 

bug #31893: ice-9 format produces control characters and non-printable characters for numeric output

Submitter:  Joel J. Adamson <trashbird1240>
Submitted:  Wed 15 Dec 2010 08:58:34 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 19 Dec 2010 12:14:35 PM UTC, 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 #\0 -- 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

Andy Wingo <wingo>
Group administrator
Sun 19 Dec 2010 11:51:43 AM UTC, comment #1: 

Very interesting! We can make the test case shorter:

> (format #f "~9,8,,,0g" 0.001)

$1 = "\x00\x00\x00\x00\x00\x00\x00\x00\x00"


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!

Andy Wingo <wingo>
Group administrator
Wed 15 Dec 2010 08:58:34 PM UTC, original submission:  

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))

Joel J. Adamson <trashbird1240>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #22211:  ss_theory_scm.tar.gz added by trashbird1240 (4KiB - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by wingo (Posted a comment)
  • -email is unavailable- added by trashbird1240 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-12-19 wingo StatusNone Invalid
        Open/ClosedOpen Closed
    2010-12-15 trashbird1240 Attached File- Added ss_theory_scm.tar.gz, #22211

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code