X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fpp-backq.lisp;h=fd1fb13b386c4472a36c4331816740e361d67f26;hb=44fa19275c08a17b9d80d95102c1a8bc0da7a17e;hp=dc5d6ae62be6334329fbdfc206f4295338e034c3;hpb=7abb9e44907ef12b52ac26d6482fbe21c036ee9b;p=sbcl.git diff --git a/src/code/pp-backq.lisp b/src/code/pp-backq.lisp index dc5d6ae..fd1fb13 100644 --- a/src/code/pp-backq.lisp +++ b/src/code/pp-backq.lisp @@ -43,32 +43,32 @@ (mapcar #'backq-unparse (cdr form))) (backq-list* (do ((tail (cdr form) (cdr tail)) - (accum nil)) - ((null (cdr tail)) - (nconc (nreverse accum) - (backq-unparse (car tail) t))) - (push (backq-unparse (car tail)) accum))) + (accum nil)) + ((null (cdr tail)) + (nconc (nreverse accum) + (backq-unparse (car tail) t))) + (push (backq-unparse (car tail)) accum))) (backq-append (apply #'append - (mapcar (lambda (el) (backq-unparse el t)) - (cdr form)))) + (mapcar (lambda (el) (backq-unparse el t)) + (cdr form)))) (backq-nconc (apply #'append - (mapcar (lambda (el) (backq-unparse el :nconc)) - (cdr form)))) + (mapcar (lambda (el) (backq-unparse el :nconc)) + (cdr form)))) (backq-cons (cons (backq-unparse (cadr form) nil) - (backq-unparse (caddr form) t))) + (backq-unparse (caddr form) t))) (backq-vector (coerce (backq-unparse (cadr form)) 'vector)) (quote (cond - ((atom (cadr form)) (cadr form)) - ((and (consp (cadr form)) - (member (caadr form) *backq-tokens*)) - (backq-unparse-expr form splicing)) - (t (cons (backq-unparse `(quote ,(caadr form))) - (backq-unparse `(quote ,(cdadr form))))))) + ((atom (cadr form)) (cadr form)) + ((and (consp (cadr form)) + (member (caadr form) *backq-tokens*)) + (backq-unparse-expr form splicing)) + (t (cons (backq-unparse `(quote ,(caadr form))) + (backq-unparse `(quote ,(cdadr form))))))) (t (backq-unparse-expr form splicing)))))) @@ -83,9 +83,9 @@ (backq-comma (write-char #\, stream)) (backq-comma-at - (princ ",@" stream)) + (write-string ",@" stream)) (backq-comma-dot - (princ ",." stream))) + (write-string ",." stream))) ;; Ha! an example of where the per-process specials for stream ;; attributes rather than per-stream actually makes life easier. ;; Since all of the attributes are shared in the dynamic state, we @@ -96,14 +96,24 @@ ;; stream, possibly with a space prepended. However, this doesn't ;; work for pretty streams which need to do margin calculations. Oh ;; well. It was good while it lasted. -- CSR, 2003-12-15 - (let ((output (with-output-to-string (s) - (write (cadr form) :stream s)))) - (unless (= (length output) 0) - (when (and (eql (car form) 'backq-comma) - (or (char= (char output 0) #\.) - (char= (char output 0) #\@))) - (write-char #\Space stream)) - (write (cadr form) :stream stream)))) + ;; + ;; This is an evil hack. If we print to a string and then print again, + ;; the circularity detection logic behaves as though it's already + ;; printed that data... and it has, to a string stream that we send + ;; to the bitbucket in the sky. -- PK, 2013-03-30 + (when (eql (car form) 'backq-comma) + (let ((output (with-output-to-string (s) + ;; Patching evil with more evil. The next step is + ;; likely to stop the madness and unconditionally + ;; insert a space. + (let (*circularity-hash-table* + *circularity-counter*) + (write (cadr form) :stream s))))) + (when (and (plusp (length output)) + (or (char= (char output 0) #\.) + (char= (char output 0) #\@))) + (write-char #\Space stream)))) + (write (cadr form) :stream stream)) ;;; This is called by !PPRINT-COLD-INIT, fairly late, because ;;; SET-PPRINT-DISPATCH doesn't work until the compiler works.