X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcode%2Fcondition.lisp;h=8c410d459df1b54ef03eb581845f7730e38657c5;hb=e57523089c7ad0ce2c874c03ecfe721d299efbfb;hp=acaf32b1a885029cc112f2ff6fccb40d329114d7;hpb=c92ed9e146effcd017fea24e4d1fc5e26af73ae0;p=sbcl.git diff --git a/src/code/condition.lisp b/src/code/condition.lisp index acaf32b..8c410d4 100644 --- a/src/code/condition.lisp +++ b/src/code/condition.lisp @@ -766,6 +766,9 @@ (defun %report-reader-error (condition stream &key simple) (let* ((error-stream (stream-error-stream condition)) (pos (file-position-or-nil-for-error error-stream))) + (when (and pos (plusp pos)) + ;; FILE-POSITION is the next character -- error is at the previous one. + (decf pos)) (let (lineno colno) (when (and pos (< pos sb!xc:array-dimension-limit) @@ -786,22 +789,22 @@ :element-type (stream-element-type error-stream)))) (when (= pos (read-sequence string error-stream)) + ;; Lines count from 1, columns from 0. It's stupid and traditional. (setq lineno (1+ (count #\Newline string)) - colno (- pos - (or (position #\Newline string :from-end t) -1) - 1)))) + colno (- pos (or (position #\Newline string :from-end t) 0))))) (file-position-or-nil-for-error error-stream pos)) (pprint-logical-block (stream nil) - (format stream - "~S ~@[at ~W ~]~ - ~@[(line ~W~]~@[, column ~W) ~]~ - on ~S" - (class-name (class-of condition)) - pos lineno colno error-stream) - (when simple - (format stream ":~2I~_~?" - (simple-condition-format-control condition) - (simple-condition-format-arguments condition))))))) + (if simple + (apply #'format stream + (simple-condition-format-control condition) + (simple-condition-format-arguments condition)) + (prin1 (class-name (class-of condition)) stream)) + (format stream "~2I~@[~_~_~:{~:(~A~): ~S~:^, ~:_~}~]~_~_Stream: ~S" + (remove-if-not #'second + (list (list :line lineno) + (list :column colno) + (list :file-position pos))) + error-stream))))) ;;;; special SBCL extension conditions @@ -1088,15 +1091,6 @@ SB-EXT:PACKAGE-LOCKED-ERROR-SYMBOL.")) (define-condition encapsulated-condition (condition) ((condition :initarg :condition :reader encapsulated-condition))) -(define-condition values-type-error (type-error) - () - (:report - (lambda (condition stream) - (format stream - "~@" - (type-error-datum condition) - (type-error-expected-type condition))))) - ;;; KLUDGE: a condition for floating point errors when we can't or ;;; won't figure out what type they are. (In FreeBSD and OpenBSD we ;;; don't know how, at least as of sbcl-0.6.7; in Linux we probably