;;; Printer
+(defun lisp-escape-string (string)
+ (let ((output "")
+ (index 0)
+ (size (length string)))
+ (while (< index size)
+ (let ((ch (char string index)))
+ (when (or (char= ch #\") (char= ch #\\))
+ (setq output (concat output "\\")))
+ (when (or (char= ch #\newline))
+ (setq output (concat output "\\"))
+ (setq ch #\n))
+ (setq output (concat output (string ch))))
+ (incf index))
+ (concat "\"" output "\"")))
+
;;; Return T if the string S contains characters which need to be
;;; escaped to print the symbol name, NIL otherwise.
(defun escape-symbol-name-p (s)
(#\space "space")
(otherwise (string form)))))
((stringp form) (if *print-escape*
- (concat "\"" (escape-string form) "\"")
+ (lisp-escape-string form)
form))
((functionp form)
(let ((name (oget form "fname")))
(concatf res "~"))
((char= next #\%)
(concatf res *newline*))
+ ((char= next #\*)
+ (pop arguments))
(t
(concatf res (format-special next (car arguments)))
(pop arguments))))
res)))
(defun format-special (chr arg)
- (case chr
+ (case (char-upcase chr)
(#\S (prin1-to-string arg))
- (#\a (princ-to-string arg))))
+ (#\A (princ-to-string arg))))