aboutsummaryrefslogtreecommitdiffstats
path: root/strsrch.scm
diff options
context:
space:
mode:
Diffstat (limited to 'strsrch.scm')
-rw-r--r--strsrch.scm15
1 files changed, 9 insertions, 6 deletions
diff --git a/strsrch.scm b/strsrch.scm
index 68bcf0e..71c69df 100644
--- a/strsrch.scm
+++ b/strsrch.scm
@@ -66,16 +66,19 @@
(set! max-no-char (if (null? max-no-char) #f (car max-no-char)))
(letrec
((no-chars-read 0)
+ (peeked? #f)
(my-peek-char ; Return a peeked char or #f
(lambda () (and (or (not (number? max-no-char))
(< no-chars-read max-no-char))
(let ((c (peek-char <input-port>)))
- (and (not (eof-object? c))
- (if (procedure? max-no-char)
- (not (max-no-char c))
- (not (eqv? max-no-char c)))
- c)))))
- (next-char (lambda () (read-char <input-port>)
+ (cond (peeked? c)
+ ((eof-object? c) #f)
+ ((procedure? max-no-char)
+ (set! peeked? #t)
+ (if (max-no-char c) #f c))
+ ((eqv? max-no-char c) #f)
+ (else c))))))
+ (next-char (lambda () (set! peeked? #f) (read-char <input-port>)
(set! no-chars-read (+ 1 no-chars-read))))
(match-1st-char ; of the string str
(lambda ()