Fix bug when displaying #\'
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Tue, 16 Nov 1993 16:36:44 +0000 (16:36 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Tue, 16 Nov 1993 16:36:44 +0000 (16:36 +0000)
v7/src/compiler/machines/C/cout.scm

index 4211f970fa3dccf278ad31f6034e9fc8f73433d1..c0aef95eb2d86a1d257706154a0844c99be40904 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: cout.scm,v 1.18 1993/11/16 16:09:15 gjr Exp $
+$Id: cout.scm,v 1.19 1993/11/16 16:36:44 gjr Exp $
 
 Copyright (c) 1992-1993 Massachusetts Institute of Technology
 
@@ -733,7 +733,7 @@ MIT in each case. |#
   (char-set-union char-set:not-graphic (char-set #\\ #\")))
 
 (define char-set:C-named-chars
-  (char-set #\\ #\" #\' #\Tab #\BS
+  (char-set #\\ #\" #\Tab #\BS  ;; #\' Scheme does not quote it in strings
            ;; #\VT #\BEL       ;; Cannot depend on ANSI C
            #\Linefeed #\Return #\Page))
 
@@ -747,6 +747,10 @@ MIT in each case. |#
         (C-quotify-string
          (substring string (1+ index) (string-length string)))))))
 
+;; The following two routines rely on the fact that Scheme and C
+;; use the same quoting convention for the named characters when they
+;; appear in strings.
+
 (define (C-quotify-string-char char)
   (cond ((char-set-member? char-set:C-named-chars char)
         (let ((result (write-to-string (string char))))
@@ -764,13 +768,15 @@ MIT in each case. |#
 
 (define (C-quotify-char char)
   (cond ((not (char-set-member? char-set:C-char-quoted char))
-        (string-append "'" (make-string 1 char) "'"))
+        (string #\' char #\'))
        ((char-set-member? char-set:C-named-chars char)
         (string-append
          "'"
          (let ((s (write-to-string (make-string 1 char))))
            (substring s 1 (-1+ (string-length s))))
          "'"))
+       ((char=? char #\')
+        "'\\''")
        ((char=? char #\NUL)
         "'\\0'")
        (else