fix `read-language' exn construction in an EOF case

Closes PR 11683
 Merge to 5.1
(cherry picked from commit dd5f0dfc80)
This commit is contained in:
Matthew Flatt 2011-01-31 06:47:37 -07:00 committed by Eli Barzilay
parent 7b34013eda
commit c417d1f39d
2 changed files with 14 additions and 0 deletions

View File

@ -1103,6 +1103,13 @@
;; Check error-message formatting:
(err/rt-test (read (open-input-string "#l"))
(lambda (exn) (regexp-match? #rx"`#l'" (exn-message exn))))
;; Make sure read-language error here is this can comes from read-language
;; and not from an ill-formed srcloc construction:
(let ()
(define p (open-input-string ";\n"))
(port-count-lines! p)
(err/rt-test (read-language p)
(lambda (exn) (regexp-match? #rx"read-language" (exn-message exn)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -992,6 +992,13 @@ read_inner_inner(Scheme_Object *port, Scheme_Object *stxsrc, Scheme_Hash_Table *
dispatch_ch = ch;
if (get_info && (dispatch_ch != '#') && (dispatch_ch != ';')) {
/* If ch is EOF, then col or pos wasn't incremented by reading ch.
The col and pos might be used in an error message, which expects
to subtract one from each --- so counteract by adding one here. */
if (ch == EOF) {
if (pos >= 0) pos++;
if (col >= 0) col++;
}
return expected_lang("", ch, port, stxsrc, line, col, pos, get_info);
}