---------- Forwarded message ----------
From: $) <[EMAIL PROTECTED]>
Date: 17.10.2006 13:30
Subject: read-line (and probably other input routines) - unexpected behaviour when reading binary files on Windows
To: [email protected]
Hi!
The Chicken manual says that read-line consumes all input from the current input port untill #!eof when called without parameters.
The weird thing is that Scheme IO treats #\x1a (character with code 27) as #!eof when reading from file. The following code snippet prints #!eof:
(define crash-pattern "\x1a (esc) breaks read-line \x1a it is weird")
(with-output-to-file "test.scm.123" (lambda() (display crash-pattern)))
(print(with-input-from-file "test.scm.123 " read-line))
The file "test.scm.123" is written successfully. So I guess that something goes wrong while reading the file?
With-input-from-string or even reading from custom port behaves as expected:
(define crash-pattern "\x1a (esc) breaks read-line and read-string \x1a it is weird")
(define (my-make-string-port str)
(let* (
(str str)
(index -1)
(indexlt (string-length str)))
(make-input-port
(lambda() (set! index(+ 1 index)) (if (< index indexlt) (string-ref str index) #!eof))
(lambda() #t)
(lambda() (void)) )))
(print (with-input-from-string crash-pattern read-line)) ; doen't trim crash-pattern
(print (with-input-from-port (my-make-string-port crash-pattern) read-line)) ; doesn't trim crash-pattern as well
I wonder if this behaviour is by design? Are there any issues related to reading and writing binary data with ports in Chicken Scheme?
WBR, mejedi
Sedna team
_______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
