From 480977d0645e12f5e108850e061d04a24a5502ee Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 13 May 1997 00:02:05 +0000 Subject: [PATCH] * boot-9.scm (scm-style-repl): After reading an expression, consume any trailing newline (perhaps preceded by whitespace), to avoid screwing up GDB. More detail in comments. --- ice-9/boot-9.scm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index a8ff7215c..cce9b6fb5 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -2347,6 +2347,17 @@ (* 1000 (/ (- (gc-run-time) start-gc-rt) internal-time-units-per-second)))) (display " msec in gc)\n"))) + + (consume-trailing-whitespace + (lambda () + (let ((ch (peek-char))) + (cond + ((eof-object? ch)) + ((or (char=? ch #\space) (char=? ch #\tab)) + (read-char) + (consume-trailing-whitespace)) + ((char=? ch #\newline) + (read-char)))))) (-read (lambda () (if scm-repl-prompt (begin @@ -2359,6 +2370,17 @@ (repl-report-reset))) (run-hooks before-read-hook) (let ((val (read (current-input-port)))) + ;; As described in R4RS, the READ procedure updates the + ;; port to point to the first characetr past the end of + ;; the external representation of the object. This + ;; means that it doesn't consume the newline typically + ;; found after an expression. This means that, when + ;; debugging Guile with GDB, GDB gets the newline, which + ;; it often interprets as a "continue" command, making + ;; breakpoints kind of useless. So, consume any + ;; trailing newline here, as well as any whitespace + ;; before it. + (consume-trailing-whitespace) (run-hooks after-read-hook) (if (eof-object? val) (begin