X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fprint.lisp;h=48af786e0b52972902a752909d871e00c304a4ea;hb=bdf672312657b00576cdd26367c2b0ef2a340b27;hp=941b97c6a148ff52f733a7455c0df68726d87ce4;hpb=77ec86f4b46f8f39589c07ccd92c21a4c076cc4d;p=jscl.git diff --git a/src/print.lisp b/src/print.lisp index 941b97c..48af786 100644 --- a/src/print.lisp +++ b/src/print.lisp @@ -18,6 +18,21 @@ ;;; 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)