reader: fix/unbreak reading of here strings
The repair in 55a27e01a6
wasn't right.
This commit is contained in:
parent
55a27e01a6
commit
6757a202d5
|
@ -214,6 +214,9 @@
|
||||||
(err/rt-test (readstr "\"\\uD800\\uDD1\"") exn:fail:read?)
|
(err/rt-test (readstr "\"\\uD800\\uDD1\"") exn:fail:read?)
|
||||||
|
|
||||||
(test "abc" readstr "#<<EOS\nabc\nEOS\n")
|
(test "abc" readstr "#<<EOS\nabc\nEOS\n")
|
||||||
|
(test "abc\ndef" readstr "#<<EOS\nabc\ndef\nEOS\n")
|
||||||
|
(test "\n" readstr "#<<EOS\n\n\nEOS\n")
|
||||||
|
(test "abc" readstr "#<<EOS\nabc\nEOS\n ")
|
||||||
(test "abc" readstr "#<<EOS\nabc\nEOS")
|
(test "abc" readstr "#<<EOS\nabc\nEOS")
|
||||||
(test "ok\r\nmore\r" readstr "#<<EOS\r\nok\r\nmore\r\nEOS\r")
|
(test "ok\r\nmore\r" readstr "#<<EOS\r\nok\r\nmore\r\nEOS\r")
|
||||||
(err/rt-test (readstr "#<<EOS\nabc\nEO") exn:fail:read?)
|
(err/rt-test (readstr "#<<EOS\nabc\nEO") exn:fail:read?)
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
;; Parse terminator
|
;; Parse terminator
|
||||||
(define full-terminator
|
(define full-terminator
|
||||||
(cons
|
(cons
|
||||||
#\newline
|
#\newline ;; assumption below that this character is first
|
||||||
(let loop ()
|
(let loop ()
|
||||||
(define c (read-char/special in config source))
|
(define c (read-char/special in config source))
|
||||||
(cond
|
(cond
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
(unless (null? terminator)
|
(unless (null? terminator)
|
||||||
(reader-error in config #:due-to c
|
(reader-error in config #:due-to c
|
||||||
"found end-of-file before terminating `~a`"
|
"found end-of-file before terminating `~a`"
|
||||||
(list->string full-terminator)))]
|
(list->string (cdr full-terminator))))]
|
||||||
[(not (char? c))
|
[(not (char? c))
|
||||||
(reader-error in config #:due-to c
|
(reader-error in config #:due-to c
|
||||||
"found non-character while reading `#<<`")]
|
"found non-character while reading `#<<`")]
|
||||||
|
@ -207,8 +207,13 @@
|
||||||
(unless (null? terminator-accum)
|
(unless (null? terminator-accum)
|
||||||
(for ([c (in-list (reverse terminator-accum))])
|
(for ([c (in-list (reverse terminator-accum))])
|
||||||
(accum-string-add! accum-str c)))
|
(accum-string-add! accum-str c)))
|
||||||
(accum-string-add! accum-str c)
|
(cond
|
||||||
(loop full-terminator null)]))
|
[(char=? c #\newline)
|
||||||
|
;; assume `full-terminator` starts with #\newline
|
||||||
|
(loop (cdr full-terminator) (list #\newline))]
|
||||||
|
[else
|
||||||
|
(accum-string-add! accum-str c)
|
||||||
|
(loop full-terminator null)])]))
|
||||||
|
|
||||||
;; Done
|
;; Done
|
||||||
(define str (accum-string-get! accum-str config))
|
(define str (accum-string-get! accum-str config))
|
||||||
|
|
|
@ -52069,7 +52069,8 @@ static const char *startup_source =
|
||||||
"(let-values(((c102_0) c_88)"
|
"(let-values(((c102_0) c_88)"
|
||||||
"((temp103_2)"
|
"((temp103_2)"
|
||||||
" \"found end-of-file before terminating `~a`\")"
|
" \"found end-of-file before terminating `~a`\")"
|
||||||
"((temp104_2)(list->string full-terminator_0)))"
|
"((temp104_2)"
|
||||||
|
"(list->string(cdr full-terminator_0))))"
|
||||||
"(reader-error10.1"
|
"(reader-error10.1"
|
||||||
" #f"
|
" #f"
|
||||||
" #f"
|
" #f"
|
||||||
|
@ -52149,8 +52150,15 @@ static const char *startup_source =
|
||||||
" for-loop_6)"
|
" for-loop_6)"
|
||||||
" lst_96)))"
|
" lst_96)))"
|
||||||
"(void))))"
|
"(void))))"
|
||||||
|
"(if(char=? c_88 '#\\newline)"
|
||||||
|
"(let-values()"
|
||||||
|
"(loop_113"
|
||||||
|
"(cdr full-terminator_0)"
|
||||||
|
"(list '#\\newline)))"
|
||||||
|
"(let-values()"
|
||||||
|
"(begin"
|
||||||
"(accum-string-add! accum-str_5 c_88)"
|
"(accum-string-add! accum-str_5 c_88)"
|
||||||
"(loop_113 full-terminator_0 null))))))))))))"
|
"(loop_113 full-terminator_0 null)))))))))))))))"
|
||||||
" loop_113)"
|
" loop_113)"
|
||||||
" full-terminator_0"
|
" full-terminator_0"
|
||||||
" null)"
|
" null)"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user