io: fix printing of '||

This commit is contained in:
Matthew Flatt 2019-01-01 13:58:48 -07:00
parent 13e2817a2d
commit f85d18aed6
2 changed files with 10 additions and 2 deletions

View File

@ -60,6 +60,7 @@
(ptest "#\\x" #\x) (ptest "#\\x" #\x)
(ptest "'apple" 'apple) (ptest "'apple" 'apple)
(ptest "'|apple banana|" '|apple banana|) (ptest "'|apple banana|" '|apple banana|)
(ptest "'||" '||)
(ptest "'#:apple" '#:apple) (ptest "'#:apple" '#:apple)
(ptest "\"apple\"" "apple") (ptest "\"apple\"" "apple")
(ptest "#\"apple\"" #"apple") (ptest "#\"apple\"" #"apple")

View File

@ -56,12 +56,19 @@
(cond (cond
[(or for-keyword? [(or for-keyword?
for-type? for-type?
(not (string->number? str))) (and (not (string->number? str))
(not (string=? str ""))))
str] str]
;; Remaining two cases add some form of quoting to ;; Remaining two cases add some form of quoting to
;; protect against a symbol looking like a number ;; protect against a symbol looking like a number
[(and config (not (config-get config read-accept-bar-quote))) [(and config (not (config-get config read-accept-bar-quote)))
(string-append "\\" str)] (cond
[(string=? str "")
;; There's no good answer in this case. Traditionally, Racket
;; just prints an empty string, anyway.
str]
[else
(string-append "\\" str)])]
[else [else
(string-append "|" str "|")])] (string-append "|" str "|")])]
[(or (and config (not (config-get config read-accept-bar-quote))) [(or (and config (not (config-get config read-accept-bar-quote)))