That's a bug... input-port-byte-position should require a "byte port". Device ports such as files are byte ports, but so are u8vector ports. So it should work on u8vector ports. While I was testing this I wrote this code, which you may find useful.
(define (read-as-u8vector filename) (let* ((size (file-size filename)) (u8vect (make-u8vector size 0)) (n (with-input-from-file filename (lambda () (read-subu8vector u8vect 0 size))))) (if (not (equal? n size)) (error "inconsistent file size???") u8vect)))
(define (test filename) (let ((u8vect (read-as-u8vector filename))) (let ((port (open-input-u8vector u8vect))) (let ((content (read-line port))) (close-input-port port) content))))
(pretty-print (test "~/.emacs"))
On 16-Aug-08, at 8:27 AM, Hans Petter Egesund wrote:
Hi, more on slow xml...
I can't get ssax to parse from a string, it seems the library is using input-port-byte-position which needs a device input port. So the attempt so slurp the file into memory, and then do the parsing ends here?!
I will tell if I come up with something interesting.
Petter
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list