Nikodemus Siivola <tsiivola@...> writes:
> Higly embarrasing: the patch gets the line numbers of by one -- as
> evidenced by the sample I posted. Apparently counting to five is beyond
Heh. I quite like the idea of "line 0, column 0", but...
> - (let ((error-stream (stream-error-stream condition)))
> - (format stream "READER-ERROR ~@[at ~W ~]on ~S:~%~?"
> - (file-position error-stream) error-stream
> + (let* ((error-stream (stream-error-stream condition))
> + (pos (file-position error-stream))
> + (ary (make-string pos)))
> + (file-position error-stream :start)
> + (read-sequence ary error-stream)
... at this point I don't think you have any guarantee that
ERROR-STREAM is actually a file-stream. Consequently, FILE-POSITION
can return NIL, and rewinding the stream can fail, so the
READ-SEQUENCE call could read from the current stream position. It's
probably worth doing a little more type checking -- remember, you
don't want the condition printing routine to signal an error!
[ Also, this points out something else that's wrong: FILE-POSITION on
a string-stream with a second argument of :START or :END doesn't
recognize these as valid position specifiers. *sigh* ]
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)