aboutsummaryrefslogtreecommitdiffstats
path: root/strsrch.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
commitbd9733926076885e3417b74de76e4c9c7bc56254 (patch)
tree2c99dced547d48407ad44cb0e45e31bb4d02ce43 /strsrch.scm
parentfa3f23105ddcf07c5900de47f19af43d1db1b597 (diff)
downloadslib-bd9733926076885e3417b74de76e4c9c7bc56254.tar.gz
slib-bd9733926076885e3417b74de76e4c9c7bc56254.zip
Import Upstream version 2c7upstream/2c7
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 ()