Ticket #557: pp-fix.diff

File pp-fix.diff, 2.1 KB (added by Mario Domenech Goulart, 13 years ago)

Proposed fix to pretty-print

  • extras.scm

    diff --git a/extras.scm b/extras.scm
    index a2b0d7c..7b0142d 100644
    a b  
    337337                                    (let loop ((i 0) (j 0) (col (out "\"" col)))
    338338                                      (if (and col (fx< j (string-length obj)))
    339339                                          (let ((c (string-ref obj j)))
    340                                             (cond ((assq c '((#\\ . "\\")
    341                                                              (#\" . "\\\"")
    342                                                              (#\tab . "\\t")
    343                                                              (#\newline . "\\n")
    344                                                              (#\return . "\\r")))
    345                                                    =>
    346                                                    (lambda (a)
    347                                                      (let ((col2
    348                                                             (out (##sys#substring obj i j) col)))
    349                                                        (loop (fx+ j 1)
    350                                                              (fx+ j 1)
    351                                                              (out (cdr a) col2)))))
    352                                                   (else (loop i (fx+ j 1) col))))
     340                                            (if (or (char=? c #\\)
     341                                                    (char=? c #\"))
     342                                                (loop j
     343                                                      (+ j 1)
     344                                                      (out "\\"
     345                                                           (out (##sys#substring obj i j)
     346                                                                col)))
     347                                                (cond ((assq c '((#\tab . "\\t")
     348                                                                 (#\newline . "\\n")
     349                                                                 (#\return . "\\r")))
     350                                                       =>
     351                                                       (lambda (a)
     352                                                         (let ((col2
     353                                                                (out (##sys#substring obj i j) col)))
     354                                                           (loop (fx+ j 1)
     355                                                                 (fx+ j 1)
     356                                                                 (out (cdr a) col2)))))
     357                                                      (else (loop i (fx+ j 1) col)))))
    353358                                          (out "\""
    354359                                               (out (##sys#substring obj i j) col))))))
    355360            ((char? obj)        (if display?