* Better dealing with errors in eval-string and read-from-string/-all

* Made them work with byte strings too
* Added tests to the above

svn: r5081

original commit: a772fa8c8407386a2279c4d6ea2d6294de7c83c0
This commit is contained in:
Eli Barzilay 2006-12-11 18:03:33 +00:00
parent 6032d24e71
commit d17918a616
2 changed files with 10 additions and 12 deletions

View File

@ -143,9 +143,7 @@
(define cache-image-snip-class% (define cache-image-snip-class%
(class snip-class% (class snip-class%
(define/override (read f) (define/override (read f)
(let ([data (read-from-string (bytes->string/utf-8 (send f get-bytes)) (let ([data (read-from-string (send f get-bytes) (lambda () #f))])
void
(lambda (x) #f))])
(if data (if data
(argb->cache-image-snip (make-argb (first data) (second data)) (argb->cache-image-snip (make-argb (first data) (second data))
(third data) (third data)

View File

@ -36,8 +36,8 @@ needed to really make this work:
(define syntax-snipclass% (define syntax-snipclass%
(class snip-class% (class snip-class%
(define/override (read stream) (define/override (read stream)
(let ([str (send stream get-bytes)]) (make-object syntax-snip%
(make-object syntax-snip% (unmarshall-syntax (read-from-string (bytes->string/utf-8 str)))))) (unmarshall-syntax (read-from-string (send stream get-bytes)))))
(super-instantiate ()))) (super-instantiate ())))
(define snip-class (make-object syntax-snipclass%)) (define snip-class (make-object syntax-snipclass%))