Skip to content

Commit

Permalink
Clear buffered input when a reader raise an error
Browse files Browse the repository at this point in the history
so that subsequent read won't be confused.
#1078
  • Loading branch information
shirok committed Nov 7, 2024
1 parent e810d55 commit 45df1ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2024-11-07 Shiro Kawai <[email protected]>

* lib/gauche/interactive/editable-reader.scm (make-editable-reader):
Clear buffered input when a reader raise an error, so that
subsequent read won't be confused.
* src/gauche.h (SCM_CHAR_MAX): Change SCM_CHAR_MAX to 0x10ffff.
We intentionally took wider range for the room of extension,
but now that internal encoding is fixed to utf-8 and more
Expand Down
7 changes: 6 additions & 1 deletion lib/gauche/interactive/editable-reader.scm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@
[buffer (open-input-string "")])
(define (read-1 reader)
(rec (try)
(let1 x (reader buffer)
(let1 x (guard (e [(is-a? e <read-error>)
;; discard remaining input so that subsequent
;; read won't be confused
(set! buffer (open-input-string ""))
(raise e)])
(reader buffer))
(if (eof-object? x)
(let1 input (read-line/edit ctx)
(if (eof-object? input)
Expand Down

0 comments on commit 45df1ab

Please sign in to comment.