david135 / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

(display <char>) is not equiv. of put-char #186

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. (display #\tab)

What is the expected output? What do you see instead?
this should print TAB character(9). but "x9;"

There is no standard semantics for DISPLAY procedure(AFAIK)
but (display <char> PORT) should be same as (put-char PORT <char>)
like Chez Scheme.

Original issue reported on code.google.com by oku...@gmail.com on 9 Jan 2011 at 1:16

GoogleCodeExporter commented 9 years ago
cc higepon.

Original comment by oku...@gmail.com on 9 Jan 2011 at 1:36

GoogleCodeExporter commented 9 years ago
Fixed.
https://github.com/higepon/mosh/commit/301fec9454bb46b78b2d2ffc13de609e7444aa65

Original comment by hige...@gmail.com on 9 Jan 2011 at 1:54

GoogleCodeExporter commented 9 years ago
There is still something wrong:

$ mosh-script proof.sps
"x10FFFF; x1;"
$ cat proof.sps
#!r6rs
(import (rnrs))

(let-values (((port getter) (open-string-output-port)))
  (display #\x0010FFFF port)
  (display " " port)
  (display #\x000000001 port)
  (write (getter)))
(newline)

Original comment by mrc....@gmail.com on 5 Feb 2011 at 9:23

GoogleCodeExporter commented 9 years ago
reopened.

DISPLAY might escape unprintable chars(except whitespaces and returns).
Because their displaying representation is not specified in R6RS...

If you really want to do this (in R6RS portable way), use put-char or 
put-string instead.

prism:check oku$ nmosh check.sps 
"\x10FFFF; \x1;"
prism:check oku$ cat check.sps 
#!r6rs
(import (rnrs))

(let-values (((port getter) (open-string-output-port)))
  (put-char port #\x0010FFFF)
  (put-string port " ")
  (put-char port #\x000000001)
  (write (getter)))
(newline)

IMO, these should be handled with transcoders and (display <char>) should be 
equivalent with put-char
as subject of this bug says.

Original comment by oku...@gmail.com on 5 Feb 2011 at 10:19

GoogleCodeExporter commented 9 years ago
I confirmed the problem using this:

#!r6rs
(import (rnrs) 
        (srfi :8) (srfi :42))

(define (check id)
  (let ((c (integer->char id)))
    (define (using-display port return)
      (display c port)
      (return))
    (define (using-put-char port return)
      (put-char port c)
      (return))
    (let ((dsp (call-with-values open-string-output-port using-display))
          (pcr (call-with-values open-string-output-port using-put-char)))
      (unless (string=? dsp pcr)
        (write (list 'ID: id dsp pcr)) (newline)))))

(do-ec (: i 0 #xd800)
       (check i))

(do-ec (: i #xe000 #x110000)
       (check i))

Original comment by oku...@gmail.com on 5 Feb 2011 at 10:37

GoogleCodeExporter commented 9 years ago

Original comment by hige...@gmail.com on 26 Apr 2011 at 1:57