X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fprint.lisp;h=8cb36bd2db7092f5aff371de226b9ac95355571c;hb=dea14bb78b0fc90032373212912a16ed1f6a4a29;hp=941b97c6a148ff52f733a7455c0df68726d87ce4;hpb=77ec86f4b46f8f39589c07ccd92c21a4c076cc4d;p=jscl.git diff --git a/src/print.lisp b/src/print.lisp index 941b97c..8cb36bd 100644 --- a/src/print.lisp +++ b/src/print.lisp @@ -16,8 +16,25 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading print.lisp!") + ;;; 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) @@ -28,6 +45,7 @@ (when (or (terminalp ch) (char= ch #\:) (char= ch #\\) + (not (char= ch (char-upcase ch))) (char= ch #\|)) (return-from escape-symbol-name-p t)))) dots-only)) @@ -241,7 +259,7 @@ (defun write-line (x) (write-string x) - (write-string *newline*) + (write-char #\newline) x) (defun warn (string) @@ -265,7 +283,7 @@ ((char= next #\~) (concatf res "~")) ((char= next #\%) - (concatf res *newline*)) + (concatf res (string #\newline))) ((char= next #\*) (pop arguments)) (t